I'm trying to write a custom feature based on the CustomPocket example.
The goal is to make something like the hole tool but to make pockets for heated threaded inserts in 3d prints.
I'm to the point where I just can't understand the geometry. Here are some screen snapshots In the code I'm doing the combine as a join so that the insert body is visible. Once I get this straigened out it will be a cut.
The first screen shot is an isometric. view showing the selected point and the generated body{

Then we have a front view showing that the body is too hing and to the left.

Finally a top viww showing that the body is too far forward:

This is the function to generate the tool body. I've also attache the whole extension directory as a zip file.
@prainsberry wrote:
Fusion 360 Custom Feature API
With the release of Fusion 360 today, we are very excited to announce the availability of a preview of the new Custom Feature API. This is a long-awaited capability for the Fusion 360 API and our first iteration is now available. Please note we are considering this “Preview” functionality as there are some limitations and only some specific workflows that we support. That said this a MAJOR enhancement to the Fusion 360 API.
You can now not only define a custom command dialog for your add-in, but you can actually define it as a full feature definition. This means that parametric timeline updates, model parameter changes and user edits will all now behave as expected for any other feature in Fusion 360. There is a lot of information to digest for this one, so if this interests you, check out our help documentation and learn more about this functionality.
We would love to hear more about how you would like to use it, what you have built, or would like to build. We would like to use this thread to capture feedback about the current capabilities, as well as what you would like to see next.
# Utility function that given the position and pocket size builds
# a temporary B-Rep body is the tool body to create the pocket.
def CreateThreadedInsertBody(point, a, b, c, d😞
try:
# Get the face the point is on.
face: adsk.fusion.BRepFace = GetFaceUnderPoint(point)
if face is None:
return None
# Define the pocket at the origin with the length in the X direction,
# width in the Y direction, and d in the -Z direction.
tBRep: adsk.fusion.TemporaryBRepManager = adsk.fusion.TemporaryBRepManager.get()
lengthDir = adsk.core.Vector3D.create(1, 0, 0)
widthDir = adsk.core.Vector3D.create(0, 1, 0)
bodies = []
aRadius = a / 2.0
bRadius = b / 2.0
# X is 44.762 too high
# Y is 27.622 too high
# Z is 44.925 off
coneNadirPoint = adsk.core.Point3D.create(point.x, point.y, point.z - c)
nadirPoint = adsk.core.Point3D.create(point.x, point.y, point.z - d)
cone = tBRep.createCylinderOrCone(
point,
aRadius,
coneNadirPoint,
bRadius)
cylinder = tBRep.createCylinderOrCone(
coneNadirPoint,
bRadius,
nadirPoint,
bRadius)
bodies.append(cone)
bodies.append(cylinder)
# Combine the bodies into a single body.
newBody: adsk.fusion.BRepBody = None
for body in bodies:
if newBody is None:
newBody = body
else:
tBRep.booleanOperation(newBody, body, adsk.fusion.BooleanTypes.UnionBooleanType)
# Get the natural U direction and normal of the face and use them as the length and d directions.
eval = face.evaluator
(_, param) = eval.getParameterAtPoint(point)
(_, normal) = eval.getNormalAtParameter(param)
(_, lengthDir, _) = eval.getFirstDerivative(param)
widthDir = normal.crossProduct(lengthDir)
# Define a transform to position the pocket body onto the part.
trans = adsk.core.Matrix3D.create()
trans.setWithCoordinateSystem(point, lengthDir, widthDir, normal)
tBRep.transform(newBody, trans)
return newBody
except:
showMessage('CreateThreadedInsertBody: {}\n'.format(traceback.format_exc()))