[Closed] help with creating my own snapshot tool for shapes
I would like to snapshot an animated shape on every frame in the total number of keys.
I’m not getting any errors, but there are no new shapes generated… I’ve been excited by my progress in mxs lately but it is obvious that I have a long way to go…
global ss = $
global ssNum = numknots ss -- number of knots in the selected spline
global ssa = #() -- empty array of knot point positions
global knotKeys = #() --empty array of the key frames of the animated knots
global masterTrack = ss[4][8] --grab the master point controller
global knotKeys = masterTrack.keys -- array of the keys of the controller
global keyCount = knotKeys.count -- number in the array of the keys of the controller
global lastKey =(getkeytime mastertrack.controller keycount).frame as integer --get an integer value for the last key for loops
mapped fn getTheKnots =
(
(for k in 1 to ssNum do
(
append ssa (getKnotPoint ss 1 k)
)
)
)
mapped fn makeNewShape =
(
for s in 1 to ssNum do
(
ns = splineShape()
addNewSpline ns
addKnot ns 1 #Bezier #Curve (ssa[s])
close ns 1
updateShape ns
)
)
for i in 1 to lastKey do
( slidertime = i
getTheKnots
makeNewShape
--ssa =()
)
global ss = $
global ssNum = numknots ss -- number of knots in the selected spline
global ssa = #() -- empty array of knot point positions
global knotKeys = #() --empty array of the key frames of the animated knots
global masterTrack = ss[4][8] --grab the master point controller
global knotKeys = masterTrack.keys -- array of the keys of the controller
global keyCount = knotKeys.count -- number in the array of the keys of the controller
global lastKey =(getkeytime mastertrack.controller keycount).frame as integer --get an integer value for the last key for loops
fn getTheKnots =
(
(for k = 1 to ssNum do
(
append ssa (getKnotPoint ss 1 k)
)
)
)
fn makeNewShape =
(
for s = 1 to ssNum do
(
ns = splineShape()
addNewSpline ns
addKnot ns 1 #Bezier #Curve (ssa[s])
close ns 1
updateShape ns
)
)
for i in 1 to lastKey do
( slidertime = i
getTheKnots()
makeNewShape()
--ssa =()
)
Start with that… should get you closer. It’s not working yet, but you’ll see the errors and can go from there.
Quick tips: ” for i in array ” means return the items in the array ( object1, object2)
” for i = 1 to array.count ” means return a number ( array[1] ) Functions without parameters need () to execute… and mapped isn’t part of declaring a function.
I can fix it later tonight, but I’m at work right now, so I don’t have time.
Thank you! I’m struggling but I’ve come a long way with MXS having no other language under my belt. I appreciate the nudge in the right direction.
I think I understood that about the loops and arrays. My loops call variables that are integers right? ssNum is an int, the number of knots. and lastKey is an int.
The only error I’m getting now is with addKnot, asking for 6 arguments. The sixth and optionally seventh arguments are the in and out vectors for the bezier handles. In the help file sample, they call addKnot with only five arguments in much the same form I have.
[left]addKnot new_spline 1 #smooth #curve pen_pos
[/left]
Anyway, the reason I am creating this script is that I like to model with animated splines. I turn on ghosting and set the number of ghosted frames to cover my animatin range. this is a very fast and interactive way of previewing a form.
Yeah, the way you were doing it was fine… didn’t notice that it was just calling an integer on first look. Either way, just wanted to make sure you knew
An easier approach might be to simply copy the spline, and remove all keys every frame instead… ? Then you don’t have to rebuild the spline curves…
No, that is way too uncomplicated. I’m trying to get beyond my usual five lines of code!
Revisiting this idea, I decided to build the splines from snapshots of meshes converted to poly…
for o in selection do
(
p1 = polyop.getvert o 1
ss = SplineShape pos:p1
addNewSpline ss
(
for i =1 to 6 do
(
addKnot ss 1 #corner #line (polyop.getvert o i)
)
)
close ss 1
updateShape ss
)