Notifications
Clear all

[Closed] Maxscript Transform

Hey,

This is the code im working with:

theArray01 = $Control_Points* as array
theArray02 = $Base_Bones* as array

for i = 1 to theArray01.count do 
(
    for i = 1 to theArray02.count do 
    (
        theArray01[i].transform = theArray02[i].transform 
    )
)

I'm trying to change the transform of one set of objects in an array to another but its throwing an error "transform is undefined" can anyone shed any light on this. Thanks!
4 Replies

The nested loop is redundant. For one the second loop overwrites the value of i, and you’re looping over theArray02 n times, where n is the length of theArray01.

(
 local theArray01 = $Control_Points* as array
 local theArray02 = $Base_Bones* as array

 --Make sure we don't encounter an array index out of bounds exception.
 local n = if (theArray01.count <= theArray02.count) then theArray01.count else theArray02.count

 for i = 1 to n do 
   theArray01[i].transform = theArray02[i].transform
)

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

n = amin theArray01.count theArray02.count

Ah nice. I searched the docs for a min/max function, but for some reason amin did not come up. Should remember that one

Was just taking as break watching Derren Brown: The Guilt Trip, defo worth a watch.

Thanks Pjanssen, denisT for the quick responses. Happy i asked, would never of solved that one.