PDA

View Full Version : $.rotation.controller.x_rotation.keys not working when accessed via a variable?


WhiteMage
02-14-2009, 03:35 PM
I can access the .keys property like this:
$.rotation.controller.x_rotation.keys

but let's say I do this:
rotContX = $.rotation.controller.x_rotation
rotContX.keys

It does not work. It says: "Unknown property: "keys" in -0.975016"

Is there something here I don't understand?

It's strange because this works:
rotCont = $.rotation.controller
rotCont.keys


thanks,

Piflik
02-14-2009, 03:51 PM
.x_rotation is a numerical number (float) and not a controller, thus not keyable.

Use .x_rotation.controller

That should work...(no guaranties though)

Edit:

Also, .rotation.controller.x_rotation looks a bit strange to me.

.rotation.x_rotation.controller is the correct order methinks

WhiteMage
02-14-2009, 04:12 PM
thanks, it works. But which one should I use? It's getting confusing, both of these works:

$.rotation.controller.x_rotation.controller.keys
$.rotation.x_rotation.controller.keys

I'm not exactly sure of the difference between both

Piflik
02-14-2009, 04:37 PM
I'm not sure either, but if both work take the shorter one :D

WhiteMage
02-14-2009, 09:55 PM
I will ;)

Still, if someone knows what the difference between

$.rotation.controller.x_rotation.controller.keys
and
$.rotation.x_rotation.controller.keys

is, I'd like to know! Thanks

WhiteMage
02-15-2009, 01:10 AM
This is a much bigger problem than I thought...

My problem is the variable gets evaluated BEFORE evaluating it WITH its property.

Another example of this is:

rotTransform = $.rotation
print rotTransform.isAnimated
outputs: -- Unknown property: "isAnimated" in (quat 0.0347845 0 0 0.999395)

where:
print $.rotation.isAnimated
works perfectly.

I'm betting there's something really obvious I'm not aware of... Enlighten me please :)

eek
02-15-2009, 01:52 AM
This is a much bigger problem than I thought...

My problem is the variable gets evaluated BEFORE evaluating it WITH its property.

Another example of this is:

rotTransform = $.rotation
print rotTransform.isAnimated
outputs: -- Unknown property: "isAnimated" in (quat 0.0347845 0 0 0.999395)

where:
print $.rotation.isAnimated
works perfectly.

I'm betting there's something really obvious I'm not aware of... Enlighten me please :)

test = $.rotTransform would return a value not a parameter, so test.isAnimated would return undefined as theres no property for a value, the value itself is the property.

$.rotation.isAnimated is returning if the rotation controller is animated, not its value and so returns a correct value.

So test = $.rotation will return its rotation value, not its controller where as you could do test = $.rotation.controller

test.isAnimated should work (im not at max though so)

WhiteMage
02-15-2009, 03:13 AM
test = $.rotTransform would return a value not a parameter, so test.isAnimated would return undefined as theres no property for a value, the value itself is the property.

$.rotation.isAnimated is returning if the rotation controller is animated, not its value and so returns a correct value.

So test = $.rotation will return its rotation value, not its controller where as you could do test = $.rotation.controller

test.isAnimated should work (im not at max though so)

not working.

test = $.rotation.controller
test.isAnimated

reports the same error as:
$.rotation.controller.isAnimated

which is: -- Unknown property: "isAnimated" in Controller:Euler_XYZ

to get the .isAnimated property to return a value, I have to add it like this: $.rotation.isAnimated

And I'm still left with the problem where:
test = $.rotation
test.isAnimated

won't work because the variable is evaluated without the property

Piflik
02-15-2009, 09:56 AM
AFAIK, you cannot ask a variable if it is animated. 'isAnimated' needs a property to work with, and these aren't saved in variables by default.

The only way to do what you want would be

Test = $.rotation

Test.controller.isAnimated

or maybe this...

Test = getproperty $ #rotation

Test.isAnimated

WhiteMage
02-15-2009, 02:31 PM
not working either..

