Dynamic Component Redraw

Dynamic Component Redraw

Postby JonD » Mon Oct 05, 2009 10:07 pm

Is there an observer to catch the 'event' when a user applies a change to a dynamic component that causes it to redraw? I need to beable to force a redraw of another dynamic component if a change happens to another. I thought I saw something on a dynamic component observer, but I cannot find any documentation on it...

Thanks,
Jon
0

JonD 
PluginStore Author
PluginStore Author
 

Re: Dynamic Component Redraw

Postby bsnantes » Thu Dec 17, 2009 12:51 am

I have the same need. Did you find any solutions ?
0

bsnantes 
 

Re: Dynamic Component Redraw

Postby JonD » Wed Jan 06, 2010 6:17 am

Nothing yet...
0

JonD 
PluginStore Author
PluginStore Author
 

Re: Dynamic Component Redraw

Postby Chris Fullmer » Wed Jan 06, 2010 9:25 am

well supposedly the refresh method will force a redraw. Did you try that method? It might need to be implemented inside of a tool class. Did you look into that method?

Chris
0
Lately you've been tan, suspicious for the winter.
All my Plugins I've written
User avatar
Chris Fullmer 
SketchUp Team
SketchUp Team
 

Re: Dynamic Component Redraw

Postby thomthom » Wed Jan 06, 2010 9:48 am

Chris Fullmer wrote:well supposedly the refresh method will force a redraw. Did you try that method? It might need to be implemented inside of a tool class. Did you look into that method?

Chris

He need the refresh method and an event callback...
0
Thomas Thomassen — SketchUp Monkey & Coding addict
List of my plugins and link to the CookieWare fund
User avatar
thomthom 
PluginStore Author
PluginStore Author
 

Re: Dynamic Component Redraw

Postby Jim » Wed Jan 06, 2010 2:49 pm

I think it should be possible. The operation of DC's are not documented, but this blog post might contain some useful examples.

http://sketchupapi.blogspot.com/2009/07 ... scene.html
0
Hi

Jim 
Global Moderator
 

Re: Dynamic Component Redraw

Postby ScottLininger » Wed Jan 06, 2010 6:14 pm

Hey guys,

There is no observer for DC redraw. I did think of a trick you could try, however.

The "functions" that can be called as part of a DC formula are defined in a class called DCFunctionsV1. Any protected methods inside that class are discovered by the DC plugin by reflection and can be called inside a DC spreadsheet formula. Since every formula is run each time a DC is redrawn, you can call your own ruby code this way.

For example, let's make a new DC spreadsheet function that shows a messagebox:

1. Save this script as customDCFunctions.rb into your plugins directory.

Code: Select all
# Adds custom DC spreadsheet functions.
class DCFunctionsV1
 
  protected
 
  # Shows a messagebox from DC formula.
  # Example Formula: =messagebox("something")
  def messagebox(param_array)
    val = param_array[0]
    UI.messagebox(val.to_s)
    return val
  end

  # Returns first thing, alphabetically, in list of params.
  # Example Formula: =firstAlpha("bob", "cal", "amy", "dan")
  def firstalpha(param_array)
    return param_array.sort.first
  end

end


2. Restart SU, and create a new DC. Add a custom attribute called "onredraw" (or whatever you want) with the following formula:
Code: Select all
=messagebox("Hello")


Whenever that DC is redrawn (manipulate it with the scale tool, for example), you'll see your messagebox. You could just as easily call some more complex code. People who have your script installed will get the behavior you want. People without it won't, of course, so you'd need to be careful about that.

Hope that gets you started. :)
0
- Scott Lininger
SketchUp Software Engineer
Have you visited the Ruby API Docs?
User avatar
ScottLininger 
 

Re: Dynamic Component Redraw

Postby JonD » Sun Jan 10, 2010 4:56 am

Many thanks Scott, Thom and Chris. I will give this a try when I get back to the workstation.
0

JonD 
PluginStore Author
PluginStore Author
 

Re: Dynamic Component Redraw

Postby JBPM » Fri Oct 13, 2017 4:35 pm

@ScottLininger 
 
Hi!
You code is interesting. (customDCFunctions.rb)
I try it but I got a error message when I open SU

Error Loading File CustomDCFunctions.rb
Error: #<SyntaxError: C:/Users/Design6/AppData/Roaming/SketchUp/SketchUp 2017/SketchUp/Plugins/CustomDCFunctions.rb:11: void value expression
C:/Users/Design6/AppData/Roaming/SketchUp/SketchUp 2017/SketchUp/Plugins/CustomDCFunctions.rb:17: void value expression>


Do you have a clue, why?

Thank you
0

JBPM 
 

Re: Dynamic Component Redraw

Postby Dan Rathbun » Fri Oct 13, 2017 10:09 pm

Scott Lininger left Trimble/SketchUp several years ago to start his own company. (He is unlikely to see or reply to your question. Ie, this topic thread is at least 7 years old!)

There are more recent threads on making custom DC functions (but you should not publish any custom changes.)

See this thread:
viewtopic.php?f=180&t=67235
0
    I'm not here much anymore. But a PM will fire email notifications.
    User avatar
    Dan Rathbun 
    PluginStore Author
    PluginStore Author
     

    SketchUcation One-Liner Adverts

    by Ad Machine » 5 minutes ago



    Ad Machine 
    Robot
     



     

    Return to Developers' Forum

    Who is online

    Users browsing this forum: No registered users and 16 guests

    Visit our sponsors: