How do you get a group's definition?
-
When you copy a group the Entity Window displays how many copies there exist of that group.
You can also find the definition in Sketchup.active_model.definitions
but, is there a way to get the definition from the Group object instead of iterating through the Sketchup.active_model.definitions and compare every definition there is? -
One way would be to create an empty group inside that group, then query the parent of the empty group.
definition = (group.entities.add_group).parent
The empty group is volatile, and will be automatically purged by any operation affecting the model geometry. It's not a nice way to do it, but it works.
Just curious - why do you need the definition?
-
hm... if I edit that group, then won't it make it unique?
I want to get all the copied entities of a group so I can make a plugin that allows you to select all of these all at once. I often find myself with old models at the office where the original creator have created lots of copies of an object as an group instead of components.
So I want to be able to quickly select copies of groups. And then I'll make a function that will allow me to convert all these copies to components.
Just wanted to check if there was an easier way to do this without looping through the instances array every time.
btw Rick, on a sidenote, I saw your Instances script, and I was surprised that SU allows you to select objects that's nested deep within groups and components. Unexpected, but potentially very useful.
-
And won't your code actually return the same as what 'group' returns?
-
group.entities.parent
is all you need to get the definition of any group
-
That's great Dale! Works perfectly.
But I would never that expected that .parent would return that. I would have expected that:
group.entities.parent === group
-
@thomthom said:
That's great Dale! Works perfectly.
But I would never that expected that .parent would return that. I would have expected that:
> group.entities.parent === group >
There are a lot of strange things about groups, and that is one of them.
Advertisement