I’ve used the original
parametric.rb plugin from the Sketchup team in two of my plugins, SU Draw Parametric Shapes, and Polyhedra (both hosted on the SketchUcation Plugin Store).
It suffered from two drawbacks, which I’m pleased to say have now been fixed by Steve Baumgartner (@slbaumgartner). Many thanks, Steve.
1.Parameter order was not preserved when Editing an already-drawn component, as the parameter key/value pairs were stored in a hash, not an array, and would be returned in an arbitrary order.
2.If I installed both plugins, then I would get duplicate entries in the context menu when right-clicking to edit a drawn shape or polyhedron.
To preserve key/parameter order, each derived class in the calling function now needs to define a new function which passes an array of keys to
parametric.rb in the required order. Here’s an example from the Shapes plugin, for a Helix shape:
def keys ['start_radius','end_radius','start_height','end_height','start_angle','rotations','num_segments'] end
To preserve backward compatibility, the revised
parametric.rb implements a default
keys method which returns
nil , if not overridden by the derived class as in the example above.
I’ve updated both my plugins on SketchUcation to use the revised
parametric.rb plugin, which will be installed along with the parent program when you update the plugin.
You need to restart SU after updating the plugin.
Here’s the updated code. Note, if you want to use it yourself, change the Module name to show your own initials and calling program name, to avoid namespace clashes.
parametric.rb (14.4 KB)