Notifications
Clear all

[Closed] what am I doing wrong here?

hello all, this is my problem right now…I run the script and it says “Ok” but nothing happened heres the code:

for obj in selection do
(
objPos = obj.pos.controller.x_position;
f = 40;

with animate on( 
	execute("at time f objpos = -50");
)

)

any tips or advice would be appreciated thank you.:surprised

4 Replies

Two things… your line ‘objPos = obj.pos.controller.x_position’ returns a number, not an object, so you cannot use it to set parameters. And the execute command passes out the string, so it is not being run in the local area anymore, so it needs a global variable (I think…Bobo could probably explain better). Try this:

for obj in selection do
(
global obj = obj
global f = 40;

with animate on(
execute(“at time f obj.pos.controller.x_position = -50”);
)
)

As Flipped_Normal points out, you are trying to set properties on a number, which has no properties. objPos = obj.pos.controller.x_position should instead be objPos = obj.pos.controller.x_position.controller, which will return a controller for which properties can then be set. Note that to get and set values for this controller, you’ll need to access its .value property.

I’m uncertain why you are using execute() in this context. You could just as easily write at time f with animate on objPos.value = -50. That will do the same thing, only without having to define globals to deal with the execute() scope issue.

RH

Thanks for the help Flipped_Normal and RH, I’ll try it now

Originally posted by LFShade

I’m uncertain why you are using execute() in this context.

Uhhm, MEL background shows through?