Determining Corner Points
-
I've been thinking about adding an edit feature into the Truss Plugin so that a user can click on a truss or roof assembly and edit all of the parameters rather than having to delete and recreate the geometry with the plugin.
The only problem I am having with this is I need to some how store or retrieve the corner points that were originally selected when the truss assembly was created. This is normally pretty simple except what if the user creates the truss assembly and then later moves it to a new location. Now if they go back and edit the truss assembly within the plugin the assembly will be recreated at the original points and not at the new location.
Any ideas on how to deal with this?
-
Perhaps by creating an attribute record when the truss is created.
truss.add_attribute("This Truss Type","First Point",pt1)
truss.add_attribute("This Truss Type","Second Point",pt2)Then you can retrieve the creation data using
pt1=truss.get_attribute("This Truss Type","First Point")
-
This had occurred to me but the problem arises when the assembly (group) is then moved or rotated to a new position post creation. The stored points are no longer valid. I need some way of accessing their absolute positions regardless of how to truss assembly is moved.
-
Are the original
pt1
andpt2
created in themodel.active_entities
context ?
Ifpt1
is always theORIGIN
then you really only needpt2
?
Why not use a transformation ?
You can store the initialtruss.transformation.to_a
as an attribute with the truss.
Then... when you next need to assess the current truss location/rotation just get the currenttruss.transformation
and then modify [transform!] it OR even the saved point [or 2 points] - having adjusted it by the transformation that was stored as it was created - recreated from the attribute array back into a transformation.
http://www.sketchup.com/intl/en/developer/docs/ourdoc/transformation
Advertisement