[Closed] Circular Dependency
Hi
I have searched the forum thoroughly on the subject of circular dependencies, but haven’t found any decent solution. My problem is quite simple: In a scene an object has two custom attributes that are supposed to work together, but if i try to assign the values to tracks inside of a float script i get the circular dependency error. No clue why or how to get rid of it.
This topic might have hold a solution but the link to Paul Neales zip file with the promising name “circulardependencysolved” is broken
David
Hi David,
you might like to look into using weak references in your script controllers. there is a fair bit of info about this but here are a few –
in MXS help –
Using Script Controllers/Referencing Nodes and Controllers in Script Controllers
paul neale’s site –
http://www.paulneale.com/tutorials/Scripting/weakReferences/weakReferences.htm
and a bit on mine (done after what I learned on pauls site!) –
http://www.lonerobot.com/NodeVisibility.html
if this doesn’t help, try posting an example so that we can see what’s going on.
Hi LoneRobot
I don’t quite get how to work with weakreferences (the whole concept is a mystery to me). But i guess they might be the solution. only how…
I am working on setup that bobo helped me with here. My goal was to have a custom attribute that can either be typed in or driven by a script. Bobo advised me to use a float list with two seperate controllers, a bezier float and a float script. The weights of both can then be animated.
I managed to do this alright, only that the boolean that does the switching is inside the same attribute holder and 3dsmax doesn’t approve of that. If i use wire parameters it works to some degree (I have to update the wiring each time i load the scene), but using a float script doesn’t work at all.
I have attached an image, but I’m not sure it is easy to understand. It is part of a stereoscopic camera setup (based on lois marceauxs excellent tutorials). the boolean “suggested” is supposed to switch the values from cam_dist between manual numbers and the advised 1/30 of distance to target. Although these settings work i would really like to get rid of the hassle to update the wiring when opening the scene (I always get the message: runtime error: illegal self reference in controller script).
Instead of using Track use Controller and then use theVariable.value in the script. This might get around that. What is your exact setup?
Hi David,
I think i understand a bit better what you’re trying to do. I’m not sure why you have to update wiring each time you open max, that doesn’t sound right to me. Could you re-attach the image?, im not seeing it here.
oh i might have actually forgotten to upload the image. here it comes.
hi david, thanks for that. From what I can see in your image, you have two controllers, weighted between each other, but you want them to act in an on/off sort of way, so that you can either have the scripted distance, or the distance from the attribute. is that right?
The issue is potentially coming from whatever you are doing in the event handler of the checkbox, or the way you have wired it up. I’m thinking that if it was wired correctly, you wouldn’t need to keep doing it. Also, you need a boolean parameter in the attribute parameter block, this will allow you to wire this parameter to the result correctly. This is the section of the attribute marked “parameters” at the start.
Yes, this is exactly what I’m trying to do.
I don’t have any event handler with the checkbox. I created the custom attributes entirely with the parameter editor.
After your last post I thought using a script to create custom attributes would help, but the problem reappeared. this is what i used:
ca = attributes cam
(
parameters cam_params rollout:rl_cam
(
fov type:#angle ui:(sp_fov)
focus type:#worldunits ui:(sp_focus)
cam_dist type:#worldunits ui:(sp_cam_dist)
best type:#boolean ui:(cb_best)
)
rollout rl_cam "camera settings"
(
spinner sp_fov "fov" range:[0,170,45] fieldwith:70
spinner sp_focus "focus" range:[0,100000,300] fieldwidth:80
spinner sp_cam_dist "cam dist" range:[0,100000,0] fieldwidth:80
checkbox cb_best "best" align:#right
)
)
custattributes.add $.modifiers[1] ca
I then assigned a float list manually to the cam_dist parameter, with a bezier_float and a float_script as elements of the list. After that i assigned a float_script to the weights and tried getting the boolean value “best” as a track variable inside the script. But as soon as i did that i got the circular depency error again.
Would it be possible to create the list etc. inside the ca definition and then a change event for the checkbox? Would that solve the problem? Or is it time to use weak references, whatever they are?
I really appreciate the help i get from you.
David
It’s not the CA that is causing the circular dependency. Paul answered it earlier in the post. instead of using ‘assign track’, use ‘assign controller’ and reference the check state as best.value in the script controller.
ok, i guess i managed to solve this thanks to your help. I didn’t understand exactly what PEN meant, but i figured it out. I had to assign a boolean controller to the track and use that controllers value in the script. Kind of a weird workaround, but hey, it worked! I don’t get any error messages anymore and that is great.
thanks again, David