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: 

How to do the window selection?

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
john4TMYX
152 Views, 5 Replies

How to do the window selection?

 

Hi guys,

I use Visual Studio 2022 C++ to develop a plugin for Fusion 360. I have a group of surfaces,  I need to select all the surfaces so my plugin can handle them. Does anyone know how to make a window selection? I can select any individual surface, but not all the surfaces in one selection. 

 

Thank you.

Regards

John

5 REPLIES 5
Message 2 of 6
BrianEkins
in reply to: john4TMYX

I did a quick test by modifying the sample delivered with Fusion called "CommandSample". In the entry.py file in the commands/Selections folder, I edited the last few lines of the command_created function to the following:

    # Create a selection input, apply filters and set the selection limits
    selection_input = inputs.addSelectionInput('selection_input', 'Surfaces', 'Select Surfaces')
    selection_input.addSelectionFilter('SurfaceBodies')
    selection_input.setSelectionLimits(1, 0)

I can now use a window to select multiple surfaces. There are two things here. First, is setting the filter to allow the selection of open bodies, and the second is setting the selection limits to not limit how many items can be selected. The argument value of 1 indicates that at least one surface must be selected. I would guess it will still work if this is zero too. The second argument of 0 is the most important, and it indicates there is no limit to the number of surfaces that can be selected.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 3 of 6
john4TMYX
in reply to: john4TMYX

Hi Brian Ekins,

Thank you for your reply. Could you please tell me how to read all the selected entities?

 

Regards

John

 

Message 4 of 6
BrianEkins
in reply to: john4TMYX

The SelectionCommandInput object has a selectionCount property that tells you how many items were selected and a selection method where you provide an index and it returns a selection. Using the selection method and going from 0 to selectionCount-1 will return all the selections. 

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 5 of 6
john4TMYX
in reply to: john4TMYX

I use c++. The entry code I use is "class MyCommandCreatedHandler : public CommandCreatedEventHandler", it is the sample codes from the web page. The codes that catch the selection event is from "MyUnSelectHandler : public SelectionEventHandler", I don't see any where I could access the SelectionCommandInput. Maybe I am wrong, but the SelectionCommandInput is the ui codes that I use to build the dialog. After I have the dialog, then I should be able to use SelectionEventArgs to read the current selections. But no where I could see any codes that I can use to read the selected entities.

Message 6 of 6
BrianEkins
in reply to: john4TMYX

You're correct that the SelectionCommandInput is what you create to have the ability to select available in the command dialog. The SelectionCommandInput remains available for the lifetime of the command. You can save it in a global, or get it from the list of inputs associated with the command, or there are some other cases where it's provided through a property. When the select event is fired, it provides a SselectoinEventArgs object. This object supports the activeInput property, which returns the SelectionCommandInput object the user used for the selection. This is important because a command can have more than one SelectionCommandInput. From this, you can use the selectionCount and selection functions I mentioned before.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com

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