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: 

Relative Import is broken? Python API

Message 1 of 4
269 Views, 3 Replies

Relative Import is broken? Python API

Hey Everyone, I'm wanting to split my add-in into multiple modules for organization purposes. I've used relative imports as suggested in every single post I could find on importing modules into an addin/script, and VS Code is able to resolve the imports properly, however, when I run the add-in in Fusion it doesn't work unless all of the code I've written is in the file that was created when I created the Add-in through Fusion. I'm kind of lost here, and I hope that someone will be able to help me figure out what's going on.

I have two PATH system variables on my system for some reason, they are as follows:

%AppData%\Roaming\Autodesk\Autodesk Fusion 360\API\Python\defs

%AppData%\Roaming\Autodesk\Autodesk Fusion 360\API\AddIns


Below is a screenshot of VSCode


Message 2 of 4
in reply to: ryan27XKQ

Hi @ryan27XKQ .


It was not clear from the image alone.

I tried it here, and was able to call it.

I've attached the add-in I tested.

Message 3 of 4
in reply to: ryan27XKQ

Accidentally replied to the post and not kandennti

Message 4 of 4
in reply to: kandennti

Alright, so from what I understand after perusing your code, it looks like every single module must have a function that instantiates objects you intend to use and that the API does not allow for the instantiation of objects in your file that were imported from another file. Honestly that seems like a major limitation on how add-ins can be written and will prevent me from using many modules, packages, and libraries.

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