Python Scripts and Add-in does not load at all.

Python Scripts and Add-in does not load at all.

fabrimp
Participant Participant
1,662 Views
9 Replies
Message 1 of 10

Python Scripts and Add-in does not load at all.

fabrimp
Participant
Participant

Hi all,


I'm trying to use python and create my own add-ins however nothing happens when I launch any python script on fusion. Even the scripts that came with fusion are not working, only the C++ ones work.

I Already tried to reinstall fusion and delete all user data also reinstalled python but nothing happens.

I tried to google and search on this forum but looks like no one had that same issue.

I need some help to start troubleshooting the issue, is there any log files that can check or anything that I could probably be missing?

I'm running the latest version of fusion 360 2.0.15299 on windows 11

0 Likes
Accepted solutions (1)
1,663 Views
9 Replies
Replies (9)
Message 2 of 10

BrianEkins
Mentor
Mentor

This seems to be specific to your configuration, and I don't know what the problem might be. I don't know if any of this is a problem but are using Windows Home or Professional? Is there anything special about your login, like it runs as an Administrator?

 

Fusion does log some information when you run or edit a script or add-in. You can find the location of the log file by displaying the TEXT COMMAND window; make sure the option to the right is set to "Txt" and type in "Paths.get". You'll see "AppLogFilePath" in the list, which is the current log file. If you just tried running a script, you should see some lines at the bottom with "VSCode:" in the line. Look for any failures logged here.

 

You also mentioned that you re-installed Python. Unless you're doing standalone Python programming, there's no reason to install Python on your machine. Fusion has its own copy of Python installed as part of Fusion.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 3 of 10

fabrimp
Participant
Participant

Thanks for your help.

 

I'm using windows pro and I for the sake of this troubleshooting I removed python from my machine.

 

When i try to run any add in the text command returns the following error : 

SCRIPT ERROR 

Traceback (most recent call last):
  File "C:\Users/fabri/AppData/Local/Autodesk/webdeploy/production/540c9578410bc15ff261605667cfced82aa9ac6d/Api/InternalAddins/traceparts\localization.py", line 55, in _loadStringTable
    return tables[localeNameMap[getCurrentLanguage()]]
KeyError: <adsk.core.UserLanguages object at 0x000001B55766F7F0>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Users/fabri/AppData/Local/Autodesk/webdeploy/production/540c9578410bc15ff261605667cfced82aa9ac6d/Api/InternalAddins/traceparts/traceparts.py", line 11, in <module>
    COMMANDNAME = _LCLZ('InsertName', 'Insert TraceParts Supplier Components')
  File "C:\Users/fabri/AppData/Local/Autodesk/webdeploy/production/540c9578410bc15ff261605667cfced82aa9ac6d/Api/InternalAddins/traceparts\localization.py", line 9, in _LCLZ
    _stringTable = _loadStringTable() or {}
  File "C:\Users/fabri/AppData/Local/Autodesk/webdeploy/production/540c9578410bc15ff261605667cfced82aa9ac6d/Api/InternalAddins/traceparts\localization.py", line 57, in _loadStringTable
    handleError('loadStringTable')
  File "C:\Users/fabri/AppData/Local/Autodesk/webdeploy/production/540c9578410bc15ff261605667cfced82aa9ac6d/Api/InternalAddins/traceparts\utils.py", line 20, in handleError
    log('{}\n{}'.format(name, traceback.format_exc()))
  File "C:\Users/fabri/AppData/Local/Autodesk/webdeploy/production/540c9578410bc15ff261605667cfced82aa9ac6d/Api/InternalAddins/traceparts\utils.py", line 17, in log
    ui.palettes.itemById('TextCommands').writeText(msg)
AttributeError: 'Palette' object has no attribute 'writeText'

SCRIPT ERROR 

Traceback (most recent call last):
  File "C:/Users/fabri/AppData/Roaming/Autodesk/ApplicationPlugins/GFGearGenerator.bundle/Contents/GFGearGenerator.py", line 3257, in run
    cmdDefcontrol=tbPanel.controls.addCommand(cmdDef)
TypeError: addCommand() missing 2 required positional arguments: 'positionID' and 'isBefore'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Users/fabri/AppData/Roaming/Autodesk/ApplicationPlugins/GFGearGenerator.bundle/Contents/GFGearGenerator.py", line 3319, in run
    ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
TypeError: messageBox() missing 3 required positional arguments: 'title', 'buttons', and 'icon'

 

Because of the language issues, i checked my language settings on windows : 

fabrimp_0-1676471600936.png

 

But I still have no clue how to fix it. Any help is very welcome.

Thanks !

0 Likes
Message 4 of 10

fabrimp
Participant
Participant

Thanks for your help.

 

