XM Magdalena 3D print, GGeorgy (3D)
LC #42 Pipers Alley

View Full Version : Undo Context Not Appearing in Stack

03-04-2009, 10:25 AM
Hi Guys,

I have written a very simple (and clumsy) little macro here, to demonstrate my problem. Sometimes when I am using the undo clauses, they are not storing an undo in my stack!

Here is an example of a clumsy macro to flatten a spline. From the code I would have hoped that it would have given me a "Spline Flatten" addition to my undo stack. But it doesnt record anything at all! I am sure I am doing something pretty silly. Is it anything to do with the on execute context?

macroScript SplineFlat category:"SplineFun"

on execute do
undo "Spline Flatten" on
SelSplines = for o in selection where (iskindof o line) or (iskindof o SplineShape) collect o

for o in SelSplines do
for s = 1 to numsplines o do
for i = 1 to (numknots o s) do
SpPos = getknotpoint o s i
setknotPoint o s i [SpPos.x,SpPos.y,0]

)--End of for
updateshape o
)--End of for
)--End of Undo
)--End of Execute

)--End of SplineFlat

Any ideas why this doesnt record in the stack? Does it have to be from a rollout or something? I am in Max 2009.

Thanks for your time guys,


03-04-2009, 11:07 AM
alas - those commands aren't undoable, looks like; even if you type them in the MaxScript Listener, no "Undo MaxScript" entry is generated.

03-04-2009, 05:06 PM
Hi Richard,

Thats a shame. Hoping I was doing something silly instead. Thanks for taking the time to look into it. Its really appreciated.



03-04-2009, 06:00 PM
This is a long standing issue with maxscript, spline operations do not generate undo entries..
A way around this limitation is to create a copy of the spline, modify the copy, replace the original spline with the copy, and then delete the copy. All within a single undo context obviously.


03-06-2009, 09:34 AM
cheers Martijn!

That explains quite a bit. I have another very simple script that rebuilds a spline as accurately as it can with a user specified number of knots. This very much goes through the process that you described of building a new spline from scratch. As you mentioned, this is also fully undoable, with a nice little description that appears in the stack.

There are obviously other problems with replacing the spline with a new spline, but I might work it through anyway. Cheers!


CGTalk Moderation
03-06-2009, 09:34 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.