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: 

Setting a toolclip filename now raises a RuntimeError

5 REPLIES 5
SOLVED
Reply
Message 1 of 6
Anonymous
487 Views, 5 Replies

Setting a toolclip filename now raises a RuntimeError

I have an add-in that was working fine before the latest update, that now won't load.  I get the following error:

 

2015-07-31 11:17:42,958 __main__C%3A%2FUsers%2Fdaniel_obermiller%2FAppData%2FRoaming%2FAutodesk%2FAutodesk%20Fusion%20360%2FAPI%2FAddIns%2F: ERROR Failed: Traceback (most recent call last):
  File "C:\Users\daniel.obermiller\Documents\fusion-360\Add-Ins\my_addin.py", line 309, in run
    commandPolicyDef.toolClipFilename = getToolClipFileName()
  File "C:/Users/daniel.obermiller/AppData/Local/Autodesk/webdeploy/dev/feeb652b43527cc3143c29c11fc5b90c1f517401/Api/Python/packages\adsk\core.py", line 2855, in <lambda>
    __setattr__ = lambda self, name, value: _swig_setattr(self, CommandDefinition, name, value)
  File "C:/Users/daniel.obermiller/AppData/Local/Autodesk/webdeploy/dev/feeb652b43527cc3143c29c11fc5b90c1f517401/Api/Python/packages\adsk\core.py", line 51, in _swig_setattr
    return _swig_setattr_nondynamic(self,class_type,name,value,0)
  File "C:/Users/daniel.obermiller/AppData/Local/Autodesk/webdeploy/dev/feeb652b43527cc3143c29c11fc5b90c1f517401/Api/Python/packages\adsk\core.py", line 44, in _swig_setattr_nondynamic
    if method: return method(self,value)
  File "C:/Users/daniel.obermiller/AppData/Local/Autodesk/webdeploy/dev/feeb652b43527cc3143c29c11fc5b90c1f517401/Api/Python/packages\adsk\core.py", line 2935, in _set_toolClipFilename
    return _core.CommandDefinition__set_toolClipFilename(self, *args)
RuntimeError: 3 : invalid argument value

The code looks like this

 

commandPolicyDef = ui.commandDefinitions.addButtonDefinition("Name", "Text", "", "./Resources/CommandOne")
commandPolicyDef.toolClipFilename = getToolClipFileName()        
onCommandPolicyCreated = CommandPolicyCreatedEventHandler()
commandPolicyDef.commandCreated.add(onCommandPolicyCreated)

Where getToolClipFileName just returns this

 

"./Resources/CommandOne/ToolClip.png"  

 

Why am I getting this error now?

5 REPLIES 5
Message 2 of 6
ekinsb
in reply to: Anonymous

I just tested this and am unable to reproduce the problem.  Can you post your program, or a simplified program that reproduces the problem?  Are you using Windows or Mac?  You can either post it here or send it directly to me at brian.ekins@autodesk.com.


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 3 of 6
Anonymous
in reply to: ekinsb

Windows.  Unfortunately I've already left work for the day, so I'll be unable to send you the exact code until next Monday.

Message 4 of 6
Anonymous
in reply to: ekinsb

I was able to reproduce the issue with the following program

 

 

try:
    import adsk.core
    import adsk.fusion
    import traceback
except:
    app = adsk.core.Application.get()
    ui  = app.userInterface
    ui.messageBox('Failed to load imports:\n{}'.format(traceback.format_exc()))

def run(context):
    try:
        adsk.autoTerminate(False)
        app = adsk.core.Application.get()
        ui  = app.userInterface

        commandPolicyDef = ui.commandDefinitions.addButtonDefinition("Policy", "Title", "", "./Resources/CommandOne")
        commandPolicyDef.toolClipFilename = "./Resources/CommandOne/ToolClip.png"
    except:
        if ui:
           ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

        adsk.autoTerminate(True)
        

def stop(context):
    return

 

 

Traceback is the same as previously posted:

 

  File "C:\Path\to\sample\file.py", line 17, in run
    commandPolicyDef.toolClipFilename = "./Resources/CommandOne/ToolClip.png"
  File "C:/Users/daniel.obermiller/AppData/Local/Autodesk/webdeploy/dev/85596dc3311771e78032fd270cb48fa0f655a848/Api/Python/packages\adsk\core.py", line 2883, in <lambda>
    __setattr__ = lambda self, name, value: _swig_setattr(self, CommandDefinition, name, value)
  File "C:/Users/daniel.obermiller/AppData/Local/Autodesk/webdeploy/dev/85596dc3311771e78032fd270cb48fa0f655a848/Api/Python/packages\adsk\core.py", line 51, in _swig_setattr
    return _swig_setattr_nondynamic(self,class_type,name,value,0)
  File "C:/Users/daniel.obermiller/AppData/Local/Autodesk/webdeploy/dev/85596dc3311771e78032fd270cb48fa0f655a848/Api/Python/packages\adsk\core.py", line 44, in _swig_setattr_nondynamic
    if method: return method(self,value)
  File "C:/Users/daniel.obermiller/AppData/Local/Autodesk/webdeploy/dev/85596dc3311771e78032fd270cb48fa0f655a848/Api/Python/packages\adsk\core.py", line 2963, in _set_toolClipFilename
    return _core.CommandDefinition__set_toolClipFilename(self, *args)
RuntimeError: 3 : invalid argument value

 

Message 5 of 6
ekinsb
in reply to: Anonymous

I suspect that there's a problem with the image file you're trying to use for the tool clip.  I've attached a full project, including the resource images, that uses your code and is working for me.  Below is a picture of the result where you can see the toolcip displayed, (which is a screen shot of the code window).

 

ToolClip.png

 

 


Brian Ekins
Inventor and Fusion 360 API Expert
Mod the Machine blog
Message 6 of 6
Anonymous
in reply to: ekinsb

Oh now this is embarassing... Somehow the image was removed.  Putting it back fixed everything.

 

That being said, this was a thoroughly unhelpful error message.  I know swigging things can make it a little weird, but is it possible to improve that?

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report