How to add CAM Operations into a folder CAMFolder

How to add CAM Operations into a folder CAMFolder

enervino
Enthusiast Enthusiast
326 Views
1 Reply
Message 1 of 2

How to add CAM Operations into a folder CAMFolder

enervino
Enthusiast
Enthusiast

Hello, I would like to know how to add a custom operation to a folder. the Documentation only has "createFromTemplate", this does not help for an operation that was already created. I was looking into 

adsk.cam.operation.parent but I think this only returns information. The code I'm using here is from the API samples:
#create a operation from the given template
results = setup.createFromTemplate(TemplateFile)
operation : adsk.cam.Operation = results.item(0)

 

0 Likes
327 Views
1 Reply
Reply (1)
Message 2 of 2

echatzief
Advocate
Advocate

What do you mean already created?

You are basically assigning operations to templates, then you are loading the specific templates to the corresponding setup. What you mentioned is the method for assigning operations to setups.

The first one is a method to assign templates to setups.

The second one is a method to store templates in a list if you are using more than one.

 

(You are first executing the second block of code, and then the first one.)

 

 

 

def AssignTemplate(diameter_list_mm, temp_file, repl_value):  
    temp_file_list = []
    for diam_edge_mm in diameter_list_mm:
        temp_name = temp_file.replace(repl_value, str(int(diam_edge_mm)))
        if (not os.path.exists(temp_name)):
            err_mesg = "The template '" + temp_name + "' does not exist"
            ui.messageBox(err_mesg)

        # helping_msg = "The templates used are : " + temp_name
        # ui.messageBox(helping_msg)

        temp_file_list.append(temp_name)
    return temp_file_list
 
def AssignOpsToSetups(setups_, num_ops, num_edges, diameter_list_mm, template_name, diameter_ordered_list, holes_set_):

    num_edges_of_different_diameter = [len(i) for i in holes_set_ ]
    iter_operations_list = [i for i in range(num_ops)]

    for set_ in setups_:
        num_ops_msg = "The number of operations are " + str(num_ops)
        ui.messageBox(num_ops_msg)
        for oper in range(num_ops):
            results = set_.createFromTemplate(template_name[oper])
            operation = results.item(0)
            assign_num = str(int(diameter_list_mm[oper]))
            operation.name = assign_num + '_mm_Drill'
0 Likes