Would like to be able to multi select objects consecutively along + or - XYZ axis. (Example: so that they are selected in order from left to right along X axis)
As it stands right now selecting multiple objects at once seems to randomize the order.
Forum topic · Scripts Wanted
By tuxmask75 · 2013-10-21
Would like to be able to multi select objects consecutively along + or - XYZ axis. (Example: so that they are selected in order from left to right along X axis)
As it stands right now selecting multiple objects at once seems to randomize the order.
barigazy · 2013-10-21
This can help
fn sortByAxis arr1 arr2 axis: maxtomin: =
(
local first, second
case axis of
(
(#x): (first = arr1.pos.x ; second = arr2.pos.x)
(#y): (first = arr1.pos.y ; second = arr2.pos.y)
(#z): (first = arr1.pos.z ; second = arr2.pos.z)
)
case of (
(first < second): if not maxtomin then -1 else 1
(first > second): if not maxtomin then 1 else -1
default:0
)
)
-- example
delete objects
cnt = 1
objArr = for c in #(Box, Teapot, Cylinder, Cone, Sphere) collect (obj = c pos:[(cnt*50), 0, 0] ; cnt+=1 ; obj)
qsort objArr sortByAxis axis:#x maxtomin:off -- selected in order from left to right along X axis
print objArr
--qsort objArr sortByAxis axis:#x maxtomin:on -- selected in order from right to left along X axis
barigazy · 2013-10-21
As you can see you can choose any axis and sorting order ei:
-> if you set #x axis and "maxtomin" argument is "off" then objects array is sorted
along x-axis from left to right
-> if you set #z axis and "maxtomin" argument is "on" then objects array is sorted
along z-axis from top to bottom
etc.
It's easy pretty much :)
Cheers!
barigazy · 2013-10-21
This is another example of QSort method
http://www.scriptspot.com/forums/3ds-max/general-scripting/example-how-t…
tuxmask75 · 2013-10-21
This is just what I needed.. however how do you ignore objects on hidden layers ?
barigazy · 2013-10-21
To collect all not hidden objects just use
for o in objects where not o.isHidden collect o
At least try to read MXS help