I'm trying to write a script that will automatically generate a thread undercut for when machining a thread on a lathe.
Is it possible to retrieve the thread properties after the thread feature has been selected in the command window. Such as;
selectionInput = inputs.addSelectionInput(commandId + '_selection', 'Select', 'Select bodies or occurrences')
selectionInput.setSelectionLimits(1)
selectionInput.selectionFilters = ['Features', 'Occurrences']
#Once thread feature has been selected retrieve the thread pitch and thread size e.g Size M6 ; Thread 1mm.
Thank you in advance
Solved! Go to Solution.
Solved by JeromeBriot. Go to Solution.
Hello,
Try this:
import adsk.core, adsk.fusion, traceback
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
try:
selection = ui.selectEntity('Select a thread feature', 'Features')
except:
selection = None
if selection:
threadFeature = selection.entity
ui.messageBox('Thread pitch: {}\nThread size: {}'.format(threadFeature.threadInfo.threadPitch, threadFeature.threadInfo.threadSize))
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
See ThreadFeature object documentation.
Jérôme Briot, Freelance engineer - Mechanical design and prototyping
3D Print Plus / Pro | IDF Import | GitHub To Fusion 360 | Tube Bending Data Exchanger | Slice Data Export
Memory Used | Basic Calculator | Check Computer Specifications | Import spline from any CSV file
Can't find what you're looking for? Ask the community or share your knowledge.