Change in SelectionItem API

Hello,

I noticed that the API changed from version 2023 SP2 U2 to 2024.5.0 for SelectionItem.
When questioning the selection item resulting from a pickFromPoint operation, the method getNodeId() used to return NodeId | null, whereas now we are guaranteed to have a NodeId.

When I test with a pick in the void in the scene, I get a node id of -1.

We used to check for null if nothing was picked, now I’m not sure what the correct way of handling the return is.

A lot of our integration of this does:

if (sel.getNodeId() !== null) {
   ... do something with the node
}

Now this condition will pass even tho I didn’t pick a node.

Help me out please.

Hello @alexis.besner,

So rather than checking if the node id is not null, you can check if the selection type is not Communicator.SelectionType.None:

if (sel.getSelectionType() !== Communicator.SelectionType.None) {
   ... do something with the node
}

Thanks,
Tino

Thanks Tino, will do!

2 Likes