Notifications
Clear all

[Closed] how to save object self,in Attributes?

if use

TestAtt = Attributes “TestAtt”
(
Parameters Main
(
thisNode Type:#Node
)
)
TheBox = Box()

CustAttributes.Add TheBox TestAtt
TheBox.Testatt.ThisNode = TheBox

then

– Runtime error: Assignment failed, possible dependency loop,

3 Replies

Not sure if there’s a way to set #node directly to itself but you could always use weak references:


  TestAtt = Attributes "TestAtt"
  (
  	Parameters Main
  	(
  		thisNode Type:#maxObject
  	)
  )
  TheBox = Box()
  
  CustAttributes.Add TheBox TestAtt
  TheBox.Testatt.thisNode = (nodeTransformMonitor node:theBox)

Access it by:

TheBox.testAtt.thisNode.node

Maybe someone else has a solution with #node

very thanks

 JHN

AFAIK #maxObject with weakreference is the only and the best way, without creating circular dependencies.

-Johan