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.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Can anyone think of an elegant way to pop open the file dialogue?

Message 1 of 3
527 Views, 2 Replies

Can anyone think of an elegant way to pop open the file dialogue?

I'm giving users an interface to read or write data, but I need them to make decisions as well as give me a new/existing file to write/read - I can't just throw them directly into createFileDialog().


One idea I had, was to detect them clicking on something (e.g. "Select File") in with their options, which grabs the name of the file, then when they click "OK", it performs the complex actions based on their input with the file they gave:-


Screen Shot 2020-09-25 at 9.29.38 pm.png


However, I can't find any way to detect them clicking on anything that looks nice.  I've tried ImageCommandInput and TextBoxCommandInput (with an <img> tag) and TextBoxCommandInput that contains an HTML form - but while they all look pretty, they do nothing (I can't detect any events firing).  Ideally, does anyone know how to use JavaScript or <forms> inside TextBoxCommandInput to "talk" to my add-in?


Logically, I *could* wait for the "OK" and *then* ask the file, but that's going to confuse them to no-end (who clicks "OK" to import from a file, without selecting a file first? counter-intuitive!).  I could ask for the file first, but that too will confuse because the flow doesn't make sense before the other decisions they need to make.  I could use some other control, like a ButtonRowCommandInput - except that's a 16x16 pixel icon, which - while working - will basically look stupid...


Any ideas anyone?

Labels (2)
Message 2 of 3
in reply to: OceanHydroAU

I would use a BoolValueCommandInput.  This shows up in the dialog as a button.  This is what the various import commands in Fusion use, like the "Insert DXF" command.  They use a folder icon for the button.  You can react when the button is clicked and display a file dialog to get the filename and then save that filename in a global variable.  When the OK button is clicked you can do something with the filename in the execute event.  I've attached a simple add-in that demonstrates this.

Brian Ekins
Inventor and Fusion 360 API Expert
Message 3 of 3
in reply to: BrianEkins

@Brilliant pointer - thanks Brian.  I did basically that same thing, but I prefer the icon and wording that Fusion360 is using for this same issue (thanks for pointing me at DXF!) so I'm going to change my UI to match those.

Screen Shot 2020-09-26 at 12.44.55 pm.png


Screen Shot 2020-09-26 at 12.44.12 pm.png

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