Notifications
Clear all

[Closed] Add new line to expression when defining an expression via maxscript?

hi,

this seems like it should be really simple…

i want to add a rotation script controller to multiple objects which has the following code… i can’t suss out a way to do it without scripting as i can only paste instance the controller to one of the objects at a time.

this is the expression which i use in the script controller…

YVec = normalize ($.pos – (at time (currenttime-1) $.pos))
ZVec = [0,0,1]
XVec = cross YVec Zvec
ZVec = cross XVec YVec
tm = (matrix3 XVec YVec ZVec $.pos)
tm.rotationpart

this is the maxscript code i’m trying to use to add the expression to multiple objects…

for i in selection do
(
select i
$.rotation.controller=rotation_script ()
$.rotation.controller.script =”YVec = normalize ($.pos – (at time (currenttime-1) $.pos)) “
 –here is the problem, the line above puts the first line of the code into the expression box, i’m not sure how to create a new line within the expression so i can add the rest of the code to the expression box via maxscript, and i can’t put the the whole expression on one line as it throws up an error
)

any ideas? thanks in advance

Neil

2 Replies

You can use multiline string with no issues – put the quotes only on the very first and very last line. Or use
, that’s the newline character. Or use semicolon at the end of each line.

1 Reply
(@neilcooper33)
Joined: 11 months ago

Posts: 0

thanks! this worked…
however now i have a problem where the same values are being used for all the objects… so i think the objects are rotating based on other object’s trajectories… when one object starts to turn, it also rotates the other object…

any ideas on this one?

thanks again