Clearing selections

Clearing selections

brad.bylls
Collaborator Collaborator
333 Views
2 Replies
Message 1 of 3

Clearing selections

brad.bylls
Collaborator
Collaborator

I would like to clear any & all selections the user may have selected before a script starts.

Brad Bylls
0 Likes
Accepted solutions (1)
334 Views
2 Replies
Replies (2)
Message 2 of 3

kandennti
Mentor
Mentor
Accepted solution

Hi @brad.bylls -San.

 

Try this.

# Fusion360API Python script

import traceback
import adsk.core as core

def run(context):
    ui: core.UserInterface = None
    try:
        app: core.Application = core.Application.get()
        ui = app.userInterface

        sels: core.Selections = ui.activeSelections
        ui.messageBox(f"Select Count {sels.count}")

        sels.clear()
        ui.messageBox(f"Select Count {sels.count}")

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
0 Likes
Message 3 of 3

brad.bylls
Collaborator
Collaborator

Thanks @kandennti 

sels: core.Selections = ui.activeSelections
sels.clear()

This worked at the start of the Create function

Brad Bylls
0 Likes