Activate Setup and Create NCprogram
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
When I manually "activate" a setup. The stock shows and creating an NCProgram ports over the post from the machine and the program comment from the setup. It has to be activated with the stock showing though for it to work. In other words, it can't just be active, it has to be purposely clicked on to show stock.
see video: https://app.screencast.com/favqFh5yKg1jJ
In the following code, I can activate the setup, but it doesn't show stock and port the info over to the NCProgram. Is there a way to do this or am I going to have to code in the post and comments? I should be able to activate the setup properly, correct? That way I have one script that handles every machine instead of creating one script per machine with the post and everything else called out in the script. Am I on the right track or is this not possible?
Thanks.
# Fusion360API Python script
import traceback
import adsk.core as core
import adsk.fusion as fusion
import adsk.cam as cam
def run(context):
ui: core.UserInterface = None
try:
app: core.Application = core.Application.get()
ui = app.userInterface
camObj: cam.CAM = app.activeProduct
# https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-995d634e-a8ef-4f2b-a826-1d32171f4998
ncPrograms: cam.NCPrograms = camObj.ncPrograms
for setup in camObj.setups:
setup_index = 0
setup_var = camObj.setups.item(setup_index)
#Activate the setup
returnValue = setup.activate()
ncIpt: 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 = True
ncIpt.operations = [setup]
ncPrograms.add(ncIpt)
ui.messageBox("Done")
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))S