Hi @dames123
I think currently we don't have a support to read post from linked library via API. I will just confirm that.
Do you want to import the post from your local directory then use it? is it the workflow you are trying to acheive?
Yes. I have a script that currently pulls a post from the Fusion local folder and I would like to change that to a linked folder. Maybe @Jorge_Jaramillo has some insight?
#n360API Python script
import adsk.core
import traceback
import adsk.core as core
import adsk.fusion as fusion
import adsk.cam as cam
def run(context):
app = adsk.core.Application.get()
try:
create_and_duplicate_ncprogram(app)
ui: core.UserInterface = None
except:
app.log('Failed:\n{}'.format(traceback.format_exc()))
def create_and_duplicate_ncprogram(
app: adsk.core.Application,
) -> None:
try:
camObj: adsk.cam.CAM = app.activeProduct
ui = app.userInterface
# https://url.us.m.mimecastprotect.com/s/R9VIC2kr1Nf6PQk3I9ku4o?domain=help.autodesk.com
ncPrograms: adsk.cam.NCPrograms = camObj.ncPrograms
for setup in camObj.setups:
ncIpt: adsk.cam.NCProgramInput = ncPrograms.createInput()
ncIpt.displayName = setup.name
ncParameters = ncIpt.parameters
ncParameters.itemByName('nc_program_filename').value.value = setup.name
ncParameters.itemByName('nc_program_openInEditor').value.value = False
ncParameters.itemByName('nc_program_useMachineConfig').value.value = True
ncParameters.itemByName('nc_program_filename').value.value = setup.parameters.itemByName('job_programName').value.value # Set the filename to the same as the setup
ncParameters.itemByName('nc_program_comment').value.value = setup.parameters.itemByName('job_programComment').value.value
ncIpt.operations = [setup]
prg = ncPrograms.add(ncIpt)
prg.machine = setup.machine # Set the machine to the same as the setup
app.log(f' {setup.name=} :: {setup.machine=} {prg.machine=}')
# Duplicate the NCProgram
duplicatedPrg = prg.duplicate()
if duplicatedPrg:
camObj.ncPrograms[-1].name = f"{setup.name} SETUPSHEET"
postConf = import_post_processor()
if postConf:
camObj.ncPrograms[-1].postConfiguration = postConf
else:
app.log(f"Failed to duplicate NCProgram for setup: {setup.name=}")
app.log("Dont forget to set your tool numbers")
for prg in ncPrograms:
app.log(f"{prg.name} : nc_program_post = {prg.parameters.itemByName('nc_program_post').value.value}")
ui.messageBox("Dont forget to set your tool numbers")
except:
app.log('Failed:\n{}'.format(traceback.format_exc()))
def import_post_processor() -> adsk.cam.PostConfiguration | None:
POST_PROCESSOR_DESCR = 'Setup-Sheet-For-High-Speed'
POST_PROCESSOR_FILENAME = 'Setup-Sheet-For-High-Speed.cps'
POST_PROCESSOR_URL = 'user://'
camMngr: adsk.cam.CAMManager = adsk.cam.CAMManager.get()
camLibMngr: adsk.cam.CAMLibraryManager = camMngr.libraryManager
postLibrary = camLibMngr.postLibrary
importedURL: adsk.core.URL = None
local_url = adsk.core.URL.create(POST_PROCESSOR_URL)
# 1. Look for post processor locally
for url in postLibrary.childAssetURLs(local_url):
if url.leafName == POST_PROCESSOR_FILENAME:
importedURL = url
if not importedURL:
# 2. Look for post processor in Fusion's PostProcessors Library
postQuery = postLibrary.createQuery(adsk.cam.LibraryLocations.Fusion360LibraryLocation)
postConfigs = postQuery.execute()
for config in postConfigs:
if config.description == POST_PROCESSOR_DESCR:
# 3. If found it, copy it locally
importedURL = postLibrary.importPostConfiguration(config, local_url, POST_PROCESSOR_FILENAME)
if importedURL:
postConf = postLibrary.postConfigurationAtURL(importedURL)
return(postConf)
else:
return(None)
adsk.terminate()
Hi @Jorge_Jaramillo ,
Yes, you can link a folder on a network share for your team to access. I know I should probably use the cloud but I prefer a hard copy.