Failed to select a cylinder-face as geometry for a drill operation

Failed to select a cylinder-face as geometry for a drill operation

maurizio_manzi
Advocate Advocate
1,025 Views
8 Replies
Message 1 of 9

Failed to select a cylinder-face as geometry for a drill operation

maurizio_manzi
Advocate
Advocate

Hello,
I create a drill operation and select my cylinder-Face as geometry (drill position),

but in the line "selection = cadcontours.getCurveSelections()" I get an error message:

"AttributeError: 'CadObjectParameterValue' object has no attribute 'getCurveSelections'"

 

Code:

# drillFace is my cylinder-face (I can select it manually in the operation)
operationInput = setup.operations.createInput('drill')
operationInput.tool = toolDrill
op_drill = setup.operations.add(operationInput
op_drill.parameters.itemByName('holeMode').expression = "'selection-faces'"
cadcontours: adsk.cam.CadContours2dParameterValue = op_drill.parameters.itemByName('holeFaces').value
selection = cadcontours.getCurveSelections() # <<<--- Error see below
faceContourSel: adsk.cam.FaceContourSelection = selection.createNewFaceContourSelection()
contour selection
faceContourSel.inputGeometry = [drillFace]
cadcontours.applyCurveSelections(selection)
 
# ERROR:

#selection = cadcontours.getCurveSelections()

#AttributeError: 'CadObjectParameterValue' object has no attribute 'getCurveSelections'

 

Best regards

Maurizio

 

0 Likes
Accepted solutions (1)
1,026 Views
8 Replies
Replies (8)
Message 2 of 9

kandennti
Mentor
Mentor

Hi @maurizio_manzi .

 

"op_drill.parameters.itemByName('holeFaces').value" is "CadObjectParameterValue" instead of "CadContours2dParameterValue".

1.png

 

Therefore, it must be done this way.

・・・
        operationInput = setup.operations.createInput('drill')
        operationInput.tool = toolDrill
        op_drill = setup.operations.add(operationInput)
        op_drill.parameters.itemByName('holeMode').expression = "'selection-faces'"
        # cadcontours: adsk.cam.CadContours2dParameterValue = op_drill.parameters.itemByName('holeFaces').value
        cadcontours: adsk.cam.CadObjectParameterValue = op_drill.parameters.itemByName('holeFaces').value
        # selection = cadcontours.getCurveSelections() # <<<--- Error see below
        # faceContourSel: adsk.cam.FaceContourSelection = selection.createNewFaceContourSelection()
        # contour selection
        # faceContourSel.inputGeometry = [drillFace]
        # cadcontours.applyCurveSelections(selection)
        cadcontours.value = [drillFace]
・・・
0 Likes
Message 3 of 9

maurizio_manzi
Advocate
Advocate

Thank you very much for help.
I create the cylinder surface for the drill operation as a revolve:

# Create surface as rotation:
revolves = occComp.features.revolveFeatures
revInput = revolves.createInput(profile, axis, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
angle = adsk.core.ValueInput.createByReal(math.pi*2)
revInput.setAngleExtent(False, angle)
revInput.isSolid = False
ext = revolves.add(revInput)
 
Now I try to use the revolve ("ext") as surface for the drill operation:
drillFace = ext # Revolve as Face for drill operation
operationInput = setup.operations.createInput('drill')
operationInput.tool = toolDrill
op_drill = setup.operations.add(operationInput) # Add Operation
op_drill.parameters.itemByName('holeMode').expression = "'selection-faces'"
cadcontours: adsk.cam.CadObjectParameterValue = op_drill.parameters.itemByName('holeFaces').value
cadcontours.value = [drillFace]
 
But I get in the operation an error message (see pic below).
I think, I can't use directly the revolve as face for the drill operation.
How can I get a valid face from my revolve operation ?
 
26-04-_2023_10-24-27.png
 
Best regards
Maurizio
0 Likes
Message 4 of 9

kandennti
Mentor
Mentor

@maurizio_manzi .

 

As with all questions, it takes too much time to reproduce the same condition rather than looking for the cause.
Could you please attach the f3d file?

0 Likes
Message 5 of 9

kandennti
Mentor
Mentor
Accepted solution

@maurizio_manzi .

 

It should be a BRepFace listing, not a RevolveFeature.

1.png

・・・
        # drillFace = ext # Revolve as Face for drill operation
        drillFaces = [f for f in ext.bodies[0].faces]
・・・
        # cadcontours.value = [drillFace]
        cadcontours.value = drillFaces
・・・


There may be other causes, but we cannot be sure without seeing the data.

 

Use this one because the indentation is broken.

1.png

0 Likes
Message 6 of 9

maurizio_manzi
Advocate
Advocate

   

0 Likes
Message 7 of 9

maurizio_manzi
Advocate
Advocate

How can I create this dump myself ?

 

aaa.png

0 Likes
Message 8 of 9

kandennti
Mentor
Mentor

@maurizio_manzi .

 

Thanks for the data.

I gave up because I don't know what "profile" and "axis" are.

0 Likes
Message 9 of 9

maurizio_manzi
Advocate
Advocate

Hello,
It works fine, with:

drillFaces = [f for f in ext.bodies[0].faces]
・・・
        # cadcontours.value = [drillFace]
        cadcontours.value = drillFaces

 Thank you very much.

How can I see this dump in my VS-code ?

 

aaa.png

 

Best regards
Maurizio

0 Likes