• Login
sketchucation logo sketchucation
  • Login
🤑 SketchPlus 1.3 | 44 Tools for $15 until June 20th Buy Now

Clearing the model.selection programmatically

Scheduled Pinned Locked Moved Developers' Forum
3 Posts 2 Posters 9.3k Views
Loading More Posts
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    sjn001tvh
    last edited by 11 Nov 2018, 00:15

    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

    1. select from screen the child group
    2. retrieve the parent's group ID
    3. using Ruby Console issue: model.selection.clear
    4. objParent.transformation.to_a

    Second test

    1. Select from the screen the parent group
    2. Verify that the object ID is the same for the both tests
    3. 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.

    1 Reply Last reply Reply Quote 0
    • S Offline
      sjn001tvh
      last edited by 11 Nov 2018, 03:54

      Found it! objModel.close_active will the clear the selection set

      Sorry to disturb.

      Scott.

      1 Reply Last reply Reply Quote 0
      • S Offline
        slbaumgartner
        last edited by 30 Dec 2018, 16:12

        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.

        1 Reply Last reply Reply Quote 0
        • 1 / 1
        • First post
          Last post
        Buy SketchPlus
        Buy SUbD
        Buy WrapR
        Buy eBook
        Buy Modelur
        Buy Vertex Tools
        Buy SketchCuisine
        Buy FormFonts

        Advertisement