Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

help for simple motion scripts

alessandro.ds
Explorer

help for simple motion scripts

alessandro.ds
Explorer
Explorer

Hi guys
I am new to the world of programming and I would like to know if it is possible to ask from a script on fusion 360 another program (always written with python) that takes data from the serial, and then use those parameters to warp or move the view or both at the same time.
I would like to query an external app because from the second app I am going to create the adjustments and settings for the movements.
I really hope someone can answer me.
I have seen on the documentation but I have not found anywhere how to do it much less how to interact on that function, or I probably did not understand how to do it since I started programming with python a few days ago and all the documentation is in English and I have to use google translate to understand something.

Greetings
Alexander

0 Likes
Reply
541 Views
7 Replies
Replies (7)

kandennti
Mentor
Mentor

Hi @alessandro.ds .

 

I don't understand English either, so the language may be strange to you.

 

I took it to mean "I want to run an external program from the Fusion360 API and receive the results to run Fusion360."

The import function of this add-in that I created earlier does that.

https://github.com/kantoku-code/Fusion360_Curve3D_Doorway 

 

The main process goes something like this.
・In the Fusion360API (python), specify the import file in the file open dialog.
・Execute the external program with subprocess.check_output.

https://github.com/kantoku-code/Fusion360_Curve3D_Doorway/blob/main/Curve3DDoorway/commands/Import3D... 

・The external program outputs the necessary information to the standard output.
・Receive the standard output in python and process the Fusion360API based on the information.

 

In the case of my add-in, I ran the script (ruby) in a 3DCAD program called "siren" which does not have a screen, and output the results to the standard output.
subprocess.check_output was able to receive the standard output directly, so there was no need to write the results to another file. This was very convenient.

https://docs.python.org/3.7/library/subprocess.html 

1 Like

alessandro.ds
Explorer
Explorer

hello thanks for the reply. I didn't understand much of the program you wrote but I'll explain in more detail what I want to do.
in practice I am making a kind of spacemouse, which will have a simple little program made with python and its graphical interface from which to set the sensitivity of the command and / or any buttons.
what i need and understand how i do in the python script on fusion to tell it to execute the orbit command following the values that the external program reads.

0 Likes

kandennti
Mentor
Mentor

@alessandro.ds .

 

The screen is manipulated by using the Viewport.camera property.

https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-2005e69c-36cd-45a2-bb3d-8cf5b968ab9a 

 

Note that the camera object must be copied, the values changed, and then assigned to the Viewport.camera property again.

 

You may find the sample created here helpful.

https://forums.autodesk.com/t5/fusion-360-api-and-scripts/camera-movements-amp-matrix3d/m-p/10749746... 

0 Likes

alessandro.ds
Explorer
Explorer

thanks for the answer tomorrow surely I will start studying these parts and let's see what I can come up with.
another thing i need is to know if the python scrypt that runs in fusion 360 can communicate with an external program.
this is because I made a little program in python that allows me to set the sensitivity of the hardware. it would therefore be great to be able to communicate them so that I receive the movement data directly from the small program otherwise I would have to communicate the script with the serial and it would really be an excessive load

0 Likes

BrianEkins
Mentor
Mentor

There is nothing in the API that supports communication with outside processes. However, I know some people that have experimented with different techniques to support this.  The most common approach is to use sockets.

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

alessandro.ds
Explorer
Explorer

hello thanks again for the answer but apparently I can't understand how the structure of the api works.
I looked in the documentation but it is really very complex.
to upload information you have to go to a thousand pages. I'm probably unable to understand this type of scrypt.
consider that I still can't understand how to change the retention axis in the example you explained.
I hope you have a little more detailed explanation of the various parts of the example and how they behave.

0 Likes

kandennti
Mentor
Mentor

@alessandro.ds .

 

The two things that determine the orientation of the screen are the vector from the eye property to the target property and the upVector.

1.png

 

Zooming and other scaling is determined by the viewExtents value.

2.png

 

However, I don't know what kind of signals come in from the mouse.

 

Perhaps this topic will help you.

https://forums.autodesk.com/t5/fusion-360-api-and-scripts/3d-mouse-now-works-in-2d-drawings/m-p/9407... 

1 Like