PDA

View Full Version : Controller Type return true?


Gräck
10-12-2007, 02:18 PM
Hi all,

this is a rather easy question I think.

So when I want to assign a specific controller to a selected object, I would go like this, right?

$.position.controller = springpositioncontroller()

That works fine.

Now I want to ask whether this controller is assigned to the selected object or not, so I would go like this:

$.position.controller == springpositioncontroller()

However this always returns false, so I assume it is not the right way to ask for springpositioncontroller(), there has to be another expression, but I just can't find the correct one.

Sorry for this very easy noob question, but I hope someone can help.

eek
10-12-2007, 02:29 PM
Is the object selected when you query it? I'd always use object names or selections not $. You querying an controller with a function ()

$.pos.controller = position_xyz()
$.pos.controller == position_xyz

This should be correct, I do this all the time - just not at max atm.

Gräck
10-12-2007, 02:33 PM
I'm sorry, this doesn't work.

I create a point helper (Position_XYZ is applied by default).
Then I type in $.pos.controller == position_xyz.
This returns false, but actually it should return true.

eek
10-12-2007, 02:41 PM
hmm.. hehe i just got up - im returning false till i get a cup of coffee in me :)

$.pos.controller.controller == position_xyz()
$.pos.controller == position_xyz()

a = bezier_position()
$.pos.controller = a

$.pos.controller == a

$.pos.controller == positionController

Gräck
10-12-2007, 02:48 PM
Ok, so you first assign a variable to the controller, then check if this variable is used. Well, that works fine if you first want to assign a controller, but what if you did not assign the controller via script?

What if I just want to check whether a specific controller type is assigned to an object or not?

Thanks for your help so far.

eek
10-12-2007, 02:56 PM
Ok, so you first assign a variable to the controller, then check if this variable is used. Well, that works fine if you first want to assign a controller, but what if you did not assign the controller via script?

What if I just want to check whether a specific controller type is assigned to an object or not?

Thanks for your help so far.

Thats ok, im gunna head to work - in front of max i'll figure it out in like 2 secs. Meanwhile Mark looking at this post will first laugh, then give you the answer.

marktsang
10-12-2007, 02:56 PM
hola,


$box01.pos.x_position.controller = float_script()
classof $box01.pos.x_position.controller == float_script --- returns true

you have to test against class not against the controller as this would test for instances not controller type

mark

Gräck
10-12-2007, 02:58 PM
Perfect, thanks.

JHN
10-12-2007, 02:59 PM
<strike>You'll need "classof controller" to check controller type.</strike>

Already answered I see :)

-Johan

Bobo
10-12-2007, 05:18 PM
Now I want to ask whether this controller is assigned to the selected object or not, so I would go like this:
$.position.controller == springpositioncontroller()


The reason this returns false is because you are constructing a new instance of a spring position controller on the right side, then asking if that SAME controller is instanced in the position controller track of your object. Since you just constructed it, chances are zero that the existing controller IS that controller.

You can think of instances of a class (as the MAXScript Reference shows in the FAQ) as individuals from the same nation (say, Germans). If you give birth to a German guy (instance of a class called German), you can use classof() to ask if the guy is German, but what you wrote above is asking if a guy is a specific person (say, Michael Schumacher). ;)

Hope this helps understand the logic behind it.

JHN
10-12-2007, 05:31 PM
There's two kind of answers that are both almost right, the answers Bobo gives (these are offcourse always right :bowdown: ) and the answers the rest give, wich will help you but sometimes point to the manual that what's his name co-wrote/write.. :P

Great explanation as ever!

-Johan

CGTalk Moderation
10-12-2007, 05:31 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.