[Closed] Storing node references
I have a scripted plugin that needs to store a reference to another node of the same type.
parameters main rolout:params
(
oppositeControl type:#node
)
I can assign the reference from one object to another:
[font=Courier New] [/font]
$obj01.oppositeControl = $obj02
but when I try to store a reference from the second back to the first I get a dependency loop error:
[font=Courier New][size=2] [/font][/size]
[font=Courier New][size=2][/font][/size]$obj2.oppositeControl = $obj01
-- Runtime error: Assignment failed, possible dependency loop
I did some digging through the docs and found out the cause of the problem.
[font=Courier New]#node and #nodeTab are used to store references to nodes. The nodes stored in these parameters cannot create a circular dependency. If, for example, you were creating a scripted helper, and set the helper as a target or parent of a camera, you can not store the camera node in a #node or #nodeTab parameter.[/font]
What would be the best way to store a reference between two nodes in a way that doesn’t make max panic? I would store the node names as a string an use GetNodeByName, but this could cause some serious problems if anything gets renamed.
Use a maxObjectTab instead and nodeTransformMonitor. Have a look here on my site…
http://www.penproductions.ca/tutorials/Scripting/weakReferences/weakReferences.htm
Interesting. This requires a few extra steps to manage the references, but at least it works without throwing dependency loop errors. Thanks, Paul.
you don’t need maxObjectTab. The maxObject type property is enough. But the nodeTransformMonitor is undoubtedly the key.