Fusion 360 API - mesh object properties return unexpected values

Fusion 360 API - mesh object properties return unexpected values

Anonymous
Not applicable
520 Views
1 Reply
Message 1 of 2

Fusion 360 API - mesh object properties return unexpected values

Anonymous
Not applicable

Hello,

I tried accesing the data of user-selected mesh using the API. According to the API specification, nodeIndices can be used to look up nodeCoordinates of each triangle. Does this mean that the length of nodeIndices and nodeCoordinates should be equal? However, this does not happen in my script. I use the following code to access the data of the mesh body selected by user - I included just the handler for the execute event:

# Event handler for the execute event. 
class SampleCommandExecuteHandler(adsk.core.CommandEventHandler):
    def __init__(self):
        super().__init__()
    def notify(self, args):
        eventArgs = adsk.core.CommandEventArgs.cast(args)

        # Code to react to the event.
        app = adsk.core.Application.get()
        ui  = app.userInterface
        
        product = app.activeProduct
        design = adsk.fusion.Design.cast(product)
        # Get the root component of the active design.
        rootComp = design.rootComponent
        # Get the values from the command inputs. 
        inputs = eventArgs.command.commandInputs
        # Assign the selected body to mb variable
        mb :adsk.fusion.MeshBody = inputs.itemById('msh').selection(0).entity
        msh = mb.displayMesh.nodeCoordinates
        dbl = mb.displayMesh.nodeCoordinatesAsDouble
        flt = mb.displayMesh.nodeCoordinatesAsFloat
        ind = mb.displayMesh.nodeIndices
        print("ind length: " + str(len(ind)) + "msh length: " + str(len(msh)) + " no of nodes: " + str(noNodes))
        print("flt length: " + str(len(flt)) + "dbl length: " + str(len(dbl)))

The output of this code is:

ind length: 29094

msh length: 4896

no of nodes: 29094

flt length: 14688

dbl length: 14688

 

I would appreciate any support to identify why the ind and msh arrays are not the same length - whether I do not understand these properties correctly or are they implemented incorrectly. Thank you in advance for any help.

0 Likes
521 Views
1 Reply
Reply (1)
Message 2 of 2

BrianEkins
Mentor
Mentor

The number of node indices and node coordinates does not have to be equal.  A simple example is if you have a rectangular plane.  It would be drawn using two triangles, which means there would be 6 indices.  However, there are only 4 points needed.  Two of the points will be used for both triangles.  For example, if the point list is 0, 1, 2, and 3 and the index list would be 0, 1, 2, 0, 2, 3.

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