We are having some problems getting the transformation correct when adding a child group to a parent group when that parent group is active. If the parent group isn't active then it works fine.
Has anyone else had this problem. Details and technique to duplicate are below.
Our workflow is that the user adds child groups to a parent group while the parent is open. The script below shows my problem, you have to enter it line by line in the ruby console because there are steps (Steps A and B) where you have to click around to change the current active group. I have tried calling make unique on both groups to no avail and canāt even do a work around of setting the childās transformation to the parentās inverse transformation because when I try to get the parentās transformation it comes back as identity. I would really appreciate any help in finding a work around for this, I donāt want to have to go to components instead of groups unless I really have to.
Script is below:
# clear everything out
Sketchup.active_model.entities.clear!
# add the parent group
group1 = Sketchup.active_model.entities.add_group
# didnāt work
# group1.make_unique
# set parentās transformation
group1.transformation = Geom;;Transformation.translation(Geom;;Point3d.new(10.m, 0, 0))
# add some points to the parent group
group1.entities.add_cpoint(Geom;;Point3d.new(0.m, 0.m, 0.m))
group1.entities.add_cpoint(Geom;;Point3d.new(5.m, 5.m, 3.m))
# the parent groupās transformation shows the correct translation
puts group1.transformation.to_a.join(', ')
# step A) double click group1 to open it
# parentās transformation now shows as identity?
puts group1.transformation.to_a.join(', ')
# add the child group
group2 = group1.entities.add_group
# didnāt work
# group2.make_unique
# we want the child groupās axes to be the same as the parent groupās axes, unfortunately this seems to put it at the absolute origin
group2.transformation = Geom;;Transformation.new
# add some points to the child group
group2.entities.add_cpoint(Geom;;Point3d.new(0.m, 0.m, 1.m))
group2.entities.add_cpoint(Geom;;Point3d.new(5.m, 5.m, 4.m))
# step B) exit out of all groups to top level model
# the parent groupās transformation is correct
puts group1.transformation.to_a.join(', ')
# the child group has a negative translation to bring it back to the origin? Why?
puts group2.transformation.to_a.join(', ')
# this will put group2 where it is supposed to be
group2.transformation = Geom;;Transformation.new
# group transformations are now correct
puts group1.transformation.to_a.join(', ')
puts group2.transformation.to_a.join(', ')