help ! my script has no undo !!!!!

hi guys !!!
i wrote a little script to help me with the rendering passes
basically it gives the selected object a specific material.
but as i was using it i found that it has no undo function !!!!
help!!! how do i resolve some thing like that ??? i tried the "undo on"
but i didnt work , should i make a button to save a scene state and load it later??
i really hope you guys can help me like always

here is the code
---------------------------------------------------------------------------------------------------------------------------------------------------------------------
global
solidblackMT = standard diffuse_color: (color 0 0 0) Self_Illumination: (100.0) name: ("SolidBlackMT") --- soid black standard material with 100% self illuminiation
solidWhiteMT = standard diffuse_color: (color 255 255 255) Self_Illumination: (100.0) name: ("SolidWhiteMT") --- soid white standard material with 100% self illuminiation
solidGrayMT = standard diffuse_color: (color 115 115 115) Self_Illumination: (100.0) name: ("SolidGrayMT") --- soid gray standard material with 100% self illuminiation
FalloffMT = standard diffusemap: (falloff ()) Self_Illumination: (100.0) name: ("FalloffMT") --- standard material with falloff map and 100% self illuminiation
ZdepthMT = standard diffusemap: (falloff ()) Self_Illumination: (100.0) name: ("ZdepthMT") --- standard material with falloff map and 100% self illuminiation(converted later to "distance blend")
WireColorMT = standard diffusemap: (Object_Color ()) Self_Illumination: (100.0) name: ("WireColor") --- standard material with "object color" map (mental ray map) and 100% self illuminiation
FalloffNearDis = (0) --- default value for use in the "distance blend map" (changed later with spinner)
FalloffFarDis = (600) --- default value for use in the "distance blend map" (changed later with spinner)

rollout MatPassomizer "MatPassomizer v1.0" width:256 height:328
(
button BlackBTN "BLACK" pos:[35,67] width:89 height:35
button WhiteBTN "WHITE" pos:[131,67] width:89 height:35
button GrayBTN "GRAY" pos:[35,115] width:89 height:35
button FalloffBTN "FALLOFF" pos:[131,115] width:89 height:35
button ZdepthBTN "ZDEPTH" pos:[24,189] width:89 height:35
GroupBox ZdepthGRP "Zdepth" pos:[16,170] width:224 height:64
spinner NearSPN "near" pos:[152,186] width:72 height:16 range:[0,1e+006,0] type:#worldunits
spinner FarSPN "far" pos:[152,210] width:72 height:16 range:[0,1e+006,600] type:#worldunits
button WireColorBTN "WireColor" pos:[24,261] width:89 height:35
GroupBox WireColorGRP "WireColor" pos:[16,242] width:224 height:64
button RanWireColorBTN "RANDOM" pos:[136,271] width:88 height:24
label RanWireLBL "random wirecolor" pos:[136,252] width:88 height:16
GroupBox BasicSolidsGRP "basic solids" pos:[16,45] width:224 height:119
label headline "assigns materials for use in matirial pass renders -1.choose objects 2.press a botton-" pos:[13,13] width:226 height:28
on BlackBTN pressed do
(
try
$.material = SolidBlackMT
catch
(
messagebox "select object"
results = undefined
)
)
on WhiteBTN pressed do
(
try
$.material = solidWhiteMT
catch
(
messagebox "select object"
results = undefined
)
)
on GrayBTN pressed do
(
try
$.material = solidGrayMT
catch
(
messagebox "select object"
results = undefined
)
)
on FalloffBTN pressed do
(
try
$.material = FalloffMT
catch
(
messagebox "select object"
results = undefined
)
)
on ZdepthBTN pressed do
(

(
try
$.material = ZdepthMT
catch
(
messagebox "select object"
results = undefined
)
)
(
try
for i in selection do
(
i.material.diffusemap.falloff_type = 4
i.material.diffusemap.Near_Distance = FalloffNearDis
i.material.diffusemap.Far_Distance = FalloffFarDis
)
catch()
)
)
on NearSPN changed val do
FalloffNearDis = (NearSPN.value)
on FarSPN changed val do
FalloffFarDis =(FarSPN.value)
on WireColorBTN pressed do
(
try
$.material = WireColorMT
catch
(
messagebox "select object"
results = undefined
)
)
on RanWireColorBTN pressed do
(
try
for i in selection do i.wirecolor = color (random 0 255) (random 0 255) (random 0 255)
catch
(
messagebox "select object"
results = undefined
)
)
)

createdialog MatPassomizer

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
JokerMartini's picture

Simple solution

A quick and simple solution to this would be to just do a Scene Hold and then after the script is run do Scene Fetch.

John Martini
Digital Artist
http://www.JokerMartini.com (new site)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.