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: 

Whether the adjacency between BRep entities, and uvgrid features can be obtained.

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
2544173825
143 Views, 2 Replies

Whether the adjacency between BRep entities, and uvgrid features can be obtained.

Now I've got the bodies of the part by importing the .smt file and I've got numerous features of the part through the Fusion 360 API, but to more accurately represent the geometry and topology of the part, I want to be able to get the uvgrid features and adjacencies of the faces and edges of the part using the Fusion 360 API, similar to uvgrid and face adjacency function.

2 REPLIES 2
Message 2 of 3
kandennti
in reply to: 2544173825

Hi @2544173825 .

 

I don't understand uvgrid, but I took it as simply getting adjacent surfaces.

 

I think you are supposed to use the BRepCoEdge object for the adjacency.

https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-1C3FFADB-52C4-49BB-8981-4A448FFE4442 

It is probably a graph structure.

 

If you just want to get adjacent faces, you can simply use BRepEdge.

I have created a sample script that selects a face, selects the surrounding faces, and terminates.

# Fusion360API Python script

import traceback
import adsk.fusion
import adsk.core

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

        # select face
        msg: str = 'Select'
        selFilter: str = 'Faces'
        sel: adsk.core.Selection = selectEnt(msg, selFilter)
        if not sel:
            return

        selectFace: adsk.fusion.BRepFace = sel.entity

        # get all edges
        edges = [e for e in selectFace.edges]

        # Acquisition of all surfaces sharing an edge
        sharedFaces = []
        [sharedFaces.extend([f for f in edge.faces]) for edge in edges]

        # Remove selected faces
        adjacentFaces = [f for f in sharedFaces if f != selectFace]

        # Forced deselection due to bug not fixed
        forcedClear()

        # Adjacent Surface Selection
        sels: adsk.core.Selections = ui.activeSelections
        [sels.add(f) for f in adjacentFaces]

        ui.messageBox('done')

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

def forcedClear():
    app: adsk.core.Application = adsk.core.Application.get()
    sels: adsk.core.Selections = app.userInterface.activeSelections
    sels.clear()

    if sels.count > 0:
        ents = sels.all
        app.executeTextCommand(u'Commands.Start SelectabilityToggleCmd')
        [sels.add(ent) for ent in ents]
        app.executeTextCommand(u'Commands.Start SelectabilityToggleCmd')
        sels.clear()


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

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

 

The Fusion360 API is very helpful because it builds these just by importing.

Message 3 of 3
2544173825
in reply to: kandennti

thanks

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