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.