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 combine cut comand in the API

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

How to use the mesh combine cut comand in the API

I need to use the mesh combine feature in the API and change de combine type (cut, intersect, join); is there anyway to do it? 

 
1 REPLY 1
Message 2 of 2

Hi @joao.araujoDNTFK .

 

As I think I mentioned before, I don't think the API provides mesh functionality.
Therefore, there seems to be no other way than to use text commands.
I have created a sample.

# Fusion360API Python script

import traceback
import adsk.core as core
import adsk.fusion as fusion

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

        exec_mesh_combine(
            'Join',
            root.meshBodies[0],
            root.meshBodies[1],
        )

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


def exec_mesh_combine(
    combineType: str,
    targetBody: fusion.MeshBody,
    toolBody: fusion.MeshBody,
) -> None:
    '''
    combineType: 'Join','Intersect','Cut','Merge'
    '''

    combineTypeDict = {
        'Join': 'infoTypeUnify',
        'Intersect': 'infoTypeIntersect',
        'Cut': 'infoTypeSubstract',
        'Merge': 'infoTypeMerge',
    }

    if not combineType in combineTypeDict.keys():
        return

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

    sels: core.Selections = app.userInterface.activeSelections
    sels.clear()
    sels.add(targetBody)
    sels.add(toolBody)

    app.executeTextCommand(u'Commands.Start ParaMeshCombineCommand')
    app.executeTextCommand(u'Commands.SetString infoType {}'.format(combineTypeDict[combineType]))
    app.executeTextCommand(u'NuCommands.CommitCmd')

 

Have you tried the previous repair? This sample is almost the same as the repair.

https://forums.autodesk.com/t5/fusion-360-api-and-scripts/how-to-use-the-mesh-repair-comand-in-the-a... 

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

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report