Storing Bounding Points
-
I'm working on making it possible to edit a truss assembly once it has been created. The only thing holding me back is a way of storing or retrieving the original bounding points of the assembly. This is not a problem provided the assembly is not moved after it was created however if it is re-positioned after it is created then I need to figure out a way of determining the bounding points at the new location. I was thinking of using the construction point feature but I'm unsure if one can reference them by name in a new session? Perhaps there is a better method of doing this.
-
The SketchUp team had created an example
Parametric
superclass that helps in saving original construction parameters, into a attribute dictionary attached to the group or component.The main problem with it is that it is not distributed stand-alone, and the several "team" extensions that use it have divergent versions. Ie, I think the "3D Shapes" extension did some revisions and fixes to it, but other extensions like the "Window Maker" extension still have the original.
You can see the code and copy the latest
Parametric
class from:
https://github.com/SketchUp/sketchup-shapes
(It is released under the MIT License.)So your options are (1) to copy the
Parametric
class into your own extension sub-module, use it as is, or subclass it and make whatever changes you need for your extension's use.Or (2), require your users to download the Trimble Team's "3D Shapes" extension, and then use it as a superclass via qualification. (Users do not actually have to have it switched "on", just have the "su_shapes/parametric.rb" file available.) This way you can leverage any future fixes to the
Parametric
class, .. but future changes could also break your plugin.Either:
(a) ... use as is without modification:
require "su_shapes/parametric.rb" module MedeekDesign module TrussMaker Parametric = Class;;new(CommunityExtensions;;Shapes;;Parametric) end end
(b) ... make local modifications for your extension. Be sure to understand the use of the Ruby keyword
super
if the superclass' methods need to be called within your method overrides:require "su_shapes/parametric.rb" module MedeekDesign module TrussMaker class Parametric < CommunityExtensions;;Shapes;;Parametric # override methods here end end end
-
I like to keep my data in a structure and I like to save structures to disk and / or store them as a complete record in a dictionary.
So you can either parse the file / or parse the dictionary in the same exact way.
Actually very simple and extremely future proof as they are key pairs. New versions that introduce new fields (elements) need only provide a reasonable default.
I can provide you with examples if you want to PM me.
Advertisement