I'm using windows pro and I for the sake of this troubleshooting I removed python from my machine.

 

When i try to run any add in the text command returns the following error : 

 

 

SCRIPT ERROR 

Traceback (most recent call last):
  File "C:\Users/fabri/AppData/Local/Autodesk/webdeploy/production/540c9578410bc15ff261605667cfced82aa9ac6d/Api/InternalAddins/traceparts\localization.py", line 55, in _loadStringTable
    return tables[localeNameMap[getCurrentLanguage()]]
KeyError: <adsk.core.UserLanguages object at 0x000001B55766F7F0>

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Users/fabri/AppData/Local/Autodesk/webdeploy/production/540c9578410bc15ff261605667cfced82aa9ac6d/Api/InternalAddins/traceparts/traceparts.py", line 11, in <module>
    COMMANDNAME = _LCLZ('InsertName', 'Insert TraceParts Supplier Components')
  File "C:\Users/fabri/AppData/Local/Autodesk/webdeploy/production/540c9578410bc15ff261605667cfced82aa9ac6d/Api/InternalAddins/traceparts\localization.py", line 9, in _LCLZ
    _stringTable = _loadStringTable() or {}
  File "C:\Users/fabri/AppData/Local/Autodesk/webdeploy/production/540c9578410bc15ff261605667cfced82aa9ac6d/Api/InternalAddins/traceparts\localization.py", line 57, in _loadStringTable
    handleError('loadStringTable')
  File "C:\Users/fabri/AppData/Local/Autodesk/webdeploy/production/540c9578410bc15ff261605667cfced82aa9ac6d/Api/InternalAddins/traceparts\utils.py", line 20, in handleError
    log('{}\n{}'.format(name, traceback.format_exc()))
  File "C:\Users/fabri/AppData/Local/Autodesk/webdeploy/production/540c9578410bc15ff261605667cfced82aa9ac6d/Api/InternalAddins/traceparts\utils.py", line 17, in log
    ui.palettes.itemById('TextCommands').writeText(msg)
AttributeError: 'Palette' object has no attribute 'writeText'

SCRIPT ERROR 

Traceback (most recent call last):
  File "C:/Users/fabri/AppData/Roaming/Autodesk/ApplicationPlugins/GFGearGenerator.bundle/Contents/GFGearGenerator.py", line 3257, in run
    cmdDefcontrol=tbPanel.controls.addCommand(cmdDef)
TypeError: addCommand() missing 2 required positional arguments: 'positionID' and 'isBefore'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Users/fabri/AppData/Roaming/Autodesk/ApplicationPlugins/GFGearGenerator.bundle/Contents/GFGearGenerator.py", line 3319, in run
    ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
TypeError: messageBox() missing 3 required positional arguments: 'title', 'buttons', and 'icon'

 

 

 

Because of the language issues, i checked my language settings on windows : 

fabrimp_0-1676471600936.png

 

But I still have no clue how to fix it. Any help is very welcome.

Thanks !

0 Likes
Message 5 of 10

BrianEkins
Mentor
Mentor

I want to confirm exactly what you're doing and seeing. Are these the steps?

 

  1. Run the "Scripts and Add-Ins" command.
  2. Choose any script from the list.
  3. Click the "Run" button.
  4. You see the text you pasted in your reply in the "TEXT COMMAND" window.

Is that correct?

If so, can you please create a new Python script and use that, so I know exactly what you're trying to run? Thanks.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes
Message 6 of 10

fabrimp
Participant
Participant

Hi Brian,

 

Yes, exactly this is what is happening. I did a capture of my screen:

 

fusion addin error.gif

 

Actually, I'm not trying to create anything new, I wanted to use the existing ones to generate gears and I started to wonder what can I create however I could even start because of the script error.

 

I was trying the default template but even this is not working 

#Author-
#Description-

import adsk.core, adsk.fusion, adsk.cam, traceback

def run(context):
    ui = None
    try:
        app = adsk.core.Application.get()
        ui  = app.userInterface
        ui.messageBox('Hello script')

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

 

And the result is the same :

 

SCRIPT ERROR 

Traceback (most recent call last):
  File "C:/Users/fabri/AppData/Roaming/Autodesk/Autodesk Fusion 360/API/Scripts/NewScript1/NewScript1.py", line 11, in run
    ui.messageBox('Hello script')
TypeError: messageBox() missing 3 required positional arguments: 'title', 'buttons', and 'icon'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:/Users/fabri/AppData/Roaming/Autodesk/Autodesk Fusion 360/API/Scripts/NewScript1/NewScript1.py", line 15, in run
    ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
TypeError: messageBox() missing 3 required positional arguments: 'title', 'buttons', and 'icon'

 

Thanks for your attention to my issue. I hope we can find a clue about what is happening.

 

Kind regards,

