Hello @nubrandao ,
Please find attached codes, You need to select single NC program before running this script, I hope you found this helpful.
import adsk.core, adsk.fusion, adsk.cam, traceback
def run(context):
ui = None
try:
app: adsk.core.Application = adsk.core.Application.get()
ui = app.userInterface
camManger = adsk.cam.CAMManager.get()
postLib = camManger.libraryManager.postLibrary
# url = adsk.core.URL.create('system://setup-sheet-excel-2007.cps')
url = adsk.core.URL.create('system://setup-sheet-excel-2007.new.cps')
postPorcessor = postLib.postConfigurationAtURL(url)
if not postPorcessor :
ui.messageBox("Specified post processor not found!")
return
if ui.activeSelections.count != 1 :
ui.messageBox("Please select only 1 ncprogram as a time")
return
Selections = ui.activeSelections.all
for sel in Selections:
ncProgram = adsk.cam.NCProgram.cast(sel)
if ncProgram :
orignalPost = ncProgram.postConfiguration
ncProgram.postConfiguration = postPorcessor
ncPostOpetion = adsk.cam.NCProgramPostProcessOptions.create()
ncProgram.postProcess(ncPostOpetion)
ncProgram.postConfiguration = orignalPost
ui.messageBox("done")
return
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
apart from that i think we can use 'use cascading post' option in NC program Window, it will help you to do same thing without ADD-IN but that may require some modification in postprocessor.