The API help hasn't been updated since last year but there is a newer function available since then that makes this relatively easy. Below is a sample that creates a mesh body from a selected body. The MeshCalculator object supports many settings to let you control how the mesh is generated. The sample uses a property that automatically sets the various settings to get a decent result.
def createMeshFromBRep():
try:
app = adsk.core.Application.get()
ui = app.userInterface
des = adsk.fusion.Design.cast(app.activeProduct)
root = des.rootComponent
brepBodySel = ui.selectEntity('Select the B-Rep body', 'Bodies')
if not brepBodySel:
return
brepBody = adsk.fusion.BRepBody.cast(brepBodySel.entity)
# Get mesh data from the B-Rep body.
meshCalc = brepBody.meshManager.createMeshCalculator()
meshCalc.setQuality(adsk.fusion.TriangleMeshQualityOptions.NormalQualityTriangleMesh)
triangleMesh = meshCalc.calculate()
# Create the mesh body.
meshBody = root.meshBodies.addByTriangleMeshData(triangleMesh.nodeCoordinatesAsDouble, triangleMesh.nodeIndices, triangleMesh.normalVectorsAsDouble, triangleMesh.nodeIndices)
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))
---------------------------------------------------------------
Brian EkinsInventor and Fusion 360 API Expert
Website/Blog:
https://EkinsSolutions.com