Dynamic Component Redraw
-
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 -
I have the same need. Did you find any solutions ?
-
Nothing yet...
-
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
-
@chris fullmer said:
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...
-
I think it should be possible. The operation of DC's are not documented, but this blog post might contain some useful examples.
Dynamic Components that react to scene (aka page) changes
Have you ever wanted to have a Dynamic Component that reacts to Scene changes? Well, this blogpost tells you how to write one (th...
(sketchupapi.blogspot.com)
-
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:
- Save this script as customDCFunctions.rb into your plugins directory.
# 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
- Restart SU, and create a new DC. Add a custom attribute called "onredraw" (or whatever you want) with the following formula:
=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.
-
Many thanks Scott, Thom and Chris. I will give this a try when I get back to the workstation.
-
@ScottLininger
Hi!
You code is interesting. (customDCFunctions.rb)
I try it but I got a error message when I open SU@unknownuser said:
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
-
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:
http://sketchucation.com/forums/viewtopic.php?f=180&t=67235
Advertisement