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: 

Using Cloud Library Post for Post Process Input

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
Joshua.mursic
138 Views, 2 Replies

Using Cloud Library Post for Post Process Input

Hello, I am trying to use a Post processor on my cloud library for use in the PostProcessInput class. The 

PostProcessInput class wants the post configuration to be a string path to the post, but I dont understand how to give it a post that is located in my Cloud Library.
 

 

import adsk.core, adsk.cam

app = adsk.core.Application.get()
ui = app.userInterface

def getPost(targetPostName:str):
    camManager = adsk.cam.CAMManager.get()
    libraryManager = camManager.libraryManager
    postLibraries = libraryManager.postLibrary
    cloudFolder = postLibraries.urlByLocation(adsk.cam.LibraryLocations.CloudLibraryLocation)
    cloudPostlibrary = postLibraries.childAssetURLs(cloudFolder)

    # Get Templates
    for cloudPost in cloudPostlibrary:
        postName = cloudPost.toString()
        if targetPostName in postName:
            postUrl = adsk.core.URL.create(postName)
            # postConfiguration = postLibraries.postConfigurationAtURL(postUrl)
            return postUrl.toString()

    # Error if not found
    ui.messageBox(f"Could not find Postprocessor {targetPostName}")


def postProcess():
    cam:adsk.cam.CAM = app.activeDocument.products.itemByProductType("CAMProductType")
    setups = cam.setups
    setup = setups.item(0)

    # specify the program name, post configuration to use and a folder destination for the nc file
    programName = '1010'
    postConfig = getPost("Dumper.cps")
    outputFolder = cam.temporaryFolder
    units = adsk.cam.PostOutputUnitOptions.DocumentUnitsOutput
    # create the postInput object
    postInput = adsk.cam.PostProcessInput.create(programName, postConfig, outputFolder, units)
    postInput.isOpenInEditor = False

    cam.postProcess(setup, postInput)

 

 

Here I am searching my cloud library for the post with the name Dumper.cps, then I am getting the URL to that post as a string, which looks like this: "cloud://Dumper.cps"

 

I pass that to the PostProcessInput class, but it is returning:

"RuntimeError: 3 : The input configuration file does not exist."

 

Is it possible to use cloud posts?

2 REPLIES 2
Message 2 of 3
kandennti
in reply to: Joshua.mursic

Hi @Joshua.mursic -San.

 

I modified it based on the sample here.

https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-995d634e-a8ef-4f2b-a826-1d32171f4998 

 

def getPost(targetPostName:str):
    camManager = adsk.cam.CAMManager.get()
    libraryManager = camManager.libraryManager
    postLibraries = libraryManager.postLibrary
    cloudFolder = postLibraries.urlByLocation(adsk.cam.LibraryLocations.CloudLibraryLocation)
    cloudPostlibrary = postLibraries.childAssetURLs(cloudFolder)

    # Get Templates
    for cloudPost in cloudPostlibrary:
        postName = cloudPost.toString()
        if targetPostName in postName:
            postUrl = adsk.core.URL.create(postName)
            # postConfiguration = postLibraries.postConfigurationAtURL(postUrl)
            # return postUrl.toString()
            return postLibraries.postConfigurationAtURL(postUrl)

    # Error if not found
    ui.messageBox(f"Could not find Postprocessor {targetPostName}")


def postProcess():
    cam:adsk.cam.CAM = app.activeDocument.products.itemByProductType("CAMProductType")
    setups = cam.setups
    setup = setups.item(0)

    # specify the program name, post configuration to use and a folder destination for the nc file
    programName = '1010'
    postConfig = getPost("Dumper.cps")
    outputFolder = cam.temporaryFolder
    # units = adsk.cam.PostOutputUnitOptions.DocumentUnitsOutput
    # create the postInput object
    # postInput = adsk.cam.PostProcessInput.create(programName, postConfig, outputFolder, units)
    # postInput.isOpenInEditor = False

    # cam.postProcess(setup, postInput)

    ncInput = cam.ncPrograms.createInput()
    ncInput.displayName = 'NC Program Sample'

    ncParameters = ncInput.parameters
    ncParameters.itemByName('nc_program_name').value.value = programName
    ncParameters.itemByName('nc_program_filename').value.value = 'NCProgramSample'
    ncParameters.itemByName('nc_program_openInEditor').value.value = False
    ncParameters.itemByName("nc_program_unit").value.value = 'DocumentUnit'
    ncParameters.itemByName('nc_program_output_folder').value.value = outputFolder

    ncInput.operations = list(setup.operations)
    newProgram = cam.ncPrograms.add(ncInput)
    newProgram.postConfiguration = postConfig

    postOptions = adsk.cam.NCProgramPostProcessOptions.create()

    newProgram.postProcess(postOptions)

 

It seems to work fine in my environment.

 

Message 3 of 3
Joshua.mursic
in reply to: kandennti

@kandennti  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