PDA

View Full Version : Problem with maxscript selection


B.Opatowiecki
06-29-2005, 11:00 AM
Hello.

I'm new to this forum, just started with maxscript and facing basic problems. I have written this small utility (floater):



(

rollout testD "PointCache"
(
button PointCache_Record "Record" pos:[1,75] width:110
button PointCacheSet "PC_Set" pos:[1,100] width:50
button PointCacheToggle "PCToggle" pos:[60,100] width:50
Spinner PCSamples "Samples:" type:#integer range:[0,30,2] pos:[10,48]
Spinner STime "Start Time:" type:#float range:[-10000,10000,0] pos:[2,1]
Spinner ETime "End Time:" type:#float range:[-10000,10000,100] pos:[5,21]

on PointCache_Record pressed do
(
(
try
(
macros.run "Modifiers" "PointCache"
$.Point_cache.samples = (PCSamples.value as Integer)
$.Point_cache.start_time = (STime.value as float)
$.Point_cache.end_time = (ETime.value as float)
$.Point_cache.Record ()
)
catch
(
messageBox "Select only one object" title:"Unknown Selection Type" beep:true
)

)
)

on PointCacheSet pressed do
(
(
try
(
macros.run "Modifiers" "PointCache"
$.modifiers[#Point_Cache].samples = (PCSamples.value as Integer)
$.modifiers[#Point_Cache].SetCache ()
)
catch
(
messageBox "Select only one object" title:"Unknown Selection Type" beep:true
)
)

)

on PointCacheToggle pressed do
(

try
(
for i in selection do (i.modifiers["Pointcache"].enabled=not(i.modifiers["Pointcache"].enabled))
)
catch
(
messageBox "This object has no pointcache modifier" title:"MissingModifier Error" beep:true
)

)

)
newF = newrolloutfloater "Pointcache" 125 155
addrollout testD newF

)


My main aim is to have support for multiple objects. So, If I have five objects selected then utility takes their names and automatically uses them as pointcache file names.
User have to press a button "reccord" and point to a specified folder then script doest the rest. This is idea for now.

Second script which doesn't work with multiple objects. I'm stuck here. Any help is very welcome.

(


SelctedObj = selection as array

if (SelctedObj.count == 1) and (classof $.baseobject != geometry) then
(

try
(
for i in selection do (i.modifiers["Turbosmooth"].enabled=not(i.modifiers["Turbosmooth"].enabled))
)
catch
(
(
rollout TSAppIter "TSAppIter" width:189 height:30
(
spinner TSAppIterSpin "" type:#integer range:[0,3,1] pos:[1,6]
button TSAppGo "go!" pos:[155,5]
label lbl3 "set iterations" pos:[90,8]


on TSAppGo pressed do
(
macros.run "Modifiers" "TurboSmoothMod"
$.Turbosmooth.iterations = (TSAppIterSpin.value as Integer)
destroyDialog TSAppIter
)
)
createDialog TSAppIter pos:[mouse.screenpos.x, mouse.screenpos.y] modal:false style:#(#style_border)
)


)
)

else (
(messagebox "Select some Geometry")
)



)


Thank you.

RyanT
06-29-2005, 08:35 PM
So I think this will solve your problem for the second script:


(

rollout TSAppIter "TSAppIter" width:189 height:30

(

spinner TSAppIterSpin "" type:#integer range:[0,3,1] pos:[1,6]

button TSAppGo "go!" pos:[155,5]

label lbl3 "set iterations" pos:[90,8]



on TSAppGo pressed do

(

for i in selection do

(

if classof i.baseobject != geometry then

(

try(i.modifiers["Turbosmooth"].enabled = not(i.modifiers["Turbosmooth"].enabled))

catch

(

addModifier i (TurboSmooth())

i.Turbosmooth.iterations = (TSAppIterSpin.value as Integer)

destroyDialog TSAppIter

)

)

)

)

)

createDialog TSAppIter pos:[mouse.screenpos.x, mouse.screenpos.y] modal:false style:#(#style_border)

)



-RyanT
Pipeworks Software
Foundation 9

CGTalk Moderation
06-29-2005, 08:35 PM
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.