Notifications
Clear all

[Closed] avoiding circular dependencies in script controllers

Hi,

I’m very new to Maxscript and I’m trying to write a position script controller that can somehow compare the current position of BoxA (the object with the script controller) with BoxB and start to move towards BoxB, picking up velocity and then slowing down once it reaches BoxB (this would mean it would move past BoxB while slowing down and then start the whole process again). I’m getting circular dependency issues which I understand, so I guess I’d like to know if there is a work-around. No matter how I try to access the transform, whether through a controller, a track or a node, I get “illegal self reference” errors.

I understand there’s something called weak references, but the few examples I’ve seen of this seem to be written as a larger maxscript, rather than inside a position script. I’d ideally like this to work without having the timeslider move, so that I can transform BoxB about in the viewport and have it update BoxA’s position.

Thanks in advance!

Peter

15 Replies

here is an useful thread about that contain unique ideas:
http://area.autodesk.com/forum/t59881

as for your needs, just focus on “proxy controller” approach.

cheers!

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

http://area.autodesk.com/forum/t59881

kindergarten.
there is nothing helpful about circular dependency.

look mxs help at the NodeTransformMonitor. that can be a solution.

Hi peter

I don’t know if you’ve seen it but there is a topic in the mxs help called “Script Controller – Avoiding Circular Dependency”.

There is a button in the script controller to “add node” which would probably be what you are after.

Outside of this, there are two types used in a parameter block that can store node references. The #node and #maxobject (and #nodetab and #maxobjecttab for arrays of node references). #Maxobject is the type that uses weak referencing, as you have to first create a nodetransformmonitor object and store the node within the .node property. One possible way of using this is that you could define a custom attribute attached to the controller and have a parameter block with the nodes/weak references stored there. I wrote something about this while ago here but there’s probably better examples around by now.

But the built in node access in the script controller is probably enough.

what NodeTransformMonitor give to me is just expensive setup with too limited usage.
its to sad to see such sort of judgement about the rest methods.
sometime you are mystery to me best wishes anyway

While the node button in mxs controller is the right way and should be used,
it’s also basic knowledge for riggers…

mxs_controller uses a limited nodeTM
nodeTransformmonitor itself, has more control than the button inside a script_controller(that creates bidirectionality).

but what KnickKnack, wants is some kind of realTime effect?
and I suppose, that reading object A and B positions, is what creates the loop?

reading it’s own position, does not make sense…

just the pos of the obj the user manipulates,
is all the ref that is needed, + timestamp
because it all depends on the obj being transformed + a lag.
with that you have a vector and distance,
that’s it.

or someone explain me why threads like this confuse me so much :]

Another way to do it is to put script controller on 3rd object.
For example dummy that will have script controller on one of its tracks.
And then this controller will be able to change position of object A relative to object B without being dependent on object A.

But make sure to do it with “with animate off” context otherwise it will create keyframes on object A.

i suggested to read mxs help about NodeTransformMonitor because only this article explains well how weak referencing works.

about kindergarten… in this post people are discussing of possible using at time context in script controller. I called it kindergarten. Why do you think every script controller variable has a tick offset value?

5 Replies
(@denist)
Joined: 11 months ago

Posts: 0
(@panayot)
Joined: 11 months ago

Posts: 0

sounds interesting… i’ll check this one later on, and after testing the code, if the memory leaks are so accumulative, will made some revision of my habits (:

but not see the connection btw “self-refs” (circular dependency) and leaks you made here?..
and what i see is that you make a whole thread against me:
http://forums.cgsociety.org/showthread.php?f=98&t=1032312
thanks for that reaction!

also hope your first sentence in other thread has not pointer to me:
some people think that using of node (addnode method) in a script controller solves a problem of circular dependency

not ever sure what you ever mean with that introductory words

(@panayot)
Joined: 11 months ago

Posts: 0

if i ever need to reply on this one?!
pleace re-read my 1st post here + the area-forum thread.

or just to save your time –

2 methods discussed there & i pointing KnickKnack to “proxy controller” (my own terminology) and its a enough popular approach.

also animating is more beyond base node transforms, whether i can use NTM for everything?..

as about if ‘at time’ deserve “kindergarten” reaction …
i know what ‘tick offset’ do but are we talk for the same things?
i used this context to avoid “self-refs” (circular dependency).

(@denist)
Joined: 11 months ago

Posts: 0

I was in bad mood yesterday. I’m presenting my apologies. Peace?

(@panayot)
Joined: 11 months ago

Posts: 0

do not worry, i understand you

this thread is more against myself… read my last posts.
i don’t care too much about circular dependency. my problem is MANY-MANY-MANY… times calling (updating) of script controllers. and i don’t have good solution to avoid it.
that was the reason for me to open the discussion in new thread.

1 Reply
(@panayot)
Joined: 11 months ago

Posts: 0

aha, ok, i see

Thanks for all your replies guys, I ended up using a script controller in another track (scale) and that worked fine for my purposes.

thanks again for your help!