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: 

How to change to "Design" ?

2 REPLIES 2
Reply
Message 1 of 3
maurizio_manzi
89 Views, 2 Replies

How to change to "Design" ?

Hello,

it's possible to change in the actual document  over a script for example from "Machining" to "Design" ?

The following code only works, if actual document is set to "Design":

 

import adsk.core, adsk.fusion, adsk.cam, traceback, os

def run(context😞
    ui = None
    try:
        app =       adsk.core.Application.get()
        ui  =       app.userInterface
        design =    app.activeProduct
        exportMgr = design.exportManager
        docName =   app.activeDocument.name

       

        ui.messageBox('Export an FeatureCAM')

        # path: = os.getenv('TMP') + "\FusionToFC"

        path = r"C:\temp\FusionToFC"
     
        if not os.path.exists(path😞
          os.mkdir(path)
     
        #igesOptions = exportMgr.createIGESExportOptions(path + "/" + docName + ".igs")
        #res = exportMgr.execute(igesOptions)

        stepOptions  = exportMgr.createSTEPExportOptions(path + "/" + docName + ".stp")
        res = exportMgr.execute(stepOptions)

        #satOptions = exportMgr.createSATExportOptions(path + "/" + docName + ".sat")
        #res = exportMgr.execute(satOptions)
   
        #smtOptions = exportMgr.createSMTExportOptions(path + "/" + docName + ".smt")
        #res = exportMgr.execute(smtOptions)

        #fusionArchivevOptions = exportMgr.createFusionArchiveExportOptions(path + "/" + docName + ".f3d")
        #res = exportMgr.execute(fusionArchivevOptions)

        ui.messageBox('Export erfolgreich')
       
    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
 
 
Best regards
Maurizio
 
2 REPLIES 2
Message 2 of 3
kandennti
in reply to: maurizio_manzi

Hi @maurizio_manzi .

 

Workspaces.itemById method is used to retrieve and activate Workspaces.

https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-018cbb0d-90ab-4f48-98cb-3428126f7d27 

 

# Fusion360API Python script

import traceback
import adsk.fusion
import adsk.core

def run(context):
    ui = adsk.core.UserInterface.cast(None)
    try:
        app: adsk.core.Application = adsk.core.Application.get()
        ui = app.userInterface

        ws: adsk.core.Workspace = ui.workspaces.itemById(
            'FusionSolidEnvironment'
        )

        if ws:
            ws.activate()

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

Thank you very much

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