Setting a toolclip filename now raises a RuntimeError

Setting a toolclip filename now raises a RuntimeError

Anonymous
Not applicable
909 Views
5 Replies
Message 1 of 6

Setting a toolclip filename now raises a RuntimeError

Anonymous
Not applicable

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?

0 Likes
Accepted solutions (1)
910 Views
5 Replies
Replies (5)
Message 2 of 6

ekinsb
Alumni
Alumni

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
0 Likes
Message 3 of 6

Anonymous
Not applicable

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

0 Likes
Message 4 of 6

Anonymous
Not applicable

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

 

0 Likes
Message 5 of 6

ekinsb
Alumni
Alumni
Accepted solution

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
Not applicable

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?

0 Likes