Possible Error in Mesh Normal Vectors?

Possible Error in Mesh Normal Vectors?

Anonymous
Not applicable
964 Views
7 Replies
Message 1 of 8

Possible Error in Mesh Normal Vectors?

Anonymous
Not applicable

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?

Capture.PNG

 

 

#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()))

 

 

0 Likes
965 Views
7 Replies
  • Mesh
Replies (7)
Message 2 of 8

kandennti
Mentor
Mentor

Hi @Anonymous .

 

I tried it with the attached data and there was no error.
win10  Fusion360 Ver2.0.9854

0 Likes
Message 3 of 8

Anonymous
Not applicable

@kandennti thanks for giving it a go. Looks like it is a local error then. Can you shed any light on what that error may be in reference too then? I have done a reasonable amount of work with the API but never had an internal validation error before. 

 

In the meantime I will continue troubleshooting on my end.

 

Also, using Win10 and fusion version V.2.0.9854

 

 

0 Likes
Message 4 of 8

BrianEkins
Mentor
Mentor

It would be good to post the f3d file that contains the mesh that demonstrates this problem.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes
Message 5 of 8

Anonymous
Not applicable

@BrianEkins Here is the file

0 Likes
Message 6 of 8

kandennti
Mentor
Mentor

@Anonymous .

 

I'm sorry. I was able to reproduce the error.
I don't know why.

0 Likes
Message 7 of 8

Anonymous
Not applicable

@kandennti Ah! Glad to hear I'm not going crazy. 

0 Likes
Message 8 of 8

BrianEkins
Mentor
Mentor

I'm able to reproduce the problem too.  There's something wrong internally with polygon meshes.  Most meshes are triangular so the polygon and triangle meshes should behave exactly the same.  It's just that all of the polygons will be triangular.  This is especially true with a mesh created by importing STL because STL only supports triangular meshes.

 

Some work needs to be done to fix the API but you should be OK if you just use the triangle mesh objects.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes