[Closed] Unhide from Left to right
I have a script that will unhide objects randomly but What I would really like is to unhide based on an objects X, any ideas?
Here is my current script
for o in selection do
(
myNum = random 0 270 --frames
my2ndNum = random myNum myNum+5 --length of unhide
myX = o.pos.x
o.visibility = bezier_float() -- Track View: Add Visibility Track
addNewKey o.visibility.controller myNum #select
addNewKey o.visibility.controller my2ndNum #select
o.visibility.controller.keys[1].value = 0
o.visibility.controller.keys[2].value = 1
)
Thanks in advance!
Collect the objects to reveal into an array.
Collect the positions’ X component (or whatever axis you want) in another array.
Collect the indices of the objects into yet another array.
Perform indexed sort using qsort (see help).
Set keys in the order defined by the index array.
Done.
Alternatively, use the distance from a given point in space to your objects for the sorting. This will produce a radial reveal if they are not in a row but spread around randomly.
Like Bobo said,
Distance can be used quite simply, distance from world origin:
fn sortDist v1 v2 = if distance v1.pos [0,0,0] > distance v2.pos [0,0,0] then 1 else -1
sel = selection as array
qsort sel sortDist
-Johan
Hey guys, now as part of this script I am trying to get the z value of the xform modifier. I can get the [x,y,z] values with
for o in sel do (
addModifier o (XForm ())
select o
m = -((getModContextBBoxMin o o.xform) - (getModContextBBoxMax o o.xform))
b = m * o.xform.gizmo.scale
print b
)
I was wondering if there was an easy way to get just the z?
Thanks!