Attributes (auto updating)
-
I've been investigating attributes today trying to get a better handle on this aspect of SketchUp. I've noticed that the housebuilder plugin creates a category called "einfo" and stores a number of variables one of which is the "origin". If you manually move the wall group the origin attribute will automatically reflect this change in location. This is exactly the feature I need for my various assemblies (groups) so that I can add an edit feature into my own plugin. Howevever, I can't seem to figure out how this attribute is automatically updating. When I create an "origin" attribute under a "einfo" category it does not update. I must be missing something.
-
Cross-posted:
http://forums.sketchup.com/t/attributes-that-auto-update/27840(and gave answer there.)
-
Thank-you, but please read recent findings:
Investigating this a bit more and I've found out some more interesting behavior.
Here is the chunk of code after I create the main group that includes all of the sub-groups and sub-components:
[highlight=#ffffff:uqexfhhl]################################## # # Foundation Assembly Information @maingrouporigin = @maingroup.transformation.origin @maingrouprotz = @maingroup.transformation.rotz # puts @maingrouporigin @maingrouprotz mdkinfo = 'MedeekInfo' @maingroup.set_attribute mdkinfo, 'name', "FOUNDATION_ASSEMBLY_#{formatted_time}" @maingroup.set_attribute mdkinfo, 'original_origin', @maingrouporigin @maingroup.set_attribute mdkinfo, 'original_rotz', @maingrouprotz[/highlight:uqexfhhl]
I am attempting to store the original origin and Z rotation of the group as some attributes that can be accessed at a later time. When I do this and then manually move the group the attribute "original_origin" updates to the new origin. When I manually rotate the group the attribute "original_rotz" does not update.
I also noticed that the value from transformation.rotz is always rounded to the nearest integer value. So if my group was originally rotate 12.75 degrees, then it will store as 12 degrees.
-
@medeek said:
Howevever, I can't seem to figure out how this attribute is automatically updating.
I came across some code not too long ago that could explain this - but there is no documentation for this. SketchUp seem to apply transformations to Geom::Point3d and Geom::Vector3d object stored in attributes. This might be what you want some times - other times if you don't want it, store them as arrays.
I need to dig up that code again to remember exactly what is going on.
(Example snippets/model of what you observe would be useful.)
-
@thomthom said:
@medeek said:
Howevever, I can't seem to figure out how this attribute is automatically updating.
I came across some code not too long ago that could explain this - but there is no documentation for this. SketchUp seem to apply transformations to
Geom::Point3d
andGeom::Vector3d
object stored in attributes. This might be what you want some times - other times if you don't want it, store them as arrays.Which is basically what I said in the duplicate thread in the SketchUp forum, ...
http://forums.sketchup.com/t/attributes-that-auto-update/27840... which has gone beyond the original questions.
Advertisement