Link Array (directional)
Version:
1
Date Updated:
02/07/2012 This code simply allows a users to link a selection of objects based on the order of selection. You can use either 0 or 1 to define the direction. That allows you to link everything forwards or backwards. Rather simple code but I figured someone would find use for it.
clearlistener() fn fnLinkArray arr dir:0= ( if dir != 0 then ( reverseArr = for i = arr.count to 1 by -1 collect arr[i] arr = reverseArr ) for o in arr do o.parent = undefined for i = 1 to (arr.count-1) do ( child = arr[i] parent = arr[i+1] child.parent = parent print (child.name + "---->" + parent.name) ) ) fnLinkArray selection dir:0 fnLinkArray selection dir:1
Comments
I'm fine, thanks
Yeah, thats the idea to make the functions separate. This way they become re-usable for other scripts, the base logic then build function library.
my recent MAXScripts RSS (archive here)
Hey Anubis - how's it going?
You definitely simplified it.
I had originally have two separate functions, one which reversed the array. I then decided to combine it into one.
I think it makes more sense to have it separate like you have posted above.
Essentially could make one function which just links the given array.
Then use other functions to build arrays out of selections.
That way users could use other functions to build arrays based on options, example being qsort based on distance from an object.
Then the user could decide whether or not they want to reverse it before running the linking function.
Just some ideas.
John Martini
Digital Artist
http://www.JokerMartini.com (new site)
Hey John
I hope its welcome to append similar function...
And if the main idea is to make it working with optional direction argument...
Cheers!
my recent MAXScripts RSS (archive here)