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.
Solved! Go to Solution.
Solved by marshaltu. Go to Solution.
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
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!
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