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: 

API - MILLTURN setup - will not return a fixture / MILL setup does it.

0 REPLIES 0
Reply
Message 1 of 1
martini_ewald
48 Views, 0 Replies

API - MILLTURN setup - will not return a fixture / MILL setup does it.

Ciao all, 

please see the script - the MILLTURN setup retur allway 0 fixture / MILL setup return 1 fixture. Why? It seems to me to be an FUSION 360 Issue. 

 

 

#Description - Script to demonstrate a missfunktion in FUSION360 #hasGlobalParameter("autodeskcam:fixture-path") FALSE on Post.CPS in a MillTurn SETUP. 

import traceback
import adsk.core as core
import adsk.fusion as fusion
import adsk.cam as cam

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

        camObj: cam.CAM = get_cam_product()

        rootOcc: fusion.Occurrence = camObj.designRootOccurrence
        root: fusion.Component = rootOcc.component

        #generate Mill setup
        setup: cam.Setup = create_setup(
            camObj,
            root.bRepBodies[0],
            root.allOccurrences[0],
            "MILL"
        )        
        setup.fixtureEnabled = True                                                                        
        ui.messageBox('Setup ' + setup.name + ' has ' + str(setup.models.count) + ' models and ' + str(setup.fixtures.count) + ' fixtures', "MILL Setup")

        #generate MillTurn setup
        setup: cam.Setup = create_setup(
            camObj,
            root.bRepBodies[0],
            root.allOccurrences[0],
            "MILLTURN"
        )        
        setup.fixtureEnabled = True                                                                        
        ui.messageBox('Setup ' + setup.name + ' has ' + str(setup.models.count) + ' models and ' + str(setup.fixtures.count) + ' fixtures', "MILLTURN Setup")        

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


def create_setup(
    camObj: cam.CAM,
    targetBody: fusion.BRepBody,
    fixture: core.Base,
    strOpType, 
    ) -> cam.Setup:

    setups: cam.Setups = camObj.setups

    match strOpType:
        case "MILL":
            setupIpt: cam.SetupInput = setups.createInput(                
            cam.OperationTypes.MillingOperation                 
            )
            setupIpt.name = strOpType
        case "MILLTURN":
            setupIpt: cam.SetupInput = setups.createInput(                        
            cam.OperationTypes.TurningOperation            
            )                
            setupIpt.name = strOpType
    
    setupIpt.models = [targetBody]
    setupIpt.fixtures = [fixture]    
    setup: cam.Setup = setups.add(setupIpt)            
    return setup


def get_cam_product() -> cam.CAM:
    app: core.Application = core.Application.get()
    activete_cam_env()

    return app.activeProduct


def activete_cam_env() -> None:
    app: core.Application = core.Application.get()
    ui: core.UserInterface = app.userInterface

    camWS: core.Workspace = ui.workspaces.itemById('CAMEnvironment') 
    camWS.activate()

 

Labels (2)
0 REPLIES 0

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