How to create one NC with the same name

How to create one NC with the same name

nubrandao
Collaborator Collaborator
1,446 Views
5 Replies
Message 1 of 6

How to create one NC with the same name

nubrandao
Collaborator
Collaborator

Hi, for example, in the company my collegs use a lot probing, mostly fusion for probing,

 

they create one toolpath (probing), rename

the create one NC program, inside input toolpath manually

then post, and rename the NC again , so, they are renaming a lot of times.

 

is possible to select one toolpath and create one NC and rename automaticly?

 

i will create a video of what i want.

(view in My Videos)

 

to me i have to be honest , is not very important because i dont probe a lot.

 

basically they want rename once (toolpath) then with shift+s run script to the selected toolpath, create a nc program with same name on title and inside

 

0 Likes
Accepted solutions (1)
1,447 Views
5 Replies
Replies (5)
Message 2 of 6

Jorge_Jaramillo
Collaborator
Collaborator

Hi,

 

In this topic:

https://forums.autodesk.com/t5/fusion-api-and-scripts/compare-and-edit-after-running-script/td-p/129...

you can an example of how to generate NC program por setup, assign it a name, and even assign a specific post-processor.

 

I hope it can help you.

 

Regards,

Jorge Jaramillo

 

 

0 Likes
Message 3 of 6

kandennti
Mentor
Mentor

Hi @nubrandao -San.

 

I made a sample.

# 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

        # Select Count check
        sels: core.Selections = ui.activeSelections
        if not sels.count == 1: return

        # Select Operation
        ope: cam.Operation = sels.item(0).entity

        # Create NcProgram Input
        camObj: cam.CAM = app.activeProduct
        ncProgs: cam.NCPrograms = camObj.ncPrograms

        ncInput: cam.NCProgramInput = ncProgs.createInput()

        # Set Name
        ncInput.displayName = ope.name

        # Set Nc Program Name
        ncInput.parameters.itemByName("nc_program_name").value.value = ope.name

        # Set Operation
        ncInput.operations = [ope]

        # Create NcProgram
        ncProgs.add(ncInput)

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))

 

Message 4 of 6

nubrandao
Collaborator
Collaborator

hi, that is perfect, could be possible to do the same thing but with multiple selections?

0 Likes
Message 5 of 6

kandennti
Mentor
Mentor
Accepted solution

@nubrandao -San.

 

What you are doing here on this topic is what you hope to do.

https://forums.autodesk.com/t5/fusion-api-and-scripts/api-create-one-nc-for-each-toolpath/td-p/12994... 

 

Slight modification.

# 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

        # Select Count check
        sels: core.Selections = ui.activeSelections
        if sels.count < 1: return

        # Select Operation
        opeLst: list[cam.Operation] = [sel.entity for sel in sels]

        camObj: cam.CAM = app.activeProduct
        ncProgs: cam.NCPrograms = camObj.ncPrograms

        for ope in opeLst:
            # Create NcProgram Input
            ncInput: cam.NCProgramInput = ncProgs.createInput()

            # Set Name
            ncInput.displayName = ope.name

            # Set Nc Program Name
            ncInput.parameters.itemByName("nc_program_name").value.value = ope.name

            # Set Operation
            ncInput.operations = [ope]

            # Create NcProgram
            ncProgs.add(ncInput)

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
Message 6 of 6

nubrandao
Collaborator
Collaborator

You are the best, that's a life saver in company. Thanks a lot