Assining points to CAM drilling operation through sketch

Assining points to CAM drilling operation through sketch

diana.petrova
Enthusiast Enthusiast
2,852 Views
23 Replies
Message 1 of 24

Assining points to CAM drilling operation through sketch

diana.petrova
Enthusiast
Enthusiast

Hello, Fusion Community!

 

So, I'm CAM engineer and have little practical experience with programming. I'm trying to automate one of the CAM operations our team is doing very often. So basicaly there is a sketch with circles (as in picture), the holes have to be drilled in the centre points of those circles. Currently there is a template file for the operations (Spot drilling->Drilling D1->Drilling D2), but all the points must be sellected manually, which is troublesome when there are over 100 point.

dianapetrova_0-1653840489933.png

Currently, with script I'm able to import operations from template to the active setup and add points from sketch to lists, but I'm struggling to assign the list of points to this parameter selected in blue and also I'm not sure if I'm accessing it correctly, as in code section below.

dianapetrova_2-1653841059847.png

 

for op in operat:
                oppoints = op.parameters.itemByName("holePoints")
                ui.messageBox(str(oppoints.isEditable))

 

 

Where 'operat' is an "Operation object". However, it shows that  this parameter is not editable.

 

Does it mean tha this parameter is not allowed to be edited from script and what I want to do is imposible to achieve? Or there is some logic problem?

 

P.S. I'll add the full code in comment

 

 

0 Likes
Accepted solutions (1)
2,853 Views
23 Replies
Replies (23)
Message 21 of 24

echatzief
Advocate
Advocate

 

 

 

 

 

 

 

0 Likes
Message 22 of 24

echatzief
Advocate
Advocate

Probably this ?




def assign_faces(operations, faces_coll):
    global app, ui
    for idx, op in enumerate(operations):
	    holeMode = op.parameters.itemByName('holeMode')
        holeFaces = op.parameters.itemByName('selection-faces')
        operation_name = op.name
        if holeFaces.isEditable:
            ui.messageBox("The hole faces for " + operation_name + " operation, are editable!" )
        else:
            ui.messageBox("The hole faces for " + operation_name + " operation, are NOT editable!" )

        selEdge = sEdge.item(refVal) # faces
        faces_edge_col.add(selEdge) # obj coll
        valZ : adsk.cam.CadObjectParameterValue 
        valZ = holeFaces .value
        valZ._set_value(faces_edge_col) # assign obj coll

0 Likes
Message 23 of 24

kandennti
Mentor
Mentor

@echatzief .

 

Since CadObjectParameterValue is documented, albeit as a preview function, there is no reason to use the "_set_value" method anymore.
As far as I can tell, "CadObjectParameterValue.value" is a list.


Sorry for the Japanese site, but I have a video that shows how to find a hole shape from a simple shape and create a drilling operation.
In this sample, "CadObjectParameterValue.value" is a list of BRepFace.

https://forums.autodesk.com/t5/fusion-360-ri-ben-yu/4yue4ri-xin-zhe-xin-ji-neng-ji-neng-gai-shan-fus... 

0 Likes
Message 24 of 24

diana.petrova
Enthusiast
Enthusiast

@kandenntiThanks a lot for your help. Found time to try and use lists instead of collections, as you suggested, and it worked!

But I guess, if CadObjectParameterValue is still in a preview stage, there will be more crashes in the future. 🙂