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 can merge faces in same body?

1 REPLY 1
SOLVED
Reply
Message 1 of 2
ho-kou
189 Views, 1 Reply

how can merge faces in same body?

ho-kou
Advocate
Advocate

Hi, everyone

 

I want use merge to join same faces in the same body.

But i can not find the api to do it.

Who konw the merge api like the picture.

Thank you for your help.

 

hokou_0-1712110450176.png

 

0 Likes

how can merge faces in same body?

Hi, everyone

 

I want use merge to join same faces in the same body.

But i can not find the api to do it.

Who konw the merge api like the picture.

Thank you for your help.

 

hokou_0-1712110450176.png

 

1 REPLY 1
Message 2 of 2
kandennti
in reply to: ho-kou

kandennti
Mentor
Mentor
Accepted solution

Hi @ho-kou -San.

 

Since merge commands do not seem to be provided by the API, this sample uses text commands.

# Fusion360API Python script

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

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

        des: fusion.Design = app.activeProduct
        if des.designType == fusion.DesignTypes.ParametricDesignType:
            ui.messageBox("Valid only in direct mode.")
            return

        root: fusion.Component = des.rootComponent

        exec_surface_merge_command(root.bRepBodies[0])

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

def exec_surface_merge_command(
        body: fusion.BRepBody
) -> None:
    
    app: core.Application = core.Application.get()
    ui: core.UserInterface = app.userInterface
    sels: core.Selections = ui.activeSelections

    [sels.add(f) for f in body.faces]

    app.executeTextCommand(u"Commands.Start FusionSurfaceMergeCommand")
    app.executeTextCommand(u'NuCommands.CommitCmd')

1.png


In the GUI, the merge command is only available in direct mode, but when I tried it, it worked in parametric mode as well.
However, since nothing appears on the timeline, we felt that this might cause problems, so the sample works only in direct mode.

1 Like

Hi @ho-kou -San.

 

Since merge commands do not seem to be provided by the API, this sample uses text commands.

# Fusion360API Python script

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

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

        des: fusion.Design = app.activeProduct
        if des.designType == fusion.DesignTypes.ParametricDesignType:
            ui.messageBox("Valid only in direct mode.")
            return

        root: fusion.Component = des.rootComponent

        exec_surface_merge_command(root.bRepBodies[0])

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

def exec_surface_merge_command(
        body: fusion.BRepBody
) -> None:
    
    app: core.Application = core.Application.get()
    ui: core.UserInterface = app.userInterface
    sels: core.Selections = ui.activeSelections

    [sels.add(f) for f in body.faces]

    app.executeTextCommand(u"Commands.Start FusionSurfaceMergeCommand")
    app.executeTextCommand(u'NuCommands.CommitCmd')

1.png


In the GUI, the merge command is only available in direct mode, but when I tried it, it worked in parametric mode as well.
However, since nothing appears on the timeline, we felt that this might cause problems, so the sample works only in direct mode.

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

Post to forums  

Autodesk Design & Make Report