How to determine "Hole Tap Type" from HoleFeature

How to determine "Hole Tap Type" from HoleFeature

kandennti
Mentor Mentor
571 Views
2 Replies
Message 1 of 3

How to determine "Hole Tap Type" from HoleFeature

kandennti
Mentor
Mentor

Hi there.

 

Does anyone know how to determine what the "Hole Tap Type" is set to from the HoleFeature in the timeline?

1.png

0 Likes
Accepted solutions (1)
572 Views
2 Replies
Replies (2)
Message 2 of 3

BrianEkins
Mentor
Mentor
Accepted solution

I thought this was there but I don't see it either. I believe when support for holes was first implemented in the API, Fusion didn't support threaded holes and you had to create a hole and then add a thread feature to the resulting cylinder to get a thread. This should be added to the API.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes
Message 3 of 3

kandennti
Mentor
Mentor

Thanks for the reply @BrianEkins .

 

I tried it and found that "Tapped" is in ThreadFeature.

 

I have created a script in response to an inquiry on the Japanese forum to "turn on/off the modeling of all screws".

# Fusion360API Python script

import traceback
import adsk.fusion
import adsk.core

def run(context):
    ui: adsk.core.UserInterface = None
    try:
        app: adsk.core.Application = adsk.core.Application.get()
        ui = app.userInterface
        des: adsk.fusion.Design = app.activeProduct
        root: adsk.fusion.Component = des.rootComponent
        threads: adsk.fusion.ThreadFeatures = root.features.threadFeatures

        # query
        msg = f'There is{threads.count} modelable screw. '
        msg += f'Do you want to model it all?\n'
        msg += f'Yes:Perform modeling\n'
        msg += f'No:Unmodel\n'
        msg += f'Cancel:Cancel'

        res = ui.messageBox(
            msg,
            'Modeling switch for all screws',
            adsk.core.MessageBoxButtonTypes.YesNoCancelButtonType,
            adsk.core.MessageBoxIconTypes.QuestionIconType
        )

        # exec
        if res == adsk.core.DialogResults.DialogYes:
            execModeled(True)
        elif res == adsk.core.DialogResults.DialogNo:
            execModeled(False)

    except:
        if ui:
            ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))


def execModeled(isModeled: bool):
    app: adsk.core.Application = adsk.core.Application.get()
    ui = app.userInterface
    des: adsk.fusion.Design = app.activeProduct
    root: adsk.fusion.Component = des.rootComponent
    sels: adsk.core.Selections = ui.activeSelections

    tl: adsk.fusion.Timeline = des.timeline
    tlPos = tl.markerPosition

    threads: adsk.fusion.ThreadFeatures = root.features.threadFeatures
    thread: adsk.fusion.ThreadFeature
    for thread in threads:
        timeObj: adsk.fusion.TimelineObject = thread.timelineObject

        if thread.linkedFeatures.count < 1:
            # ThreadFeature
            timeObj.rollTo(True)
            if thread.isModeled != isModeled:
                thread.isModeled = isModeled
        else:
            # HoleFeature
            hole =  adsk.fusion.HoleFeature.cast(thread.linkedFeatures[0])
            if not hole:
                continue
            timeObj.rollTo(False)

            isModeledNumber = 1 if isModeled else 0

            sels.clear()
            sels.add(hole)

            app.executeTextCommand(u'Commands.Start FusionDcHoleEditCommand')
            dialogInfo = app.executeTextCommand(u'Toolkit.cmdDialog')
            if 'infoModeled' in dialogInfo:
                app.executeTextCommand(u'Commands.SetBool infoModeled {}'.format(isModeledNumber))
                app.executeTextCommand(u'NuCommands.CommitCmd')

    tl.markerPosition = tlPos
    sels.clear()

It does not work perfectly, but it works to some extent.

0 Likes