Fabricio

0 Likes
Message 7 of 10

Jorge_Jaramillo
Collaborator
Collaborator

@fabrimp ,

I believe you have a problem with your environment.

 

Some suggestion to try to catch the problem:

 

1. Did you check what Brian Ekins in this message?

"Fusion does log some information when you run or edit a script or add-in. You can find the location of the log file by displaying the TEXT COMMAND window; make sure the option to the right is set to "Txt" and type in "Paths.get". You'll see "AppLogFilePath" in the list, which is the current log file. If you just tried running a script, you should see some lines at the bottom with "VSCode:" in the line. Look for any failures logged here."

 

2. Could you share the output of the following commands in Fusion's Text Commands view (make sure Py is enabled in the right - button corner). Execute one a at time:

 

import sys

sys.path

sys.version

sys.executable

 

Hope this could help.

 

Regards,

Jorge Jaramillo

 

0 Likes
Message 8 of 10

fabrimp
Participant
Participant

Hi @Jorge_Jaramillo 

 

I checked the logs however i wasn't able to find any critical errors in them. Maybe I'm missing something.

 

Following the output of the commands :

import sys 

sys.path 
['C:\\Users\\fabri\\AppData\\Local\\Autodesk\\webdeploy\\production\\540c9578410bc15ff261605667cfced82aa9ac6d', 'C:\\Users\\fabri\\AppData\\Local\\Autodesk\\webdeploy\\production\\540c9578410bc15ff261605667cfced82aa9ac6d\\Python\\lib', 'C:\\Users\\fabri\\AppData\\Local\\Autodesk\\webdeploy\\production\\540c9578410bc15ff261605667cfced82aa9ac6d', 'C:\\Users\\fabri\\AppData\\Local\\Autodesk\\webdeploy\\production\\540c9578410bc15ff261605667cfced82aa9ac6d\\Python\\lib\\site-packages', 'C:\\Users\\fabri\\AppData\\Local\\Autodesk\\webdeploy\\production\\540c9578410bc15ff261605667cfced82aa9ac6d\\Python\\DLLs', 'C:\\Users\\fabri\\AppData\\Roaming\\Python\\Python39\\site-packages', 'C:/Users/fabri/AppData/Local/Autodesk/webdeploy/production/540c9578410bc15ff261605667cfced82aa9ac6d/', 'C:/Users/fabri/AppData/Local/Autodesk/webdeploy/production/540c9578410bc15ff261605667cfced82aa9ac6d/nspylib.zip', 'C:/Users/fabri/AppData/Local/Autodesk/webdeploy/production/540c9578410bc15ff261605667cfced82aa9ac6d/Api/Python/packages', 'C:/Users/fabri/AppData/Roaming/Autodesk/Autodesk Fusion 360/MyScripts/', 'C:/Users/fabri/AppData/Roaming/Autodesk/Autodesk Fusion 360/MyScripts/Autorun/', 'C:/Users/fabri/AppData/Roaming/Autodesk/Autodesk Fusion 360/MyScripts/Samples/', 'C:/Users/fabri/AppData/Roaming/Autodesk/Autodesk Fusion 360/MyScripts/ProgramData/', 'C:/Users/fabri/AppData/Roaming/Autodesk/Autodesk Fusion 360/MyScripts/AppData/', 'C:/Users/fabri/AppData/Roaming/Autodesk/Autodesk Fusion 360/MyScripts/ManuallyInstalled/']


sys.version 
3.9.6 (tags/v3.9.6:db3ff76, Jun 28 2021, 15:26:21) [MSC v.1929 64 bit (AMD64)]

sys.executable 
C:\\Users\\fabri\\AppData\\Local\\Autodesk\\webdeploy\\production\\540c9578410bc15ff261605667cfced82aa9ac6d\\Fusion360.exe

 Thanks for your attention to my issue!

 

Kind regards,

Fabricio

0 Likes
Message 9 of 10

Jorge_Jaramillo
Collaborator
Collaborator
Accepted solution

Hi @fabrimp ,

The only difference with my environment is this path in sys.path:

'C:\\Users\\fabri\\AppData\\Roaming\\Python\\Python39\\site-packages'

 

Since it is not part of the Fusion's environment, check what you have in that directory.  Maybe something there is generating some conflict with a Fusion library.

And, do you have any PYTHON* environment variable that set this path?

 

Regards,

Jorge Jaramillo

 

 

Message 10 of 10

fabrimp
Participant
Participant

This was the issue !

I deleted this folder and it is working fine now. The weird part is that there is no mention of this folder on my environment variables and I have no clue why this folder was being used as I removed all python installations from my system to troubleshoot this. Deleting this folder solved the issue.

 

Thanks for your help !

 

Kind regards,

Fabricio