Sorry to ask you this simple task but I cannot find answer in internet.
What is different between “group.entities” and "group.definition.entities?
Thank you in advance,
model or a
definition will have
model can also use
.active_entities useful in case the user is inside and edit.
.entities and a
components [as listed in the components-browser], and also includes
groups [which are not listed there] - and also the special type
Placed component-instances do not have entities, but the
instance.definition.entities gets it.
group.entities is simply a shortcut to
To see this select a group, use
group=Sketchup.active_model.selection in the Ruby Console.
The output should be the same !
Just some notes on top of TIG explanation:
Check here the description of
…and try this:
Create two edges!
Make a group of it!
Copy the group with the move tool!
Select both groups!
group0=Sketchup.active_model.selection group1=Sketchup.active_model.selection p group0.entities.to_a p group0.definition.entities.to_a p group1.entities.to_a p group1.definition.entities.to_a p
You will see four same array.
Now double click one of the group to edit, then close (go out from editing) without changes.
Select both groups!
Run the code above again.
You will see some changes…
group.entities is a wrapper method that calls
Backstory: In the past the powers that be wished to hide the fact that groups are really just component instances with “special” behaviors. So they did not give direct API access to the group’s definition via a
#definition getter method.
They instead expected coders to only need to access the group definition’s entities collection so they exposed that via
group#entities from the beginning of the API.
But API coders still needed to get to the group’s definition object and had to use workaround search methods that were susceptible to an API bug, so they finally added the
group#definition getter method in SketchUp 2015.
As you know your codes are so interesting for me. Unfortunately your codes dose not work for me. Also I run following codes. Not important how many groups are in model answer always is “0”.
sel = Sketchup.active_model.selection p sel.size
You must manually select the groups. You know, click on it or use window selection…
(Or use the
.add method )
I don’t think… (…if you understood or even executed properly the steps above)