[solved] "movin" group into another group (in ruby)
-
hi,
after hours of trying and searching i have to ask:when i have 2 different groups at level 1 in the drawing,
how can i
a. "move = insert" group 1 INTO group 2
b. insert them both into a GROUP 3
i tried everything i found , but no chance..
probably i just need a snall kick to understand the syntax, how the structure is and how elements can be transfered.
thanx
stan
-
select the group you wish to insert
control x
open the receiving group
Menu>Edit>Paste in Place
Option to explode the inserted or not your choice
Move stuff about within the group as you wish
Close receiving group
While still highlighted repeat the above steps. -
hi mitcorb,
very kind from you, but i know the solution in skp itself,
what i need is a solution in ruby, i just cannot get the group entities into another group..but thanx a lot !!!!
stan -
ooops I didn't see the request
My apologies -
I think this works:
` def self.add(g0, g1)
g0.entities.add_instance(g1.entities.parent, g1.transformation * g0.transformation.inverse)
g1.erase!
enddef self.insert(ng, g0, g1)
ng.entities.add_instance(g0.entities.parent, g0.transformation)
ng.entities.add_instance(g1.entities.parent, g1.transformation)
g0.erase!
g1.erase!
end` -
You also need to check the group level for attribute dictionaries and materials, and apply (or copy) them to the new copied instances.
-
hi,
thanx! work like a dream,
as soon as i found out, that ang - group must be created before calling the method, then it moves both groups into it.
fantastic!THANK YOU !!!!!
stanresult:
g0 = @group_floors #COMES FROM ANOTHER METHOD g1 = @facade_group #COMES FROM ANOTHER METHOD ng = model.entities.add_group self.insert(ng, g0, g1) ##*************************************************************************** def self.insert(ng, g0, g1) ##*************************************************************************** ng.entities.add_instance(g0.entities.parent, g0.transformation) ng.entities.add_instance(g1.entities.parent, g1.transformation) g0.erase! g1.erase! #ng.name = "master house group created" count = 1 entities3 = ng.entities entities3.each { |entity| if entity.is_a?(Sketchup;;Group) entity.explode if count == 1 #SO GROUPS ELEMENTS ARE AGAIN AT LEVEL 1, as needed count = count + 1 end } end
Advertisement