em3
07-21-2011, 03:48 PM
Hello!
I am writing a script that will animate an object based on its distance to another objects position. I am using the distance from the target object (dummy) as the start frame.
This works great if I am animating boxes that are all uniformly spaced. In the real world though I have objects spread out over "miles" so, I am putting all of the objects distance values into an array and then sorting that array. I would like to use the array index as the start frame. Is there a way I can quickly collect the array index? Here is some example code:
theArr=#(30,2,54,77,565,433,5,3,866)
sort theArr
for n = 1 to theArr.count do
(
theArrValue = theArr(n).index
print theArrValue as string
)
I realize that "n" IS the index, however the names of the objects are duplicates in many cases. I was writing a function that collected an array with the object name and distance value and then doing a filterstring to find that value in the original array and find the index that way but it seemed like the WAY WRONG way to do it. So many words for such a seemingly simple thing...I am shamed. :hmm:
I am writing a script that will animate an object based on its distance to another objects position. I am using the distance from the target object (dummy) as the start frame.
This works great if I am animating boxes that are all uniformly spaced. In the real world though I have objects spread out over "miles" so, I am putting all of the objects distance values into an array and then sorting that array. I would like to use the array index as the start frame. Is there a way I can quickly collect the array index? Here is some example code:
theArr=#(30,2,54,77,565,433,5,3,866)
sort theArr
for n = 1 to theArr.count do
(
theArrValue = theArr(n).index
print theArrValue as string
)
I realize that "n" IS the index, however the names of the objects are duplicates in many cases. I was writing a function that collected an array with the object name and distance value and then doing a filterstring to find that value in the original array and find the index that way but it seemed like the WAY WRONG way to do it. So many words for such a seemingly simple thing...I am shamed. :hmm:
