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: 

How to use the mesh repair comand in the API

1 REPLY 1
Reply
Message 1 of 2
joao.araujoDNTFK
274 Views, 1 Reply

How to use the mesh repair comand in the API

I need to use the mesh repair feature in the API and change the repair type (Wrap, Stich and remove, rebuild); is there anyway to do it? 

1 REPLY 1
Message 2 of 2

Hi @joao.araujoDNTFK .

 

I don't think the mesh repair command is provided in the API, but I made a sample using a text command.

# Fusion360API Python script

import traceback
import adsk.core as core

def run(context):
    ui = core.UserInterface.cast(None)
    try:
        app: core.Application = core.Application.get()
        ui = app.userInterface

        msg: str = 'Select MeshBody'
        selFilter: str = 'MeshBodies'
        sel: core.Selection = selectEnt(msg, selFilter)
        if not sel:
            return

        exec_mesh_repair('Wrap')

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


def exec_mesh_repair(
    repairType: str):

    repairTypeDict = {
        'Close Holes': 'infoTypeSimple',
        'Stitch and Remove': 'infoTypeDefault',
        'Wrap': 'infoTypeExtended',
        'Rebuild': 'infoTypeMakeSolid',
    }

    if not repairType in repairTypeDict.keys():
        return

    app: core.Application = core.Application.get()

    app.executeTextCommand(u'Commands.Start ParaMeshRepairCommand')
    app.executeTextCommand(u'Commands.SetString infoRepairType {}'.format(repairTypeDict[repairType]))
    app.executeTextCommand(u'NuCommands.CommitCmd')


def selectEnt(
        msg: str,
        filterStr: str) -> core.Selection:

    try:
        app: core.Application = core.Application.get()
        ui: core.UserInterface = app.userInterface
        sel = ui.selectEntity(msg, filterStr)
        return sel
    except:
        return None

 

For more information about text commands, please read here.

https://forums.autodesk.com/t5/fusion-360-api-and-scripts/use-textcommands/m-p/9645688 

https://forums.autodesk.com/t5/fusion-360-api-and-scripts/use-textcommands2/m-p/9937161 

 

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

Post to forums  

Autodesk Design & Make Report