@tig said:
Have you tried tr=container.transformation.inverse and applying it to the initial object and then iterating and getting/setting the transformation for the container's container etc until you get to the model level...
That didn't seem to work (inverse), though I may very well have misunderstood what you meant, but what you said gave me an answer anyway. By applying the transform to the points at each container successively, it works perfectly! (or at least in every test so far)
Which is how I should have tried it initially but I was thinking from a performance standpoint, and forgot the old adage "premature optimization is the root of all evil"
def WALK.GetParent(ent)
Sketchup.active_model.start_operation("Walk")
model = Sketchup.active_model
@newg = model.entities.add_group
m = model.materials.add "test"
m.color="red"
orig = ent
tpos = Geom;;Point3d.new 0,0,0 # keep track of origin
trans = Geom;;Transformation.new(Geom;;Point3d.new(0,0,0)) # add transforms to this
vertices = orig.outer_loop.vertices.map {|v| v.position.clone}
while (ent.respond_to?('parent') ) # walk up hierarchy
if ((ent.is_a? Sketchup;;ComponentDefinition))
if ent.group?
t = ent.instances[0].transformation # Get the group's transform
vertices.each_with_index do |v,i|
vertices[i].transform! t
end
end
ent = ent.instances[0] # become the instance
end
ent = ent.parent
end
f = @newg.entities.add_face vertices # create the face
f.material=m
Sketchup.active_model.commit_operation
end
Thanks again for the help!