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

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

2544173825
Enthusiast Enthusiast
466 Views
2 Replies
Message 1 of 3

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

2544173825
Enthusiast
Enthusiast

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.

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

kandennti
Mentor
Mentor
Accepted solution

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.

0 Likes
Message 3 of 3

2544173825
Enthusiast
Enthusiast

thanks

0 Likes