Message 1 of 8
Possible Error in Mesh Normal Vectors?

Not applicable
03-11-2021
05:35 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Currently trying to get access to the normal vectors from a mesh in fusion, but getting a strange error that I haven't seen before. As I can figure, there are two ways to access a mesh from a MeshBody object: displayMesh and mesh. Display mesh seems more limited and can only seem to produce normal vectors for the nodes of the mesh (?) so that won't work. But when I try to grab the vector objects from mesh.normalVectors I get an internal validation error. I have posted the code below along with a test script that prints out the normal vector arrays. Also this was a box made in Fusion and exported as an STL.
Any thoughts?
#Author-
#Description-
import adsk.core, adsk.fusion, adsk.cam, traceback
def run(context):
ui = None
try:
app = adsk.core.Application.get()
ui = app.userInterface
product = app.activeProduct
design = adsk.fusion.Design.cast(product)
rootComp = design.rootComponent
meshB = rootComp.meshBodies.item(0)
polyMesh = meshB.mesh
triMesh = meshB.displayMesh
#direct tri mesh works
print(triMesh.normalVectors)
print(triMesh.normalVectorsAsDouble)
# "poly"mesh normals works but produces very strange numbers
print(polyMesh.normalVectorsAsDouble)
#either of these throw an internal validation error
#print(polyMesh.normalVectorsAsFloat)
print(polyMesh.normalVectors)
except:
if ui:
ui.messageBox('Failed:\n{}'.format(traceback.format_exc()))