Recommendations for animation code?

move! seems to improve performance in my test models…

continuing on needing animation code advice…

now I’ve written some ‘animated’ test code to try and understand the whole transformation business…

it helping, but I still don’t get it…

I’m trying to sel.add the 4 sub-groups from inside the 2 parent groups that are 3 way flipped copies…

I only get two items from the intersection and they highlight in both parent groups?

the model >> test_selector_2.skp (110.7 KB)

and the test code…

model = Sketchup.active_model
defs  = model.definitions
ents  = model.active_entities
sel   = model.selection
title = model.title
selector = defs['selector'].instances[0]
sbb = selector.bounds
view = model.active_view
begin
model.start_operation('move')
defs.to_a.map do |defn|
  next if defn == selector
  defn.instances.map do |inst|
   next if inst.parent == model
 #  ptr = inst.parent.transformation
   itr = inst.transformation
   tr = itr # ptr * itr
   model.active_entities.transform_entities(tr, inst)
   view.refresh
sleep 0.2
   model.active_entities.transform_entities(tr, selector)
   sel.add(inst) if selector.bounds.intersect(inst.bounds).valid? 
   view.refresh
sleep 0.2
   model.active_entities.transform_entities(tr.inverse, inst)
   view.refresh
sleep 0.2
   model.active_entities.transform_entities(tr.inverse, selector)
   view.refresh
sleep 0.2
   sel.to_a
  end
end.flatten.compact.uniq
ensure model.commit_operation
end

I’ve been changing the transformation used, I’ve tried the ent.move!, ent.transform! and model.active_entities.transform_entities(tr, ent) but the only close results I ever get have this selection…

ptr = inst.parent.transformation give a no method error and I don’t fully understand why…

I can see it’s because the instance parent is it’s definition and not it’s containing group…

but how do I get the containing group transformation?

and how could I then use move! which currently creates strange results…

john