How to Script the "Break Link" Command for CAM Setups in Fusion 360 API

How to Script the "Break Link" Command for CAM Setups in Fusion 360 API

i_ivanov1ch111990
Explorer Explorer
324 Views
1 Reply
Message 1 of 2

How to Script the "Break Link" Command for CAM Setups in Fusion 360 API

i_ivanov1ch111990
Explorer
Explorer

Hello Fusion 360 API Development Team,

I am currently working on automating the process of breaking links for all CAM Setups in Fusion 360 using the API. While the "Break Link" function is available in the context menu within the UI, I could not find a way to execute this operation programmatically. I attempted to use commandDef for the breakLink command, but it does not seem to produce any results.

Here are the specific points I would like clarification on:

1. Is it possible to programmatically execute the "Break Link" command for CAM Setups using the Fusion 360 API? If so, could you provide an example or point to the relevant part of the documentation?

2. Does the "Break Link" functionality rely on hidden or internal API methods that are currently unavailable to developers?

3. Are there any specific parameters or additional steps required to make the breakLink command work via commandDef or another approach?

This functionality is critical for my workflow, as the alternative (recreating setups and transferring parameters manually) introduces unnecessary complexity and potential bugs.

If this feature is not currently supported via the API, could it be considered for a future update? Breaking links for CAM Setups is an essential step in automating machining workflows.

Thank you for your assistance. I look forward to your reply.

 

Best regards,

Ivan Ivanov 

0 Likes
325 Views
1 Reply
Reply (1)
Message 2 of 2

i_ivanov1ch111990
Explorer
Explorer
import adsk.core, adsk.fusion, adsk.cam, traceback

def run(context):
    app = adsk.core.Application.get()
    ui = app.userInterface

    try:
        product = app.activeProduct
        if not isinstance(product, adsk.cam.CAM):
            ui.messageBox('Active document is not a CAM document.')
            return

        cam = adsk.cam.CAM.cast(product)
        setups = cam.setups
        if setups.count == 0:
            ui.messageBox('No setups found in the CAM document.')
            return

        for setup in setups:
            try:
                ui.activeSelections.add(setup)
            except Exception as selection_error:
                app.log(f'Error selecting setup "{setup.name}": {selection_error}')

        app.executeTextCommand('Commands.Start IronBreakLink')

        ui.activeSelections.clear()

        ui.messageBox('BreakLink command applied to all selected setups.')

    except Exception as e:
        if ui:
            ui.messageBox(f'Error: {traceback.format_exc()}')

Found a working method, topic closed