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: 

Get Selected Feature Properties From a Thread Feature

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
mike
327 Views, 2 Replies

Get Selected Feature Properties From a Thread Feature

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

Labels (1)
2 REPLIES 2
Message 2 of 3
JeromeBriot
in reply to: mike

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.

 

Message 3 of 3
mike
in reply to: JeromeBriot

Thank you for the assistance, it's much appreciated

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

Post to forums  

Autodesk Design & Make Report