[REQ] Open and close all nested groups in selection
-
From what I can gather this action is done in order to make groups unique - for that there is group.make_unique. That appears to be a more correct way to address it - you are after all looking for unique instances.
Not saying that being able to open an instance wouldn't be useful. (There is a way to close instances already, having a way to open would be a nice symmetry.)
-
That would also be handy for Revit DWG import, as it seems in this post here:
http://sketchucation.com/forums/viewtopic.php?f=11%26amp;t=61846
User and me were misguided by the fact that groups even call themselves components in that situation. I hadn't noticed that before and even if I was aware of groups behaving like components, I would never get so far as thinking the bastards would use their name too...
Another thing that is related to this, is that if you want to edit the name of a copy of an unedited group. Because of some conflict with existing component you always get a popup message saying you can't do that for components though right after that message you can after all. Very annoying and time consuming. (Now that I think of it I haven't seen that message that much lately... something fixed?)
-
Would this work?
selection=Sketchup.active_model.selection selection.grep(Sketchup;;Group) {|group| group.make_unique }
-
After the selection
grep
you need a.each
...
Sketchup.active_model.selection.grep(Sketchup::Group)**.each**{|g| g.make_unique }
or to do it to ALL groups do this ...
Sketchup.active_model.definitions.select{|d| d.group? }.each{|g| g.make_unique }
-
Thanks.
-
I use the backout plugin to exit nested groups...
-
Hmm...I tried it exactly as you wrote but it didn't work.
But, if I manually double click to open the groups and then close them and run the hide intersecting edges script it works.
Any ideas what could be missing?
I don't get any error messages in the console. -
If you use this line in the Ruby Console what is listed ?
gps = Sketchup.active_model.selection.grep(Sketchup::Group)
If it's a list of selected groups, then what happens with this ?
gps.each{|g| g.make_unique if g.entities.parent.instances[1] }
There's no need to use 'make_unique' unless there are multiple copies ?? -
That seem to work.
Again, thanks! -
I spoke to soon. It doesn't work if there are nested groups.
-
I knew I had seen a similar discussion some where. This might be what you are looking for.
http://sketchucation.com/forums/viewtopic.php?p=346107#p346107
I think there is a newer version in the plugin store.
Never mind, as written, the plugin fails with nested groups.
I think it would be an easy fix.
-
@tig said:
After the selection
grep
you need a.each
....grep takes a block which it will invoke on all matched elements. On large sets it's somewhat faster.
-
@pixero said:
As a way of automating the process from here:
http://sketchucation.com/forums/viewtopic.php?f=323%26amp;t=61842#p565790
Can someone make a script that open and close all nested groups in a selection?The code below makes a recursive traversal through nested groups. I will add an UI to the hide overlapping extension where make_unique is an option.
def self.makeUnique(ents) ents.grep(Sketchup;;Group).each { |g| g.make_unique makeUnique(g.entities) } end makeUnique(Sketchup.active_model.selection)
-
I tried your code but it didn't work with nested groups either.
-
@pixero said:
I tried your code but it didn't work with nested groups either.
I think there are two issues here.
-
HideOverlappingGeometry does not compare groups within a common top group. So in your example, the 4 boxes within a group will not be compared with each other, they will however be compared to the 4 boxes in the other group. That's just a choice I made in the extension that reflects the way I use the script. If you want to hide the seams between the groups within a group you have to enter the group and select all groups within and then run the script. I think I will add an option to the extension so that is also compares stuff within the same nesting.
-
I don't quite see why the provided code doesn't work in your example. I tried with a similar example and the groups all became unique. Do you have a sample model?
-
-
Here is a simple example file.
A real life model would probably have more nested levels. -
@pixero said:
Here is a simple example file.
A real life model would probably have more nested levels.I get the result below (and the nested groups also becomes unique):
-
Ok, so then it's a matter of you implementing the compare overlapping edges in nested groups?
Advertisement