Key of a Node

How to find a key of a node?

In my project I have two similar nodes of diagram. There are some attributes associated to these two nodes but there values are different. Somehow I want to know the key associated to these nodes, so that I can set the attributes values based on that.

Please let me know

or maybe just

A piece of code would be more helpful.

Please share if possible.

I did: “”, assuming “node” evaluates to the Node that you care about.

I found the key using the following code.

var object = elem.findObject(“SHAPE”); //where SHAPE is name of any selected node.
var key =;

Thanks Walter for giving me the hint.

If “elem” is a selected Node, then “” would get you the node’s key.

Searching the visual tree of the Node for a particular GraphObject named “SHAPE” and then walking back up the visual tree by getting its “.part” is unnecessary. And it might fail if there is no object named “SHAPE”.