Clearing the model.selection programmatically
-
In the Outliner, I have 2 object groups. One as the parent, and the other as a child to that parent.
When I select the child group from the screen using the cursor, 1) the parent block in the outliner becomes hollow, 2) the small box for the child group becomes solid, 3) and the bounding box is displayed on the screen for both objects.
Now, using Ruby, I issue the model.selection.clear.
Result of action...
the small box for the child group remains solid.
the small box for the parent group remains hollow.
the bounding box remains on the screen.Next test, I select the parent group from the screen using the cursor, 1) both small boxes in the outliner go solid, 2) and a bounding box is not displayed on the screen, but the area for the group is highlighted.
Using Ruby, I issue the model.selection.clear.
Result of action..
The outliner is clears all highlighted objects and the screen doesn't show any highlighted objects.
Question: Why does the model.selection.clear work differently for nested objects?
Here's the challenge I'm facing. I need to access the parent's object transformation zPt. I have developed a method that retrieves the objectID for the parent for the selected child group.
Using objParent.transformaton.to_a I'm able to gather the positioning information of the parent. However, this is not working if the bounding box for the selection remains on the screen.
The objParent is the same when I retrieve it with Ruby or select it manually from console. But the transformation.to_a returns different information when the bounding box remains on the screen even after I have cleared the selection.
Steps to reproduce results:
First test
- select from screen the child group
- retrieve the parent's group ID
- using Ruby Console issue: model.selection.clear
- objParent.transformation.to_a
Second test
- Select from the screen the parent group
- Verify that the object ID is the same for the both tests
- objGroup.transformation.to_a
The data in the transformation array is not the same. The only difference between these steps is that the bounding box remained on the screen and I can't seem to find a method to programmatically clear it.
Is there a solution?
Thanks,
Scott.
-
Found it! objModel.close_active will the clear the selection set
Sorry to disturb.
Scott.
-
Actually, #close_active exits the current edit context, aka active_entities, (belonging to a group or component) and returns to its parent (an enclosing group, component, or the model). Since the selection can contain entities from only one context at a time, all of the currently selected entities have to be in the active context and have to be cleared when you close it.
Advertisement