I hope this is the right forum to post this in.
I am pretty new to making my own Ruby scripts, so I'm not sure how to do this.
I have some dynamic components I have made, and exported them out of the model as their own .skp files. I want my script to get two points from the user, then load and insert the component at the point specified by the first click, scale it along one axis, then rotate it into position so the second end is at the point specified by the second click. There is also I prompt for the user to set certain values, which are then applied to attributes on the component, as well as the geometry changed.
I have everything working more or less perfectly, with one exception: While the attributes are set on the component, the geometry and textures are not updated on the model until I either edit the components properties manually, or scale it manually.
How would I go about having Ruby update the appearance of the component after all the attributes are changed?
Here's a truncated version/snippet of what I have:
- Code: Select all
#load the file
newcomp_def = Sketchup.active_model.definitions.load("Q:\Test.skp")
#create insertion transform
trans1 = Geom::Transformation.new p1
#transform scale along y to correct size
trans2 = Geom::Transformation.scaling p1, 1, (length/12), 1
#move the box over since in my model it's centered and I want it on edge
scootvec = Geom::Vector3d.new (width/2),0,0
#create transform from vector
trans3 = Geom::Transformation.translation scootvec
entities = Sketchup.active_model.active_entities
#insert component at point 1
instance = entities.add_instance newcomp_def, trans1
#scale it to length
instance.transform! trans2
#move it over by half
instance.transform! trans3
#rotate it to the correct angle
instance.transform! transrot
#set attributes
instance.set_attribute("dynamic_attributes", "product", "Name")
instance.set_attribute("dynamic_attributes", "width", width)
instance.set_attribute("dynamic_attributes", "depth", depth)
I have formulas on the component to set the textures, x and z dimension, etc. I have confirmed the values are changed by going into the component editor, the appearance just doesn't change/isn't updated.
Is it simple to accomplish this?
Thanks!
PlacidFury