PDA

View Full Version : Destroy and createDialog at same time?! repetitive!


fajar
07-23-2009, 10:24 PM
Hey all it's me again whom tryng writte a script, I got some trouble here
here is the trouble
=====================================================================
(
try (destroyDialog Mapp) catch()
rollout Mapp "Mapping Tool"
(
spinner maplength "Scale: " pos:[-7,121] width:93 height:16 range:[0.001,150,5] type:#float heigth:20
button Aplly "Do It!" pos:[0,139] width:45 height:14 toolTip:"Apply Map Scaler to selected"
button edt "Edit" pos:[45,139] width:45 height:13

on Aplly pressed do
undo "Apply Map Scaler" on
(
for obj in selection do
(
if iskindof obj GeometryClass then
(
addModifier obj (MapScalerOSM ())
obj.MapScalerOSM.Scale = (maplength.value)
)
else if iskindof obj Shape then
(
addModifier obj (MapScalerOSM ())
obj.MapScalerOSM.Scale = (maplength.value)
)
Try (destroyDialog Scala1) catch()
rollout Scala1 ""
(
button btn1 "X" pos:[4,2] width:155 height:23
)
createDialog Scala1 162 28
)
)
)
createDialog Mapp 90 154
)

=====================================================================
when the button apply pressed everything is fine but it create repetitive create and destroy dialog over and over , the count is same as object in selection, how to prevent this happen? and display dialog just only one.
thank!

Dave Black
07-23-2009, 10:37 PM
Without getting into some of the broader points of creating a dialog, your code is simply not formatted correctly, and your logic is slightly flawed.

Try something more like this:


try (destroyDialog Mapp) catch()

rollout Mapp "Mapping Tool"
(
spinner maplength "Scale: " pos:[-7,121] width:93 height:16 range:[0.001,150,5] type:#float heigth:20
button Aplly "Do It!" pos:[0,139] width:45 height:14 toolTip:"Apply Map Scaler to selected"
button edt "Edit" pos:[45,139] width:45 height:13

rollout Scala1 ""
(
button btn1 "X" pos:[4,2] width:155 height:23
)

on Aplly pressed do
(
with undo "Apply Map Scaler" on
(
for obj in selection do
(
if(iskindof obj GeometryClass) then
(
addModifier obj (MapScalerOSM ())
obj.MapScalerOSM.Scale = (maplength.value)
)
else
(
if(iskindof obj Shape) then
(
addModifier obj (MapScalerOSM ())
obj.MapScalerOSM.Scale = (maplength.value)
)
)
)

createDialog Scala1
)
)
)

createDialog Mapp 90 154



-Dave

denisT
07-23-2009, 10:55 PM
I suggest to add destroying of Scala1 dialog to Dave's code. You can do it "on Mapp close" event or when you open new "Mapping Tool"


try
(
destroyDialog Mapp
destroyDialog Mapp.Scala1
)
catch()


rollout Mapp "Mapping Tool"
(
spinner maplength "Scale: " pos:[-7,121] width:93 height:16 range:[0.001,150,5] type:#float heigth:20
button Aplly "Do It!" pos:[0,139] width:45 height:14 toolTip:"Apply Map Scaler to selected"
button edt "Edit" pos:[45,139] width:45 height:13

rollout Scala1 ""
(
button btn1 "X" pos:[4,2] width:155 height:23
)

on Aplly pressed do
(
with undo "Apply Map Scaler" on
(
for obj in selection do
(
if(iskindof obj GeometryClass) then
(
addModifier obj (MapScalerOSM ())
obj.MapScalerOSM.Scale = (maplength.value)
)
else
(
if(iskindof obj Shape) then
(
addModifier obj (MapScalerOSM ())
obj.MapScalerOSM.Scale = (maplength.value)
)
)
)

createDialog Scala1
)
)

on Mapp close do if Scala1.open do destroyDialog Scala1
)

createDialog Mapp 90 154

fajar
07-24-2009, 03:27 AM
Well everybody thank for the input, I forgot that theres another way to create dialog like this
I should increase my maxscript language skill more..and more
specialy for Denis who always answering my post kindly...

thank everybody!

CGTalk Moderation
07-24-2009, 03:27 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.