Home Technical Talk

MaxScript: Can't Undo Scripted Spline Operations?

I'm working on a script that moves vertices/knots of an editable spline, and I want to allow the user to undo the operation. I have used theHold successfully for a script that moves vertices on editable mesh/poly objects, but when I attempt to use it for splines using setKnotPoint, setInVec and setOutVec, it doesn't work.

The actual script I'm working on is a bit complex, so I tested theHold on the simple spline flattening script in the MaxScript help:
theHold.Begin()
new_z = $.pos.z
  for s = 1 to (numSplines $) do
  (
    for k = 1 to (numKnots $ s) do
    (
      knt = getKnotPoint $ s k
      in_vec = getInVec $ s k
      out_vec = getOutVec $ s k
      knt.z = in_vec.z = out_vec.z = new_z
      setInVec $ s k in_vec
      setOutVec $ s k out_vec
      setKnotPoint $ s k knt
    )--end k loop
  )--end s loop
  updateshape $
  theHold.Accept "flatten spline"
The "flatten spline" doesn't appear in the undo space in the Edit menu. Does that mean that these operations can't be undone, even though manual moving of spline vertices can? Is there an alternative way to move the points that allows for undo?

Thank you for any help.

Replies

Sign In or Register to comment.