Test = $.rotation
Test.controller.isAnimated
returns -- Unknown property: "controller" in (quat 0.23211 0 0 0.97269)
again, the variable is evaluated without its property

and same thing with:
Test = getproperty $ #rotation
Test.isAnimated
I get this: -- Unknown property: "isAnimated" in (quat 0.23211 0 0 0.97269)


somebody must know what's going on here...

ZeBoxx2
02-15-2009, 03:23 PM
somebody must know what's going on here...

The examples are a bit flawed... when you run...
Test = $.rotation
Test will now contain the rotation value of the selection (bad idea to use $, btw, as you can only call .rotation on a single object, but that's another topic). The value, a Quaternion, doesn't have any controller.

When you run..
Test = $.rotation.controller
Then you're getting the controller out of the rotation parameter, and that parameter can indeed have a controller.

The only way the former would work is if you made a reference to the parameter:

Test = &$.rotation
*Test.controller

Scary stuff.

However, even when you've got the rotation controller, you can't call .isAnimated on it. .isAnimated is applied to tracks, rather than to controllers (as you already found out). So you would have to use...
$.rotation.isAnimated
or
$.rotation.x_rotation.isAnimated
if you need to check a specific axis.

So you with the aforementioned reference, you can use..

*Test.isAnimated
*Test.x_rotation.isAnimated

WhiteMage
02-15-2009, 03:46 PM
Thanks ZeBoxx2, this really is what I was looking for! And it works very well.

Quick question, in this example

Test = &$.rotation
*Test.controller

& is to make a reference,
what does * do in that particular line?

thanks,

drdubosc
02-15-2009, 03:58 PM
Possibly via "Indexed Access to Animateable Properties?"

ie

tst = $[#transform][#rotation]
SubAnim:Rotation

tst.isanimated
true

EDIT ....oops, too late

WhiteMage
02-15-2009, 04:12 PM
no, not too late, drdubosc. Funny I was reading about this method before ZeBoxx2 posted his answer.

It looks like another good method to get the same results. I was using it with numbers, instead of #tranform and #rotation, since I'm not very familiar with the # character yet.

drdubosc
02-15-2009, 04:30 PM
Oh, good. I'm still straining my head trying to work out what the code behind this behaviour of properties must look like, so I can get a mental picture of it. An overload of "=", perhaps. Just a phase. It will pass :).

ZeBoxx2
02-15-2009, 05:00 PM
as far as * goes, it's the dereferencing operator, otherwise you're just left with another reference, while you need the value of it.

Basically the whole referencing thing is a powerful (albeit somewhat confusing-at-first) method of getting a value at the time you dereference the reference. This is different from variables in that variables are static. It's similar to a function, in that regard, but without the need for defining a function.

e.g.

fn selRadius = ( $.radius )
selRadius()

myRadius = $.radius
26.223
selRadius()
26.223
myRadiusRef = &$.radius
(prop radius* (%"getDollarSel"()))

$.radius = 10
10

myRadius
26.223
selRadius()
10.0
myRadiusref
(prop radius* (%"getDollarSel"()))
*myRadiusRef
10.0


Of course a function (or an UI element's callbacks code bock) is much more flexible as you can make calculations, put in conditional tests, etc. But sometimes, a reference is all you need and it's much more light-weight.

WhiteMage
02-15-2009, 07:40 PM
thanks ZeBoxx2 for that deeper explanation.

In the end I went with $[#transform][#rotation], it works perfectly with what I'm trying to do and it's simple enough.

Now if I can just figure out how the # character is working in this expression.. I know # character is used for arrays, but I can't see exactly how it works here.

PiXeL_MoNKeY
02-15-2009, 08:13 PM
In Maxscript the # refers to a Name Literal. You can look it up in the Maxscript Help for more info.

-Eric

WhiteMage
02-15-2009, 10:49 PM
In Maxscript the # refers to a Name Literal. You can look it up in the Maxscript Help for more info.

-Eric

thank you in pointing me to the right direction :P

CGTalk Moderation
02-15-2009, 10:49 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.