PDA

View Full Version : MapScaler Help!!


fajar
07-22-2009, 06:23 AM
Hey all , Im trying little test to writte my own script, right now I write about map scaler OSM , but I couldn't figure it out how to check if selected object have or not this modifier!! I want to make it if I press gett or edt button in object that dont have modifier , it do nothing and do createdialog if selected had one!

Check it out guys and help me figure it out!!

==============================================================================

Global Mapp
Global Scala2

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_2 "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_2 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)
)
DispMessage = "Do you want to edit it too?"
if querybox DispMessage then run = true else run = false

if run then
(
createDialog scala2 128 109 style:#()
)
else ()
)
)
on edt pressed do
(
if selection.count== 1 then
(
Try (destroyDialog Scala2) catch()
rollout Scala2 ""
(
spinner Scl2 "Scale" pos:[22,16] width:78 height:16 range:[-1000,1000,$.modifiers[#Map_Scaler_OSM].scale]
spinner UOffset2 "U Offset" pos:[0,49] width:100 height:16 range:[-1000,1000,$.modifiers[#Map_Scaler_OSM].UOffset]
spinner VOffset2 "V Offset" pos:[0,65] width:100 height:16 range:[-1000,1000,$.modifiers[#Map_Scaler_OSM].VOffset]
spinner Chn2 "Channel" pos:[29,33] width:71 height:16 range:[1,99,$.modifiers[#Map_Scaler_OSM].channel] type:#integer
button Pas "P" pos:[100,16] width:14 height:16 toolTip:"Paste "
button pas2 "P" pos:[100,32] width:14 height:16 toolTip:"Paste"
button pas3 "P" pos:[100,49] width:14 height:16 toolTip:"Paste"
button pas4 "P" pos:[100,65] width:14 height:16 toolTip:"Paste"
button pas5 "Paste all !" pos:[0,83] width:64 height:13 toolTip:"Paste all properties to selection"
button Cls6 "X" pos:[114,1] width:14 height:13 toolTip:"Close"
label lbl1 "MapScaler" pos:[28,0] width:57 height:14
GroupBox grp4 "" pos:[0,-6] width:128 height:20
button Rst1 "R" pos:[114,16] width:14 height:16 toolTip:"Reset to default"
button Rst2 "R" pos:[114,32] width:14 height:16 toolTip:"Reset to default"
button Rst3 "R" pos:[114,49] width:14 height:16 toolTip:"Reset to default"
button Rst4 "R" pos:[114,65] width:14 height:16 toolTip:"Reset to default"
button rst "Reset all !" pos:[64,83] width:64 height:13 toolTip:"Reset all to default"
button Gett "Get" pos:[0,96] width:128 height:13 toolTip:"Get settting from selected"
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
local mouseIsDown = false,thePos = [0,0]
on Scala2 lbuttondown pos do
(mouseIsDown = true ; thePos = pos)
on Scala2 lbuttonup pos do
mouseIsDown = false
on Scala2 mouseMove pos do
(
if mouseIsDown do
setDialogPos Scala2 (mouse.screenpos - thePos)
)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------
on Scl2 changed val do
(
for x in selection do
(
x.modifiers[#mapscalerOSM].scale=scl2.value
)
)
on UOffset2 changed val do
(
for x in selection do
(
x.modifiers[#mapscalerOSM].uOffset=UOffset2.value
)
)
on VOffset2 changed val do
(
for x in selection do
(
x.modifiers[#mapscalerOSM].VOffset=VOffset2.value
)
)
on Chn2 changed val do
(
for x in selection do
(
x.modifiers[#mapscalerOSM].channel=chn2.value
)
)
on Pas pressed do
(
for x in selection do
(
x.modifiers[#mapscalerOSM].scale=scl2.value
)
)
on pas2 pressed do
(
for x in selection do
(
x.modifiers[#mapscalerOSM].channel=chn2.value
)
)
on pas3 pressed do
(
for x in selection do
(
x.modifiers[#mapscalerOSM].uOffset=UOffset2.value
)
)
on pas4 pressed do
(
for x in selection do
(
x.modifiers[#mapscalerOSM].VOffset=VOffset2.value
)
)
on pas5 pressed do
(
for x in selection do
(
x.modifiers[#mapscalerOSM].scale=scl2.value
x.modifiers[#mapscalerOSM].channel=chn2.value
x.modifiers[#mapscalerOSM].uOffset=UOffset2.value
x.modifiers[#mapscalerOSM].VOffset=VOffset2.value
)
)
on Cls6 pressed do
(
destroyDialog scala2
)
on Rst1 pressed do
(
for x in selection do
(
x.modifiers[#mapscalerOSM].scale=5
scl2.value= 5
)
)
on Rst2 pressed do
(
for x in selection do
(
x.modifiers[#mapscalerOSM].channel=1
chn2.value= 1
)
)
on Rst3 pressed do
(
for x in selection do
(
x.modifiers[#mapscalerOSM].uOffset=0
UOffset2.value= 0
)
)
on Rst4 pressed do
(
for x in selection do
(
x.modifiers[#mapscalerOSM].VOffset=0
VOffset2.value= 0
)
)
on rst pressed do
(
for x in selection do
(
x.modifiers[#mapscalerOSM].scale=5
x.modifiers[#mapscalerOSM].channel=1
x.modifiers[#mapscalerOSM].uOffset=0
x.modifiers[#mapscalerOSM].VOffset=0
scl2.value= 5
chn2.value= 1
UOffset2.value= 0
VOffset2.value= 0
)
)
on gett pressed do
(
if selection.count ==1 then
(
scl2.value= $.modifiers[#Map_Scaler_OSM].scale
chn2.value= $.modifiers[#Map_Scaler_OSM].channel
UOffset2.value= $.modifiers[#Map_Scaler_OSM].UOffset
VOffset2.value= $.modifiers[#Map_Scaler_OSM].VOffset
)
else
(
messageBox "Please select one object only !" title: "Selection Error !"
)
)
)
createdialog Scala2 128 109 style:#()
)
else if selection.count > 1 then
(
messageBox "Please select one object only !" title: "Selection Error !"
)
)
)
createDialog Mapp 90 154

==============================================================================

Something happen when I click Edt and Gett button ,it says "unknown property "scale" in undefined, how to solve this problem, can you all give me some light!?

Kameleon
07-22-2009, 10:59 AM
Hey, this sould do it:

for i in selection do
(
for j in i.modifiers do
(
if j as string=="MapScaler:Map Scaler Binding" then print "Click me! Click me!"
)
)

Cheers.

fajar
07-23-2009, 01:00 AM
Thanks for answering me thank! but I think your suggest dont do the work
try it your self in Max

I remodifie your script to test it more but still no work!!
=====================================================================
rollout one "Untitled"
(
button btn1 "Button" pos:[3,2] width:155 height:25

on btn1 pressed do
(
for i in selection do
(
for j in i.modifiers do
(
if j as string=="MapScaler:Map Scaler OSM" then
messageBox "hallo"
)
)
)
)
createDialog one 162 29
=====================================================================

any other suggestion!?

Zbuffer
07-23-2009, 03:49 AM
How about this ?

rollout one "Untitled"
(
button btn1 "Button" pos:[3,2] width:155 height:25

on btn1 pressed do
(
for i in selection do
(
for j in i.modifiers do
(
if classof j == MapScalerOSM then
messageBox "hallo"
)
)
)
)
createDialog one 162 29

fajar
07-23-2009, 04:10 AM
Thank it work somehow...thank! now my little script is complete!! thank very much!

CGTalk Moderation
07-23-2009, 04:10 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.