When I group some elements for instance a Face and 4 edges, I have some entityID for the elements inside.
My problem is when I copy this group , the entities inside the new group have the same entityID.
I have found a solution with the GUI if I enter the group, then entityID are changed/updated.
But I’m looking for a pure Ruby solution as I want to make my script fully work by its self.
The persistent_id and the inspect are updated too.
Check this example :
ss = Sketchup.active_model.selection
#select group 1
puts ss[0].entities[0].entityID, ss[0].entities[0].persistent_id , ss[0].entities[0]
#22610
#162
#<Sketchup::Edge:0x000183da664d38>
#make a copy of group 1 and select it
puts ss[0].entities[0].entityID, ss[0].entities[0].persistent_id , ss[0].entities[0]
#22610
#162
#<Sketchup::Edge:0x000183da664d38>
I use Sketchup make 2017
Is it a bug or is it the way it suppose to work?
Do you a solution for me ?
Just a quick tip before I go to bed:
Try to use:
The Group #make_unique method…
“Copying a group in SketchUp will create a group that shares the same definition. SketchUp implicitly makes group unique when edited from the GUI, and from a user point of view groups could be thought of as always being unique. To honor this behavior, call this method before editing a group through the API.”
.
Yea! The groups are a kind of special component in SU.
Among other similar/same methods, it is the most “revealing”: The Group #definition method is used to retrieve the component definition for this group.
(Returns : (Sketchup::ComponentDefinition) )
( Edit
After making it unique, beside the above mentioned id’s even its definition get its own unique definition name: Group#1 , Group#2…etc)
SketchUp for Schools (web) doesn’t have ability to use Ruby.
To make the groups unique you need to go into to its editing context and then
you can close it without really editing.
If you are using desktop version of Sketchup then there are several different ways to do it by Ruby.
def make_all_groups_unique( model = Sketchup.active_model )
g_defs = model.definitions.find_all(&:group?)
model.start_operation("Make all groups unique", true)
g_defs.flat_map(&:instances).each(&:make_unique)
model.commit_operation
end
make_all_groups_unique