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: 

One script to launch another script

3 REPLIES 3
SOLVED
Reply
Message 1 of 4
brad.bylls
189 Views, 3 Replies

One script to launch another script

I have a script file to check Entitlement.

When that comes back as true, I want it to launch the approved script.

I have tried 'subprocess' and 'runpy.' but it looks like they are trying to run outside of Fusion.

This is the entitlement code (sourced from Brian Ekins)

class CheckEntitlement(apper.Fusion360CommandBase):
    def on_execute(self, command: adsk.core.Command, inputs: adsk.core.CommandInputs, args, input_values):
        app = adsk.core.Application.get()
        ui = app.userInterface
        workSpace = ui.workspaces.itemById('FusionSolidEnvironment')
        tbPanels = workSpace.toolbarPanels

        global tbPanel

        try:
            userID = app.userId
            appID = '2588623515668137326'
            url = f'https://apps.autodesk.com/webservices/checkentitlement?userid={userID}&appid={appID}'
            response = urllib.request.urlopen(url)
            jsonb = response.read()
            jsont = jsonb.decode("utf-8")
            json_dict = json.loads(jsont)

            if json_dict['IsValid']:
                # ui.messageBox('The license is valid.')
                tbPanel = tbPanels.itemById('Mold Tech')
                if tbPanel:
                    tbPanel.deleteMe()
            else:
                ui.messageBox('License has Expired') # .\nMessage: ' + json_dict['Message'])

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

 Right after line 23 I want to launch the approved script.

The approved script is just code, no def or class modules.

Any help appreciated.

Brad Bylls
3 REPLIES 3
Message 2 of 4
BrianEkins
in reply to: brad.bylls

To give credit where credit is due, I don't think that code is mine and probably came from Patrick Rainsberry.

 

Unfortunately, what you want to do isn't currently possible. The API needs an API wrapper around the functionality provided by the "Scripts and Add-Ins" command, so you can get a list of known scripts and add-ins, add new ones to the list, run scripts, and load and unload add-ins. None of that is currently available, but it would be nice.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 3 of 4
brad.bylls
in reply to: BrianEkins

To give credit where credit is due, it was you. 

https://forums.autodesk.com/t5/fusion-360-api-and-scripts/entitlement-api/m-p/10908807

Thanks for the input. 

I guess I have to put the Entitlement code at the beginning of the script to get it to work. 

 

Brad Bylls
Message 4 of 4
BrianEkins
in reply to: brad.bylls

That's funny. I saw the use of apper in your sample and figured it wasn't mine but after looking at the referenced thread I see the code you posted is a variation of my original post. It's all coming back to me now. 😄

 

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

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