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: 

Changing dimensions of a model from POST requests

6 REPLIES 6
SOLVED
Reply
Message 1 of 7
mhasan3
439 Views, 6 Replies

Changing dimensions of a model from POST requests

I am trying to make an application via Fusion 360 API scripting wherein a continuously running app would get POST requests from clients and by parsing parameters from that POST request, the app will, lets say, change the dimension of a model in the current document. My question is:

Is this possible?

I was wondering of, lets say, starting a Flask server from within the Fusion 360 script, spawned from a separate thread and that Flask server would handle the POST request. Any parameters sent via the request would then be transferred to the main thread controlling the UI by firing custom events.

Are there any better ways of doing this (if at all possible)?

6 REPLIES 6
Message 2 of 7
BrianEkins
in reply to: mhasan3

There's not anything in the API that was specifically designed to support something like this but there are a couple of things that you still might be able to use.  One of them is the custom event functionality which is intended to you let you run something (that's not calling the Fusion API) and then let it call back into the Fusion main thread via a custom event.  Then your add-in handling the event can use the API to do whatever it wants.

 

Another option is to have a process running outside of Fusion that calls into Fusion using the Fusion 360 protocol handler.  It's documented in the API help.  Your add-in can be watching for when the protocol handler is invoked and do whatever it wants in response.

 

The main difference between these two approaches is where your program is that's receiving the POST request; running within the Fusion 360 process or running as its own process.  There's much more flexibility by having it as a separate process and I would expect you'll run into fewer problems.  In the second case, there's also the option of Fusion 360 being started if it isn't already running.

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

Thanks for the suggestions. I did actually give it a try by running a Flask server in a separate thread using custom event handlers in the main thread and it works fine.

 

Talking about the other option, is there any way to programmatically invoking the fusion 360 protocol handler from , lets say, a script, as opposed to from a web based protocol handler ( as shown in the documentation)? Is there something in the documentation I am missing? Can it be done in Python? What libraries do you suggest?

Message 4 of 7
BrianEkins
in reply to: mhasan3

I did a couple of quick tests to call the protocol handler from something other than a browser (curl and Python requests) and didn't have any success.  I'm certainly not an expert in this area so it could very well be something simple I'm missing but I also had a hard time finding anything when searching.  I would assume it's possible but I'm not much help.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 5 of 7
jade.fink
in reply to: BrianEkins

Close but no cigar, it appears that the protocol handlers are an OS-specific thing which is reasonably well documented at https://docs.microsoft.com/en-us/windows/uwp/launch-resume/launch-default-app for the UWP at least. I don't know how this works outside Windows 10 and UWP.

Message 6 of 7
mhasan3
in reply to: BrianEkins

since the file link is not a usual http endpoint, thats why curl and requests also didnt work for me. I tried with Python webbrowser module in a quick test and it does work and successfully initiates Fusion360 with the model loaded.

 

You had previously mentioned that, another option is to have a process running outside of Fusion that calls into Fusion using the Fusion 360 protocol handler. my add-in could be watching for when the protocol handler is invoked and do whatever it wants in response.

 

Now, how could I actually make a communication between this process running externally outside of Fusion, which initiates Fusion using the protocol handler, and the addin inside of Fusion that I could make to run on startup. Are there any events as such inside the Fusion process that are fired when the protocol handler is called? How could I actually establish a communication between the two running scripts (protocol handler and fusion addin)?

 

Any help would be appreciated

Message 7 of 7
BrianEkins
in reply to: mhasan3

Take a look at the user manual topic on this and particularly the sections on privateInfo and Events towards the end of the topic. 

---------------------------------------------------------------
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