I have some problem about ( Illigal self-refrence in controller script ) in a script controller.
I’ve searched and one of the suggesting solution was using nodeTransformMonitor to avoid this. don’t know maybe i do all wrong or what i’m looking for is sth else so i do my best to show what i’m looking for with an example.
I’m looking for " Releative transform " but in a script controller.
Here the Releative transform but in script window
A= teapot name:"parent" wirecolor:[255,84,0] radius:10 B= Box name:"child" height:5 width:5 length:5 wirecolor:[888,144,225] pos:[15,0,12] --here the releative transform --Keep the offset transform from teapot reTrans = B.transform * inverse A.transform --testing A.rotation = EulerAngles 0 90 0 B.transform = reTrans * A.transform
it works fine but when i want to use this in a script controller my problem begins .and if i try above script in script controller i’ll face Illigal cycle or “Illigal self-refrence in controller script”.
what is my problem when using weak refrence or nodtransform monitor to overcome this problem. here i go
--get back to the original position A.rotation = EulerAngles 0 0 0 ; B.transform = reTrans * A.transform --add transform script Btransscr = B.Transform.controller = transform_script () -- i use custome attribute in script controller and maxobject tab in parameter block ca = Attributes nodestore ( parameters nodePar ( mycanode type:#maxobject ) ) con = B.transform.controller custAttributes.add con ca con.mycanode = (nodeTransformMonitor node:B forwardTransformChangeMsgs:false) con.mycanode.node --- it turns $Box:child @ [15.000000,0.000000,12.000000] crtrans = (B.transform) as string scrText = " myobjheight = this.mycanode.node.height print myobjheight "+ crtrans Btransscr.script = scrText
it is ok and the script knows the object’s height ,but when i try to get the transform of the box again it complain from Illigal self-refrence in controller script
scrText = " myobjheight = this.mycanode.node.height print myobjheight myobjtrans = this.mycanode.node.transform print myobjtrans "+ crtrans Btransscr.script = scrText
where is my problem even i use type:#maxObjectTab instead of type:#maxobject again the same thing happen the difrence is the first one is in an array form.
or is it possible to do this in script controller?
Thanks in advance