Multi axis CAM "Tool orientation" selection enumerator

Multi axis CAM "Tool orientation" selection enumerator

enervino
Enthusiast Enthusiast
619 Views
4 Replies
Message 1 of 5

Multi axis CAM "Tool orientation" selection enumerator

enervino
Enthusiast
Enthusiast

Hello, I'm trying to make a script that converts single Lines into drilling tool paths including "tool orientation", but unfortunately there is not a lot of information on how the CAM API works within fusion 360. here is what I have so far. After importing the drilling tool path template I can select the points that need to be drilled like this:

 

 

 

inputs = args.command.commandInputs

GuiInputs = getInput(inputs)
DrillLines = GuiInputs[0]

drillBottomPoints = adsk.core.ObjectCollection.create()
for lines in DrillLines:
	drillBottomPoints.add(lines.startSketchPoint)

doc = app.activeDocument
products = doc.products
cam = adsk.cam.CAM.cast(products.itemByProductType("CAMProductType"))
templateFilename = "C:\#python\DrillLines\Templates\TestDrill.f3dhsm-template"
results = setup.createFromTemplate(templateFilename)
operation : adsk.cam.Operation = results.item(0)

setups = cam.setups
setup = setups.item(0)

holePoints = operation.parameters.itemByName("holePoints")
val: adsk.cam.CadObjectParameterValue#note the documentation says nothing about this, just found it in the fourms
val = holePoints.value
val._set_value(drillBottomPoints)


#so all that works now I want to set the axis orientation
toolOriantationCheck.expression = "true" # this works enabling tool orientation
#the following 2 fails with RuntimeError: 3 : Invalid enumeration value
#I don't know what it is supposed to be tbh
view_origin_mode.expression = "(view_orientation_mode == 'surfaceNormalZ' || view_orientation_mode == 'surfaceNormalX') ? 'surfacePointOrigin' : 'jobOrigin'"
view_origin_mode.expression = "axesZX"

#after this I still have to select the Z and X-axis orientations, I don't know how to do that too

 

 

So Please advise on the above and a link to where the documentation of the parameters is located

Thanks!

 

 

 

 

0 Likes
Accepted solutions (1)
620 Views
4 Replies
Replies (4)
Message 2 of 5

BrianEkins
Mentor
Mentor

I don't believe this is officially supported by the CAM API yet. It appears to be a work in progress, which your discovery of the CadObjectParameterValue object indicates. The fact that it's not documented means that it's not supported. Once it's released, the documentation will be available. Even if the goal is to release it and you figured out how to use it, there's the risk that the functionality might change between now and when it's released, since there is no commitment to compatibility for an unsupported function.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes
Message 3 of 5

enervino
Enthusiast
Enthusiast
Accepted solution

Anyway, here is what I came up with, seems to work.

 

def editDrillParameters(operation,drillSketchLine):
    
    operation : adsk.cam.Operation = operation
    drillSketchLine : adsk.fusion.SketchLine = drillSketchLine
    
    
    #put the sketch line into adsk.core.ObjectCollection for CadObjectParameterValue to work
    drillZaxisOrintation = adsk.core.ObjectCollection.create()
    drillZaxisOrintation.add(drillSketchLine)
    
    drillTopRefPoint = adsk.core.ObjectCollection.create()
    drillTopRefPoint.add(drillSketchLine.endSketchPoint)
            
    drillBottomRefpoint = adsk.core.ObjectCollection.create()
    drillBottomRefpoint.add(drillSketchLine.startSketchPoint)
    
    
    
    
    
    #set selection mode Drop down
    holeMode = operation.parameters.itemByName("holeMode")
    val0: adsk.cam.ChoiceParameterValue =  holeMode.value
    val0.value = "selection-points"
    
    #set Point/s
    holePoints = operation.parameters.itemByName("holePoints")
    val1: adsk.cam.CadObjectParameterValue = holePoints.value
    val1._set_value(drillBottomRefpoint)
    
    #set Tool Orintation#note this has to be set true before setting the subsiqinte settings
    toolOriantationCheck = operation.parameters.itemByName("overrideToolView")
    toolOriantationCheck.expression = "true"

    #set view Mode Drop down
    view_orientation_mode = operation.parameters.itemByName("view_orientation_mode")
    val2: adsk.cam.ChoiceParameterValue =  view_orientation_mode.value
    val2.value = "axesZX"
    
    #set View orintation
    view_orientation_axisZ = operation.parameters.itemByName("view_orientation_axisZ")
    val3: adsk.cam.CadObjectParameterValue = view_orientation_axisZ.value
    val3._set_value(drillZaxisOrintation)
    
    #set Top hightMode:
    topHeight_mode = operation.parameters.itemByName("topHeight_mode")
    val4: adsk.cam.ChoiceParameterValue =  topHeight_mode.value
    val4.value = "from point"
    
    #set Top hight Refrince Point:
    topHeight_ref = operation.parameters.itemByName("topHeight_ref")
    val5: adsk.cam.CadObjectParameterValue = topHeight_ref.value
    val5._set_value(drillTopRefPoint)
    
    #set bottom hightMode:
    bottomHeight_mode = operation.parameters.itemByName("bottomHeight_mode")
    val6: adsk.cam.ChoiceParameterValue =  bottomHeight_mode.value
    val6.value = "from point"
    
    #set Top hight Refrince Point:
    bottomHeight_ref = operation.parameters.itemByName("bottomHeight_ref")
    val7: adsk.cam.CadObjectParameterValue = bottomHeight_ref.value
    val7._set_value(drillBottomRefpoint)
0 Likes
Message 4 of 5

enervino
Enthusiast
Enthusiast

Hello, I'm sad to say this method is broken now due to the new updates any ideas on how to do this with the new model? because the API documentation is sparse at best.

 

 

drillBottomRefpoint = adsk.core.ObjectCollection.create()
drillBottomRefpoint.add(drillSketchLine.startSketchPoint)

#set Point/s
holePoints = operation.parameters.itemByName("holePoints")
val1: adsk.cam.CadObjectParameterValue = holePoints.value
val1._set_value(drillBottomRefpoint)

 

 

Basically, this used to work now it does not.

 

here is the error:

 

.....return _cam.CadObjectParameterValue__set_value(self, value)
TypeError: in method 'CadObjectParameterValue__set_value', argument 2 of type 'std::vector< adsk::core::Ptr< adsk::core::Base >,std::allocator< adsk::core::Ptr< adsk::core::Base > > > const &
0 Likes
Message 5 of 5

enervino
Enthusiast
Enthusiast

Ok, i figured it out, no need for an ObjectCollection or_set_value anymore....

 

#set Point/s    
holePoints: adsk.cam.CAMParameter = operation.parameters.itemByName('holePoints')
val1: adsk.cam.CadObjectParameterValue = holePoints.value
val1.value = [drillSketchLine.startSketchPoint]

 

 value is still specifically not defined but hay...