Grouping and ungrouping
-
Hi There, i wonder..... when you make an group with ruby in sketchup.... you can explode
that group.... but is it possible to make the same group egain...???
can anyone help me...?see the following simple exaample
#create a group and add a line into the group
model = Sketchup.active_model # Open model
entities = model.entities # All entities in model
selection = model.selection # Current selection
group = entities.add_group #make emplty group#create a line in group
line = group.entities.add_line [0,0,0], [100,50,20]#explode group
group.explode -
That would probably require some method of recording what was previously selected. I'm not a developer, so I can't help you on the coding, but I recall a plugin / extension called "selection memory" (by Thom-Thom) that does more-or-less what may be required, in part at least. Maybe also take a look at "selection manager" for reference.
-
Use
model.active_entities
, working inmodel.entities
IF it's not the current context will BugSplat.You can get references to the objects which result from the explode operation [any previous reference to that line etc will get lost as it explodes]
exps = group.explode
Gives you an array - in your case it'll probably be an array containing one line...You could then remake a group in the active_entities with
group2 = entities.add_group(exps)
or perhapsexps.grep(Sketchup::Edge)[0]
If you want to replicate the group then after the first group is made you simply add a copy of it, then explode the original, so that the edge is now in the copied group, and it is replicated back in the active_entities...
group.entities.add_line(...) group2 = entities.add_instance(group.definition, group.transformation)
Now explode the original 'group' back to the edge in the active_entities...
The second copy 'group2' remains, it contains the replicated edge...
Advertisement