Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Multi chamfer problems

8 REPLIES 8
SOLVED
Reply
Message 1 of 9
brad.bylls
274 Views, 8 Replies

Multi chamfer problems

Trying to chamfer three edges on a component.

328    # Create the chamfer
329    edgeCol = adsk.core.ObjectCollection.create()
330    edgeCol.clear()
331    edges = stemExt.sideFaces[0].edges # I've tried [1] and [2] also
332    for edgeI in edges:
333        edgeCol.add(edgeI)
334
335    chamferFeats = newComp.features.chamferFeatures
336    chamferInput = chamferFeats.createInput(edgeCol, True)
337    chamferInput.setToEqualDistance(
338        adsk.core.ValueInput.createByReal((numStemDiam - numHoleThru)/4))
339    chamferFeats.add(chamferInput)

Screenshot 2023-08-07 135536.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

I get this error

Screenshot 2023-08-07 141121.png

Brad Bylls
8 REPLIES 8
Message 2 of 9
BrianEkins
in reply to: brad.bylls

Can you post the model? I created a model that looks similar and it works for me.

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

@Jorge_Jaramillo - this post is being edited to remove PII.

 

Hi,

 

Just to be sure you are in the correct feature, could you check :

 

stemExt.sideFaces.count

 

 

If it is > 1 then can you try with instead:

 

edges = stemExt.sideFaces.item(0).edges

 

 

Could you share how it creates stemExt feature?  What kind of feature is stemExt?

 

Regards,

Jorge Jaramillo

 

