Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

ui.selectEntity not showing and crashing code

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
Jellej
356 Views, 2 Replies

ui.selectEntity not showing and crashing code

I have this simple script that fails at the "ui.selectEntity" line:

 

import adsk.core, adsk.fusion, adsk.cam, traceback

# Function to test the calculateTightBoundingBox function.
def run(context):
    ui = None 
    try:
        app = adsk.core.Application.get()
        ui = app.userInterface
        
        selectedItem1 = ui.selectEntity("Select the rectangle", "SketchCurves")
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

When debugging, the core.py is opened and it shows that the code fails at "return _core.UserInterface_selectEntity(self, *args)" in the definition:

 

    def selectEntity(self, *args) -> "adsk::core::Ptr< adsk::core::Selection >" :
        """
        Supports the selection of a single entity. This provides a simple way to prompt
        the user for a selection in a script. If you need more control over the selection a command
        should be created and a SelectionCommandInput used. 
        prompt : The prompt displayed to the user during the selection. 
        filter : A string defining the types of entities valid for selection. The valid list of selection filters can be found here: <a href='SelectionFilters_UM.htm'>Selection Filters</a>. 
        You can combine multiple types by using a comma delimiter. For example,
        the string 'PlanarFaces,ConstructionPlanes' will allow the selection of either a planar face or a construction plane. 
        Returns a Selection object that provides access the selected entity through it's 'entity'
        property along with the location in space where the entity was selected. Returns null if the selection was aborted.
        """
        return _core.UserInterface_selectEntity(self, *args)

The code is ought to show a selection box, but in fact, nothing is showed and the code is simply crashing.

 

I'm completely stuck here. Could someone please help me out?

 

Thanks!

2 REPLIES 2
Message 2 of 3
kandennti
in reply to: Jellej

Hi Jellej.

 

"ui.selectEntity" is does not show a selection box.
A tooltip is displayed when the mouse stops moving.

1.png

 

 

Message 3 of 3
Jellej
in reply to: kandennti

Me so stupid...

 

Thank you so much!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report