DC components and ruby
-
Just to pass on my experiences.
I thought I would convert one of my plugins to use DC components which look perfect for editing afterwards. The DC components in question allow scaling in only one axis.
On calling the plugin, I copy into the current file a virgin DC component (if necessary), place as the user has specified with screen hits and edit the DC to match the length required as shown in the code below. Note: I built the DC in centimeters which requires some mod to the value passed, although looking at it now I guess values are always passed in inches.
# set DC attributes compdef = comp.definition ad = compdef.attribute_dictionary "dynamic_attributes" divlen = (ad["_lengthunits"] == "CENTIMETERS") ? 2.54 ; 1.0 shedlen = ((@numbays * @baysize) + (@curoutloff * 2)).to_cm / divlen ad["_leny_nominal"] = shedlen.to_s $dc_observers.get_latest_class.redraw_with_undo(comp)
All fine and dandy as the user can use the scale tool to modify the length.
The problem is that the DC component mechanism puts such a heavy load on building the geometry that what
is pretty much instantaneous with my SU6 version which does the build within the plugin, the DC component takes 20 seconds to build. I suspect there is a bucket load of observers to manage.I am now thinking of reverting back to my previous version and see if I can reuse the DC Component>Component Options code to have a version specific to my plugins which at least allows value changes.
For the guys at Google, in a perfect world, I would like to have a simple way of incorporating a Component>Component Options dialog (maintained by Google) into my code with hooks for calling my draw code. In my time, I have done a lot of Vectorworks plugin development and by way of comparison, setting up a plugin interface is very easy.
-
That's a great idea, Bill. I've added it to the feature request list.
Cheers,
Advertisement