Multi chamfer problems

Multi chamfer problems

brad.bylls
Collaborator Collaborator
1,087 Views
8 Replies
Message 1 of 9

Multi chamfer problems

brad.bylls
Collaborator
Collaborator

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
0 Likes
Accepted solutions (2)
1,088 Views
8 Replies
Replies (8)
Message 2 of 9

BrianEkins
Mentor
Mentor

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
0 Likes
Message 3 of 9

Jorge_Jaramillo
Collaborator
Collaborator

@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

 

0 Likes
Message 4 of 9

brad.bylls
Collaborator
Collaborator
 # 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
0 Likes
Message 5 of 9

brad.bylls
Collaborator
Collaborator

 

 # 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
0 Likes
Message 6 of 9

BrianEkins
Mentor
Mentor

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
0 Likes
Message 7 of 9

Jorge_Jaramillo
Collaborator
Collaborator
Accepted solution

@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

brad.bylls
Collaborator
Collaborator
Accepted solution
I moved it up before the combined feature and now it works great.
Thanks.
Brad Bylls
0 Likes
Message 9 of 9

brad.bylls
Collaborator
Collaborator
Moved it up before the combined feature and it works great.
Thanks.
Brad Bylls
0 Likes