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: 

Failed to add a new workspace

4 REPLIES 4
SOLVED
Reply
Message 1 of 5
lsRDZZQ
600 Views, 4 Replies

Failed to add a new workspace

Hello,

 

I tried to add a new workspace by calling 

Ptr<Workspace> wspace= workspaces->add("NewWSpace", "NewWSpaceID", "NewWSpace", "./icon");

 

But wspace is always null. What should I do? Thanks!

The two png icons are under ./icon directory. 

Tags (1)
4 REPLIES 4
Message 2 of 5
marshaltu
in reply to: lsRDZZQ

Hello,

 

It looked the product type you gave was not valid. Please give a try for the Python sample codes as below and see if it works or in your side?

 

 

#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.workspaces.add(app.activeProduct.productType, 'NewWSpaceID', 'NewWSpace', '')

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

 

Thanks,

Marshal



Marshal Tu
Fusion 360 Developer
Autodesk, Inc.

Message 3 of 5
lsRDZZQ
in reply to: marshaltu

Hi Marshal,

 

Thank you so much!! It works. 

 

BTW the API documentation does not indicate that we should use a specific product type like this, it is better to write it down all the details in the manual. I spent a lot of time to play with this simple functions. There is no way we can guess. No error message Just return null is really hard to figure out the problem. Hope you guys can improve it.  thanks!

 

Message 4 of 5
marshaltu
in reply to: lsRDZZQ

Hello,

 

Thank you for the suggestion. We will improve documentation for the API.

 

BTW: in C++, Application::getLastError() api will help give more error information once you cannot get expected result from some specific API. For Python and Javascript, an exception error message would pop up directly if the API call fails.

 

In addition, Application::supportedProductTypes() will give a list of product types.

 

Thanks,

Marshal



Marshal Tu
Fusion 360 Developer
Autodesk, Inc.

Message 5 of 5
lsRDZZQ
in reply to: marshaltu

Marshal,

 

Glad to know that there is a function to get the error message. thanks!

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