Create a 2D-operation and set the tool orientation over API

Create a 2D-operation and set the tool orientation over API

maurizio_manzi
Advocate Advocate
462 Views
2 Replies
Message 1 of 3

Create a 2D-operation and set the tool orientation over API

maurizio_manzi
Advocate
Advocate

Hello,
It is now possible, for example, to insert a pocket operation via the API and to select various parameters including geometry via the API. Is it also possible to set the complete tool orientation via the API (see image)? Does anyone have an example?

 

 

ToolOrientation.png

 

Best regards

Maurizio

 

Accepted solutions (1)
463 Views
2 Replies
Replies (2)
Message 2 of 3

boopathi.sivakumar
Autodesk
Autodesk
Accepted solution

Hi @maurizio_manzi 

Here is the little snippet of codes you can implement in your code

#operation creation
opInput = setup.operations.createInput('pocket2d')
opInput.tool = getTool()

# Enable Tool orientation
opInput.parameters.itemByName('overrideToolView').expression = 'true'
opInput.parameters.itemByName('view_orientation_mode').expression = "'axesZX'" ## Setting tool orentation mode to select Z axis/plane & X axis
opInput.parameters.itemByName('view_orientation_flipZ').expression = 'true'

#Adding the operation
pocketOp = setup.operations.add(opInput)
edge = body.edges.item(0) ## Body is a brepbody
pocketFace = body.faces.item(0) 

## seleting my edge for Z Axis
toolAxis: adsk.cam.CadObjectParameterValue = pocketOp.parameters.itemByName("view_orientation_axisZ").value
toolAxis.value = [edge]

## Select a face for pocket       
pocketSelection: adsk.cam.CadContours2dParameterValue = pocketOp.parameters.itemByName("pockets").value
faces = pocketSelection.getCurveSelections()
face_ = faces.createNewPocketSelection()
face_.inputGeometry = [pocketFace]
pocketSelection.applyCurveSelections(faces)

Thanks,


Boopathi Sivakumar
Senior Technology Consultant

Message 3 of 3

maurizio_manzi
Advocate
Advocate

Thank you very much

0 Likes