How to locate specific group# in model? [Solution Provided]
-
It might be very simple but I don't know how to find a specific group in my model, I have problems cutting group #94 as it freezes but I don't know which group it is, is it possible to locate the #94 in some clever way?
-
It's a shame you weren't using components. You wouldn't have this problem.
Perhaps one of the Ruby gurus would have a way to determine the group by its number via a bit of code in the Console but it doesn't appear there's any way to identify it from the Outliner or Entity Info.
-
You can of course manually give your 'unnamed' Groups individual names using 'Entity Info', but the Groups' definitions' names always stay as 'Group#1', 'Group#2' etc.
If Groups don't have names this "one-liner" will change their names to match their definition-name - then you can use the Outliner to select 'by name'.m=Sketchup.active_model;m.start_operation("ReN");m.definitions.each{|d|next unless d.group?;d.instances.each{|g|g.name=d.instances[0].definition.name if g.name.empty?}};m.commit_operation
Copy/Paste all of the code + <enter> into the Ruby Console and then use the Outliner to see/highlight the Group[s] by name.
It is one-step undo-able in case you mess up...
IF you want EVERY Group to be renamed [perhaps dangerous?] then remove the text 'if g.name.empty?
' from the one-liner, and then all Groups get named after their definition-name - 'Group#1', 'Group#2' etc overwriting any earlier names you might have added manually using 'Entity Info'...
-
You can select the Group in the Outliner window. On Windows, you can limit the visible entities by entering text in the Outliner's filter box.
-
The problem is that unnamed Group all display as 'Group' in the Outliner, so if you get an error referring to a specific Group definition name you have no way of finding it... My snippet changes unnamed Groups names to match their definition so you can then find them in the Outliner because then name==defn.name...
-
When I used this code-
m=Sketchup.active_model;m.start_operation("ReN");m.definitions.each{|d|next unless d.group?;d.instances.each{|g|g.name=d.instances[0].definition.name if g.name.empty?}};m.commit_operation
I got this error-
Error: #<NoMethodError: undefined method `definition' for #Sketchup::Group:0x834ce04>removing the .definition removed the error but did not result in the naming of the groups.
removing the .instances[0] seemed to work as expected. The final code string was
m=Sketchup.active_model;m.start_operation("ReN");m.definitions.each{|d|next unless d.group?;d.instances.each{|g|g.name=d.name if g.name.empty?}};m.commit_operation
As an alternative, selecting the offending group will make it easier to find.
m=Sketchup.active_model;s=m.selection;m.start_operation("sel grp");s.clear;m.definitions.each{|d| next unless d.group?;if d.name == "Group#94";d.entities.each{|e| s.add e};end;};m.commit_operation
-
Thank you very much TIG, I'll test it soon
-
d.instances[0].definition.name
This line makes little sense. The definition uses an instance of itself to get its definition...It's equal to
d.name
. Andd.name
will avoid the error becauseGroup
doesn't have.definition
.
Advertisement