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.
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Issue with createFromCAMTemplate2 - Need to Add Operations to the Start of the Setup

Message 1 of 1
66 Views, 0 Replies

Issue with createFromCAMTemplate2 - Need to Add Operations to the Start of the Setup

Hello Fusion 360 Community,


I hope this message finds you well. I'm currently facing an issue with the `createFromCAMTemplate2` function in my Python script. When using this function, the new operations are added to the end of the parent setup. However, I need them to be added to the start of the setup.


import adsk.core, adsk.fusion,, traceback

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

        # Get the active document.
        doc = app.activeDocument

        # From the Products collection on the active document, get the CAM Product.
        cam: = doc.products.itemByProductType('CAMProductType')

        # Check if anything was returned.
        if cam == None:
             ui.messageBox('There is no CAM data in the active document')
        camManager =

        templateLibrary = camManager.libraryManager.templateLibrary

        LocalFolder = templateLibrary.urlByLocation(

        templateLibs = getLibrariesURLs(templateLibrary, LocalFolder)

        for libUrl in templateLibs:
                if 'Vacuum' in libUrl:
                    url = adsk.core.URL.create(libUrl)

        VacuumTemplate = templateLibrary.templateAtURL(url)

        setups = cam.setups
        newVacuumOperation =
        newVacuumOperation.camTemplate = VacuumTemplate
        for setup in setups:
        if ui:

def getLibrariesURLs(libraries:, url: adsk.core.URL):
    ''' Return the list of libraries URL in the specified library '''
    urls: list[str] = []
    libs = libraries.childAssetURLs(url)
    for lib in libs:
    for folder in libraries.childFolderURLs(url):
        urls = urls + getLibrariesURLs(libraries, folder)
    return urls

I have multiple setups, and I want the new vacuum operations to be added to the start of each setup, not the end.


I've reviewed the Autodesk Fusion 360 API documentation, but I couldn't find a direct solution. If anyone has encountered a similar issue or has suggestions on how to achieve this, your guidance would be greatly appreciated.


Thank you in advance for your time and assistance!


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