I've put together a little plugin for IDEA to add support for developing Fusion 360 python scripts. It allows you to launch and debug fusion scripts in IDEA, similarly to the bundled Spyder IDE.
You can find the plugin at https://github.com/JesusFreke/fusionIdea. It should be available in IDEA's built-in plugin repository soon, it's just pending approval.
You'll also need to install a small add-in in fusion 360, to help facilitate launching scripts from within IDEA. You can find more info in the README
Hi Jesus,
First of all very nice Plug in, because I really like PyCharm and i don't feel comfortable with spyder yet.
I've just download the plug in PyChram 2018.3.1 x64 and the installation was fine then enabled the plug-in from langauges& Frameworks making sure the path is correct
Then after writing a small script the autocomplete is working fine but if i try to run nothing happens
Btw: the fusion helper addin in fusion is running (tried both cases)
you can notice it's using the local python environment and there is no run from fusion option
can you help me with installing
The "Run in Fusion" thing only shows up if it plugin detects that the script is actually a fusion script. The entry point of a fusion script is the "run" function, which your example script is missing.
In particular, the plugin checks that the script imports either adsk.core or adsk.fusion (which yours is), and has a top-level method named "run".
The simplest solution is of course to add a run method:
def run(context):
if ui:
ui.messageBox("Masoun", 0, 0)
However, if you do want to run a script that the plugin doesn't detect as a valid fusion 360 script, you can manually create a "Fusion 360" run configuration, and run it that way.
This looks like an interesting alternative to Spyder. Does this work with the free "community" edition of PyCharm, or do you need the commercial version?
Currently trying to get this plugin to work but I'm having an issue with the Python debugger timing out and failing to connect, any idea of how I can fix this?
I'm not sure what might cause that. The only thing that comes to mind is an overzealous firewall or something. The connection should be with local ports though, so I would be a little surprised if a firewall would be blocking that.
I just updated to the lastest version of Fusion and tried the plugin, just to make sure there wasn't something in the new version that broke things. It worked fine for me.
Also, just to double-check, you're using the latest version of the plugin? 0.5.5?
And which version of pycharm?
I've run plenty of online stuff through PyCharm before so I doubt its a firewall issue, uninstalled and re-installed the plugin just to make sure it's definitely 0.5.5 and I'm still getting the same issue.
Running PyCharm version 2018.3.4, Python version 3.7 for the venv.
I just tried it with 2018.3.5 and it's working fine for me.
Can you try adding a "system interpreter" python interpreter that points to the python executable bundled with fusion, and configure your project to use that? You can find the base path in the "Fusion 360 executable" setting for the plugin. e.g. if the executable is something like:
C:\Users\username\AppData\Local\Autodesk\webdeploy\production\2f45a4db7599ac84a25965c44abecc74156a5bcd\Fusion360.exe
then the python executable would be at
C:\Users\username\AppData\Local\Autodesk\webdeploy\production\2f45a4db7599ac84a25965c44abecc74156a5bcd\Python\python.exe
Fusion uses python 3.5, so maybe there's some issue with 3.7 interpreter you're using.
Should have mentioned that I'm on MacOS, tried to add Fusion's python executable as a system interpreter (from both the most recent webdeploy folder and the shared python executable) but I'm running into this error:
Have also tried running the plugin in a Conda 3.5 venv but still no luck, same timeout error.
Oh, yes. I think I mentioned in a few places the plugin is windows only currently :). I'm actually a bit surprised it was seeming to work even as well as it did. I assume you had to manually set the path to the fusion 360 executable? I can't imagine there's any way it would have autodetected it. The paths, etc. it uses for autodetection are all pretty windows specific.
I don't think it should be much work to get it working on a mac, but I don't have a mac, and honestly don't have much interest myself in trying to add support for it. But I'd be happy to give some pointer and answer any questions, if you want to try adding support.
Oops, my bad for not reading carefully there - yeah I've just been manually re-directing to the Fusion 360 executable. I do have a pc but it's not my daily driver so I'll have to try running it on that tonight.
Just had a more in-depth look into the git repository and I'd definitely be interested in having a go of adding Mac support/some sort of workaround when I've got some free time, any idea of the best places to start?
There are 2 main things that would probably need to be addressed. First, there is at least 1 place, and potentially more that assumes window style paths. This would need to be fixed to get autodetection of the fusion 360 executable working properly. See, e.g. https://github.com/JesusFreke/fusionIdea/blob/master/src/main/java/org/jf/fusionIdea/facet/FusionFac... There may be other path related tweaks/fixes that need to be made elsewhere as well.
The other thing is that there is some platform-specific code in the python shim that initiates the debug connection.
See e.g. https://github.com/JesusFreke/fusionIdea/blob/8f786e4/src/main/python/inject.py#L91 and https://github.com/JesusFreke/fusionIdea/blob/8f786e4/src/main/python/inject.py#L132
This script was derived from a script in IDEA's python implementation. I tried to maintain the mac branch in the code, but I have no way of running it or otherwise verifying that it is correct or works.
Here is the original script that it is based on:
Since you were unable to get the debugger to attach, this script is likely where the problem lies.
Hi!
I have successfully install Plug-In, but I have problem with Python interpreter. How to fix it?
You can click on the "configure python interpreter" link, and create a new "system interpreter", that points to the python distribution bundled with fusion. You can find it at C:\Users\<yourusername>\AppData\Local\Autodesk\webdeploy\production\<guid>\Python\python.exe
There will likely be many directories in C:\Users\username\AppData\Local\Autodesk\webdeploy\production\2f45a4db7599ac84a25965c44abecc74156a5bcd\Python\python.exe, but likely only one with the Python subdirectory.
Thanks to you, I managed to set up interpreter.
Tell me plz, is it possible to run programm via PyCharm by pressing green "play button" like in Spyder, when it automatically starts in Fusion.
And another question about python console, how to set up in in PyCharm for message reciaving like in Spyder?
Yes, once you create a run configuration, you can run or debug the script from the toolbar.
The easiest way to create a run configuration is via the context menu.
There's currently no way to capture the output when you "run" the script, but it does appear in the console when you debug the script.
Because of this, 99% I use "debug" instead of "run".
I managed to run code from PyCharm.
But I still couldn't received console prints:
Check my configuration setting plz:
Which interpeter should I use from SDK or specified?
I don't know why the console output wouldn't be showing. Have you tried restarting fusion? Also, did you try to open spyder or anything?
Can't find what you're looking for? Ask the community or share your knowledge.