I would love to be able to use Microsoft Code as Editor, instead of Spider2. Would it be possible to know what are the different environment settings needed?
I see there is a possibility to use another editor, doing some modifications to the .manifest file, for C++. Any way to do the same for Python?
Any help would be great.
Thanks,
Bernard
Solved! Go to Solution.
Solved by marshaltu. Go to Solution.
Hello,
Unfortunately there is no easy way to switch to another python IDE yet. Theoretically you can use other python ide (e.g. vscode) by some manual setting. I just give a try to debug python scripts with vscode according to the steps described in https://code.visualstudio.com/docs/python/debugging. It works. Please refer to following screencast. Some other manual settings will be also needed to enable code hint.
Thanks,
Marshal
Thank you for this, great help!
When I type "import sys" in the console, with Python selected, I don't get anything to display as in your screen cast. What Am I missing?
Hello,
No message means it works well. Please make sure the option in right-bottom corner is "Py" in text command window.
The codes I executed in Fusion 360 are to import "ptvsd" so that VSCode can remote debug with Fusion 360(as Python interpreter). The path appended to system path is to let Python know where it can load "ptvsd". Please note the path will be different in your machine.
import sys sys.path.append("C:\\Users\\tum\\.vscode\\extensions\\ms-python.python-2018.1.0\\pythonFiles\\PythonTools") import ptvsd ptvsd.enable_attach("my_secret", address = ('0.0.0.0', 3000))
Meanwhile you have to install Python debug tool and have same settings in launch.json in VSCode project.
"version": "0.2.0", "configurations": [ { "name": "Attach (Remote Debug)", "type": "python", "request": "attach", "localRoot": "${workspaceFolder}", "remoteRoot": "${workspaceFolder}", "port": 3000, "secret": "my_secret", "host": "localhost" } ]
Thanks,
Marshal
I am back trying to use VS Code.
I followed your advice, and screen cast, but I keep getting an error, as the debug process stop immediately. VS Code is so much better than Spider, I would really love to be able to use it.
I was wondering if I need to tell VSCode to use a different Python than the one installed in Windows, to use Fusion 360's Python?
Hello,
What was the error you were seeing? It is not necessary to let VS code use the python version inside Fusion. You can give a try if it makes difference.
Thanks,
Marshal
Here is what I get:
"debugging process interrupted unexpectedly"
Thanks for your help,
Bernard
Hello,
Unfortunately I have no idea what's root cause. I encountered the issue in the past, which was because some configuration was wrong. Meanwhile I got the error when I attached to Fusion 360 again after it was detached. I had to restart Fusion 360 to fix it.
So far, debugging experiences with VS code is not so good with Fusion 360. Some improvements will be needed to smooth the experiences. I would recommend you to create a request in our idea station. Let us see how many users have same requirements. Meanwhile our production management team can rank/prioritize it with other requirements together.
https://forums.autodesk.com/t5/fusion-360-ideastation-request-a/idb-p/125
Thanks,
Marshal
Thanks
@marshaltuwrote:Hello,
Unfortunately I have no idea what's root cause. I encountered the issue in the past, which was because some configuration was wrong. Meanwhile I got the error when I attached to Fusion 360 again after it was detached. I had to restart Fusion 360 to fix it.
So far, debugging experiences with VS code is not so good with Fusion 360. Some improvements will be needed to smooth the experiences. I would recommend you to create a request in our idea station. Let us see how many users have same requirements. Meanwhile our production management team can rank/prioritize it with other requirements together.
Hi Marshal,
Thanks for your answer. I will follow your advice, and put a request in the Idea Station. VS Code is way much better, from my point of view, and works on Mac too. So it would be a good choice. If I am not wrong, something like that is already doable for C++, why not for Python?
Anyway, thanks, and best regards,
Bernard
Getting back to attempting to make it work.
I did switch to Fusion 360 Python, and now when I attempt to attach the debugger, I get an more precise error:
There was an error in starting the debug server. Error = {"code":"ECONNREFUSED","errno":"ECONNREFUSED","syscall":"connect","address":"127.0.0.1","port":3000}
I guess it means python refused the connection. Any idea what to do to make it accept the connexion?
Thanks,
Bernard
@Le_Bearwrote:Getting back to attempting to make it work.
I did switch to Fusion 360 Python, and now when I attempt to attach the debugger, I get an more precise error:
There was an error in starting the debug server. Error = {"code":"ECONNREFUSED","errno":"ECONNREFUSED","syscall":"connect","address":"127.0.0.1","port":3000}
I guess it means python refused the connection. Any idea what to do to make it accept the connexion?
Thanks,Bernard
False alert! IT WORKS!!! Yeah!
Looks like I needed to use Fusion360 Python, won't work otherwise. Well, will teste this for a while, but it feels like being upgraded to First class after a long trip in Economy.... 🙂
Are you still able to get it to work? Could you share your launch.json file and what commands you typed into the Fusion 360 console?
Thank you
Hi,
I just successfully set up debugging with VS Code, and I wanted to share my Fusion 360 Python script to enable remote debugging with the latest version of VS Code (1.30.1) & Python (2018.12.1) in Windows.
Here is the script, which hopefully be maintenance free for the future version of the extension:
# Run this from Fusion 360's Text Command panel each time starting Fusion 360 import os from os import path vscodeDir = "C:\\Users\\tikum\\.vscode\\extensions" vscodeExtDir = "" # with os.scandir(vscodeDir) as it: # for entry in it: for entry in os.scandir(vscodeDir): if entry.name.startswith('ms-python.python') and entry.is_dir(): vscodeExtDir = entry.path import sys sys.path.append(vscodeExtDir + "\\pythonFiles\\lib\\python") import ptvsd ptvsd.enable_attach(("0.0.0.0", 3000))
2 discrepancies in the extension versions that Marshal's and my code was written for:
* The location of ptvsd module has been moved from pythonFiles/PythonTools to pythonFile/lib/python within the extension folder
* ptvsd.enable_attach no longer takes "my_secret" argument
I have saved this script as a new custom script in Fusion 360 and run it every time I startup Fusion 360, making it a 3-click process.
Also, REMOVE this line from VS Code's launch.json file:
"secret": "my_secret",
Hope this helps somebody,
Kesh
I know this is an old thread, but now that VS Code can the python editor for the API, what is the status for debugging, officially? I mean, what needs to be done to properly debug from VS Code with Fusion 360 API?
Take a look at this help topic. It goes over the steps to debug a Python script or add-in.