Message 1 of 4
How to create threaded hole feature
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am trying to create a custom threaded hole feature. Here is what I have so far.
It successfully creates the hole feature, but I can't figure out the API to add a thread to the hole. In general ThreadFeature doesn't seem very well documented.
I get an Exception at the last line below:
def command_created(args: adsk.core.CommandCreatedEventArgs):
inputs = args.command.commandInputs
inputs.addSelectionInput("point_selection", "Select Points", "Select points")
point_selection: adsk.core.SelectionCommandInput = inputs.itemById(
"point_selection"
)
point_selection.addSelectionFilter("SketchPoints")
point_selection.setSelectionLimits(1, 0)
futil.add_handler(
args.command.execute, command_execute, local_handlers=local_handlers
)
def command_execute(args: adsk.core.CommandEventArgs):
inputs = args.command.commandInputs
point_selection: adsk.core.SelectionCommandInput = inputs.itemById(
"point_selection"
)
product = app.activeProduct
design = adsk.fusion.Design.cast(product)
rootComp = design.rootComponent
holeFeatures = rootComp.features.holeFeatures
holeInput = holeFeatures.createCounterboreInput(
adsk.core.ValueInput.createByString("8.526 mm"),
adsk.core.ValueInput.createByString("16 mm"),
adsk.core.ValueInput.createByString("6 mm"),
)
holeInput.setDistanceExtent(
adsk.core.ValueInput.createByString("28 mm"),
)
pointCollection = adsk.core.ObjectCollection.create()
for p in range(point_selection.selectionCount):
pointCollection.add(point_selection.selection(p).entity)
holeInput.setPositionBySketchPoints(pointCollection)
holeFeature = holeFeatures.add(holeInput)
# All above is working
threadFeatures = rootComp.features.threadFeatures
threadType = "ISO Metric profile"
threadClass = "6H"
threadDesignation = "M10x1.5"
holeFaces = adsk.core.ObjectCollection.create()
for h in range(holeFeature.sideFaces.count):
holeFaces.add(holeFeature.sideFaces.item(h))
if holeFaces.count > 0:
threadInfo = threadFeatures.createThreadInfo(
True, threadType, threadDesignation, threadClass
)
threadInput = threadFeatures.createInput(holeFaces, threadInfo)
threadInput.isModeled = False
threadFeature = threadFeatures.add(threadInput)#This line raises an Exception
# RuntimeError: 2 : InternalValidationError : Xl::Utils::getObjectPath(item.get(), facePath, nullptr, contextPath)
FWIW, i'm trying to make the following counterbored threaded hole for Lang quick-point studs
And this is the end result I would like:
Instagram:
@sonsofsormaz
@sonsofsormaz