filanek
05-31-2008, 10:57 AM
Hi Guys,
I am new in maxscript and last couple of days I tried to write this script. It should select all cameras in scene and sort their "animationkeys" selection range on timeline. It does not work properly, the result should move the first key of the camera (including cam.target's keys) animation range right behind the previous camera last key and continue this way with next cameras. Sometimes I get small overlaps or holes between selection ranges of neighboring cameras.
here is the code:
--array of cameras
select $cam*
deselect $*target
cams = selection as array
Cnames = for i in selection collect i.name
sort Cnames
cams = for i in Cnames collect getNodeByName i
--array of camera.targets
select $*target
deselect lights
targs = selection as array
Tnames = for i in selection collect i.name
sort Tnames
targs = for i in Tnames collect getNodeByName i
--move camera's to zero
for i = 1 to cams.count do
(
for j = i to i do
(
C = (getkeytime cams[i].pos.controller 1)
T = (getkeytime targs[j].pos.controller 1)
if C <= T then movekeys cams[i] -C else movekeys cams[i] -T
if C <= T then movekeys targs[i] -C else movekeys targs[i] -T
)
)
--sort cameras in time
values = #()
for i = 1 to cams.count do
(
for j = i to i do
(
C = (getkeytime cams[i].pos.controller (numkeys cams[i].pos.controller))
T = (getkeytime targs[j].pos.controller (numkeys targs[j].pos.controller))
if C >= T then append values C else append values T
sum = 0
(
for i=1 to values.count do
(
sum = sum + values[i]
)
)
sum
movekeys cams[i] sum
movekeys targs[j] sum
)
)
movekeys cameras -values[1]
deselect cameras
could anybody help me please?
Thanks
Filip
I am new in maxscript and last couple of days I tried to write this script. It should select all cameras in scene and sort their "animationkeys" selection range on timeline. It does not work properly, the result should move the first key of the camera (including cam.target's keys) animation range right behind the previous camera last key and continue this way with next cameras. Sometimes I get small overlaps or holes between selection ranges of neighboring cameras.
here is the code:
--array of cameras
select $cam*
deselect $*target
cams = selection as array
Cnames = for i in selection collect i.name
sort Cnames
cams = for i in Cnames collect getNodeByName i
--array of camera.targets
select $*target
deselect lights
targs = selection as array
Tnames = for i in selection collect i.name
sort Tnames
targs = for i in Tnames collect getNodeByName i
--move camera's to zero
for i = 1 to cams.count do
(
for j = i to i do
(
C = (getkeytime cams[i].pos.controller 1)
T = (getkeytime targs[j].pos.controller 1)
if C <= T then movekeys cams[i] -C else movekeys cams[i] -T
if C <= T then movekeys targs[i] -C else movekeys targs[i] -T
)
)
--sort cameras in time
values = #()
for i = 1 to cams.count do
(
for j = i to i do
(
C = (getkeytime cams[i].pos.controller (numkeys cams[i].pos.controller))
T = (getkeytime targs[j].pos.controller (numkeys targs[j].pos.controller))
if C >= T then append values C else append values T
sum = 0
(
for i=1 to values.count do
(
sum = sum + values[i]
)
)
sum
movekeys cams[i] sum
movekeys targs[j] sum
)
)
movekeys cameras -values[1]
deselect cameras
could anybody help me please?
Thanks
Filip
