FAQ: What is the difference between PartId and NodeId?

In the Communicator documentation, you may notice that certain functions contain parameters with specific types – for example, the function getNodeLineColor(partId, lineIndex) takes a PartId as a parameter.

But Communicator is, for many users, a JavaScript API, so why are there types listed in the documentation?

The object types found in parameters and return values in the Communicator API Reference documentation are extracted from strongly typed objects in Communicator’s TypeScript source. Communicator’s Web Viewer API is available in both TypeScript and JavaScript.

In JavaScript, both the PartId and NodeId translate to a JavaScript Number object.

Use Case

Let us say you pass the returned value from myViewerInstance.selectionManager.getFirst().getNodeId() (a NodeId) as the first parameter for getNodeLineColor(partId, lineIndex).The Communicator API defines PartId as a type of NodeId so there would be no type compatibility issue in this scenario.

In terms of API behavior for both TypeScript and JavaScript users, as long as the NodeType of the Node in question is indeed a Part (and not a PMI, CADView, Sheet, or other NodeType), then the function will behave as expected.

To query a Node to find out its type, call getNodeType().