Message 4 of 9

 # Create the stem
    stemSketch = sketches.addWithoutEdges(xyPlane)
    center = stemSketch.modelToSketchSpace(clickPoint)
    stemCircle = stemSketch.sketchCurves.sketchCircles.addByCenterRadius(center, numStemDiam/2)
    stemSketch.sketchDimensions.addDiameterDimension(stemCircle, adsk.core.Point3D.create(1, 0, 0))
    stemSketch.name = 'Stem Diameter Sketch'
    stemProf = stemSketch.profiles[0]
    stemExtInput = extrudes.createInput(stemProf, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
    distance3 = adsk.core.ValueInput.createByReal(numStemLen + numHexLen + numThreadStraight)
    stemExtInput.setDistanceExtent(False, distance3)
    stemExt = extrudes.add(stemExtInput)
    # Change to inches in Parameters
    extent_3 = stemExt.extentOne
    distanceMP_3 = extent_3.distance
    distanceMP_3.expression = "{:.{}f}".format(((numStemLen + numHexLen + numThreadStraight) / sizeUnits), 4) + 'in'
    # Add the name
    stemExt.name = 'Stem length from face'

    # Create the oil groove
    stemGrooveSketch = sketches.addWithoutEdges(xyPlane)
    stemGrooveCircle = stemGrooveSketch.sketchCurves.sketchCircles.addByCenterRadius(
        center, (numStemDiam + .1) / 2)
    stemGrooveCircle1 = stemGrooveSketch.sketchCurves.sketchCircles.addByCenterRadius(
        center, (numStemDiam-(numStemDiam - numHoleThru)/2) / 2)
    stemGrooveSketch.sketchDimensions.addDiameterDimension(stemGrooveCircle, adsk.core.Point3D.create(1, 1, 0))
    stemGrooveSketch.name = 'Stem Groove Sketch'
    stemGrooveProf = stemGrooveSketch.profiles[0]
    stemGrooveExtInput = extrudes.createInput(stemGrooveProf, adsk.fusion.FeatureOperations.CutFeatureOperation)
    grooveCenter = (numThreadStraight + numHexLen + (numStemLen / 2)) * -1
    distance11 = adsk.fusion.DistanceExtentDefinition.create(
        adsk.core.ValueInput.createByReal((grooveCenter + .05) * -1))
    distance11A = adsk.fusion.DistanceExtentDefinition.create(
        adsk.core.ValueInput.createByReal(grooveCenter - .05))
    deg0 = adsk.core.ValueInput.createByString("0 deg")
    stemGrooveExtInput.setTwoSidesExtent(distance11, distance11A, deg0, deg0)
    stemGrooveExtInput.participantBodies = [stemExt.bodies.item(0)]
    stemGrooveExt = extrudes.add(stemGrooveExtInput)
    # Change to inches in Parameters
    extent_11A = stemGrooveExt.extentOne
    extent_11B = stemGrooveExt.extentTwo
    distanceMP_11A = extent_11A.distance
    distanceMP_11B = extent_11B.distance
    distanceMP_11A.expression = "{:.{}f}".format((((grooveCenter + .05) * -1) / sizeUnits), 4) + 'in'
    distanceMP_11B.expression = "{:.{}f}".format(((grooveCenter + .05) / sizeUnits), 4) + 'in'
    stemGrooveExt.name = 'Stem Groove'

    # Create body with combine
    plugBody = plugExt.bodies[0]
    bodyCollection = adsk.core.ObjectCollection.create()
    bodyCollection.add(plugStraightExt.bodies[0])
    bodyCollection.add(hexExt.bodies[0])
    bodyCollection.add(stemExt.bodies[0])
    model = design.activeComponent
    features = model.features
    combineFeat = features.combineFeatures
    combineInput = combineFeat.createInput(plugBody, bodyCollection)
    combineFeatur = combineFeat.add(combineInput)

    # Create the chamfer
    edgeCol = adsk.core.ObjectCollection.create()
    edgeCol.clear()
    edges = stemExt.sideFaces.item(0).edges
    for edgeI in edges:
        edgeCol.add(edgeI)

    chamferFeats = newComp.features.chamferFeatures
    chamferInput = chamferFeats.createInput(edgeCol, True)
    chamferInput.setToEqualDistance(
        adsk.core.ValueInput.createByReal((numStemDiam - numHoleThru)/4))
    chamferFeats.add(chamferInput)
Brad Bylls
Message 5 of 9
brad.bylls
in reply to: BrianEkins

 

 # Create the stem
    stemSketch = sketches.addWithoutEdges(xyPlane)
    center = stemSketch.modelToSketchSpace(clickPoint)
    stemCircle = stemSketch.sketchCurves.sketchCircles.addByCenterRadius(center, numStemDiam/2)
    stemSketch.sketchDimensions.addDiameterDimension(stemCircle, adsk.core.Point3D.create(1, 0, 0))
    stemSketch.name = 'Stem Diameter Sketch'
    stemProf = stemSketch.profiles[0]
    stemExtInput = extrudes.createInput(stemProf, adsk.fusion.FeatureOperations.NewBodyFeatureOperation)
    distance3 = adsk.core.ValueInput.createByReal(numStemLen + numHexLen + numThreadStraight)
    stemExtInput.setDistanceExtent(False, distance3)
    stemExt = extrudes.add(stemExtInput)
    # Change to inches in Parameters
    extent_3 = stemExt.extentOne
    distanceMP_3 = extent_3.distance
    distanceMP_3.expression = "{:.{}f}".format(((numStemLen + numHexLen + numThreadStraight) / sizeUnits), 4) + 'in'
    # Add the name
    stemExt.name = 'Stem length from face'

    # Create the oil groove
    stemGrooveSketch = sketches.addWithoutEdges(xyPlane)
    stemGrooveCircle = stemGrooveSketch.sketchCurves.sketchCircles.addByCenterRadius(
        center, (numStemDiam + .1) / 2)
    stemGrooveCircle1 = stemGrooveSketch.sketchCurves.sketchCircles.addByCenterRadius(
        center, (numStemDiam-(numStemDiam - numHoleThru)/2) / 2)
    stemGrooveSketch.sketchDimensions.addDiameterDimension(stemGrooveCircle, adsk.core.Point3D.create(1, 1, 0))
    stemGrooveSketch.name = 'Stem Groove Sketch'
    stemGrooveProf = stemGrooveSketch.profiles[0]
    stemGrooveExtInput = extrudes.createInput(stemGrooveProf, adsk.fusion.FeatureOperations.CutFeatureOperation)
    grooveCenter = (numThreadStraight + numHexLen + (numStemLen / 2)) * -1
    distance11 = adsk.fusion.DistanceExtentDefinition.create(
        adsk.core.ValueInput.createByReal((grooveCenter + .05) * -1))
    distance11A = adsk.fusion.DistanceExtentDefinition.create(
        adsk.core.ValueInput.createByReal(grooveCenter - .05))
    deg0 = adsk.core.ValueInput.createByString("0 deg")
    stemGrooveExtInput.setTwoSidesExtent(distance11, distance11A, deg0, deg0)
    stemGrooveExtInput.participantBodies = [stemExt.bodies.item(0)]
    stemGrooveExt = extrudes.add(stemGrooveExtInput)
    # Change to inches in Parameters
    extent_11A = stemGrooveExt.extentOne
    extent_11B = stemGrooveExt.extentTwo
    distanceMP_11A = extent_11A.distance
    distanceMP_11B = extent_11B.distance
    distanceMP_11A.expression = "{:.{}f}".format((((grooveCenter + .05) * -1) / sizeUnits), 4) + 'in'
    distanceMP_11B.expression = "{:.{}f}".format(((grooveCenter + .05) / sizeUnits), 4) + 'in'
    stemGrooveExt.name = 'Stem Groove'

    # Create body with combine
    plugBody = plugExt.bodies[0]
    bodyCollection = adsk.core.ObjectCollection.create()
    bodyCollection.add(plugStraightExt.bodies[0])
    bodyCollection.add(hexExt.bodies[0])
    bodyCollection.add(stemExt.bodies[0])
    model = design.activeComponent
    features = model.features
    combineFeat = features.combineFeatures
    combineInput = combineFeat.createInput(plugBody, bodyCollection)
    combineFeatur = combineFeat.add(combineInput)

    # Create the chamfer
    edgeCol = adsk.core.ObjectCollection.create()
    edgeCol.clear()
    edges = stemExt.sideFaces.item(0).edges
    for edgeI in edges:
        edgeCol.add(edgeI)

    chamferFeats = newComp.features.chamferFeatures
    chamferInput = chamferFeats.createInput(edgeCol, True)
    chamferInput.setToEqualDistance(
        adsk.core.ValueInput.createByReal((numStemDiam - numHoleThru)/4))
    chamferFeats.add(chamferInput)

 

Brad Bylls
Message 6 of 9
BrianEkins
in reply to: brad.bylls

This is still missing information needed to construct the model. Either an existing f3d or a full program will be best.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 7 of 9

@Jorge_Jaramillo - this post is being edited to remove PII.

 

Hi,

 

I believe your problem is after your combine the bodies into a single one under plugBody in this section:

wtallerdemadera_0-1691522881915.png

 

Once you combine the bodies, including there the body that produced the stemExt feature, the stemExt doesn't contain side faces anymore because they become BRebFaces on the new body.

 

So, I think you have two options:

1. Make the chamfer before the combine feature, or

2. Look for the edges in the combined body to make the chamfer.

 

I hope this could solve your problem.

 

Best regards,

Jorge Jaramillo

 

Message 8 of 9

I moved it up before the combined feature and now it works great.
Thanks.
Brad Bylls
Message 9 of 9

Moved it up before the combined feature and it works great.
Thanks.
Brad Bylls

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report