Skip to content

Getting started with PyCharm (Windows)

Ben Gruver edited this page Mar 18, 2023 · 5 revisions

This describes how to configure PyCharm and set up a new Fusion 360 project.

Note: An add-in is now required to be installed in Fusion for debugging/running to work. See here for more information.

  1. Install PyCharm 2021.3.2 or later
  2. Open PyCharm, and on the welcome screen select Configure (bottom right corner)->Plugins
  3. Click on the "Marketplace" tab and search for "Fusion 360 Scripting" and install the plugin
  4. Once installed, restart PyCharm to activate the changes
  5. Once it restarts, on the PyCharm welcome screen, choose "New Project"
  6. On the "new project" screen:
    1. Enter the path where you want the new project created
    2. Expand the "Project Interpreter" drop down
    3. Select the "Previously configured interpreter" option
    4. Press the "Add Interpreter" dropdown next to the "Interpreter" option and select "Add Local Interpreter"
    5. In the "Add Python Interpreter" dialog
      1. Select the "System Interpreter" option on the left.
      2. Expand the "Interpreter" drop down, and choose the interpreter with the orange 'F' (Fusion) icon. The path should be located in the local Fusion 360 installation directory
      3. Click "OK" to create the new interpreter
    6. Click on the "Create" button at the bottom of the dialog
  7. The main PyCharm interface should open with your new project
  8. Go to File->Settings->Languages & Frameworks->Fusion 360 and check the "Fusion 360 Support Enabled" checkbox.
  9. Ensure the "Fusion 360 Executable" field is properly populated with the path to the Fusion360.exe executable.
  10. Click "OK" to apply the changes and exit the settings screen.
  11. In the "Project" pane on the left, right click on the project folder and select "New->Python File" and enter a filename. For example "helloworld.py"
  12. Copy and paste the following script:
    import adsk.core, adsk.fusion
    
    def run(_):
        print("hello world\n")
  13. Start Fusion 360 if it hasn't already started
  14. Install the fusion_idea_addin in Fusion 360 (instructions)
  15. Right click in the editor pane in pycharm, and select "Debug in Fusion 360" from the context menu (it may be under the "More Run/Debug" entry)
  16. If you get an error like Cannot run [project] on '<default>', look for the run configuration dropdown in the toolbar. Expand that toolbar and select the fusion process from the list of execution targets.
  17. In order to prevent arbitrary programs from launching scripts in Fusion 360, you must confirm the initial attempt to run/debug a script. Fusion 360 will show a dialog asking for a hash of PyCharm's public key. image
  18. Copy the public key hash from PyCharm's console and enter it in the dialog. image
  19. The script should run in Fusion 360, and you should see output similar to the following in the "Console" pane
    Public key hash: 60DDDD8629935CB98BEF1FA8A4EA20966D2D323E
    Attaching to Fusion 360 process with PID=20972
    Connected to pydev debugger (build 201.6668.115)
    hello world
    
    Server stopped.
    
  20. Now add a breakproint on the print("hello world\n") line, right click and select Debug in Fusion 360
  21. The script should immediately start in Fusion 360 and PyCharm should enter debug mode, with execution paused at the breakpoint. At this point, you can debug as per usual.
Clone this wiki locally