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: 

Now available: Fusion 360 plugin for Intellij IDEA/PyCharm

83 REPLIES 83
Reply
Message 1 of 84
JesusFreke
11908 Views, 83 Replies

Now available: Fusion 360 plugin for Intellij IDEA/PyCharm

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

83 REPLIES 83
Message 21 of 84
masounmardini
in reply to: JesusFreke

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

fusion plugin.png

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)

fusion plugin2.pngyou can notice it's using the local python environment and there is no run from fusion option 

can you help me with installing

 

Message 22 of 84
JesusFreke
in reply to: masounmardini

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.

Message 23 of 84
saccade
in reply to: JesusFreke

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?

 

Message 24 of 84
JesusFreke
in reply to: saccade

The free version should work fine

Message 25 of 84
Anonymous
in reply to: JesusFreke

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?

 

Screen Shot 2019-03-18 at 14.57.04.png

Message 26 of 84
JesusFreke
in reply to: Anonymous

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. 

Message 27 of 84
JesusFreke
in reply to: JesusFreke

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?

Message 28 of 84
Anonymous
in reply to: JesusFreke

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.

 

Screen Shot 2019-03-18 at 19.46.53.png

Message 29 of 84
JesusFreke
in reply to: JesusFreke

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.

Message 30 of 84
Anonymous
in reply to: JesusFreke

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:

 

Screen Shot 2019-03-19 at 13.03.00.png

Have also tried running the plugin in a Conda 3.5 venv but still no luck, same timeout error.

Message 31 of 84
JesusFreke
in reply to: Anonymous

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.

 

Message 32 of 84
Anonymous
in reply to: JesusFreke

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? 

 

 

Message 33 of 84
JesusFreke
in reply to: Anonymous

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:

https://github.com/JetBrains/intellij-community/blob/f59b8a1/python/helpers/pydev/pydevd_attach_to_p...

 

Since you were unable to get the debugger to attach, this script is likely where the problem lies.

 

 

 

 

 

Message 34 of 84
Anonymous
in reply to: JesusFreke

Awesome, I'll dig into over the next few days 🙂
Message 35 of 84
copypastestd
in reply to: JesusFreke

Hi!

I have successfully install Plug-In, but I have problem with Python interpreter. How to fix it?

PyCharm.PNG

 

 

Message 36 of 84
JesusFreke
in reply to: copypastestd

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.

 

 

Message 37 of 84
copypastestd
in reply to: JesusFreke

@JesusFreke 

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?

 

spyder.PNG

Message 38 of 84
JesusFreke
in reply to: copypastestd

Yes, once you create a run configuration, you can run or debug the script from the toolbar.


rundebug.jpg

 

The easiest way to create a run configuration is via the context menu.

 

createconfig.jpg

 

 

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

 

output.jpg

 

 

Message 39 of 84
copypastestd
in reply to: JesusFreke

 

I managed to run code from PyCharm.

2.PNGtest1.PNG

 

But I still couldn't received console prints:

4.PNG

 

Check my configuration setting plz:

3.PNG

 

 

 

 

 

 

Which interpeter should I use from SDK or specified?

Message 40 of 84
JesusFreke
in reply to: copypastestd

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.

Post to forums  

Autodesk Design & Make Report