Hello all! I've been keeping busy trying to learn MEL script but since most of my office use Max, I started doing a bit of Maxscript too. I'm completely self taught at this point and I'm having a little issue. I'm sure it's something simple but I haven't been able to solve this. I have a button with the function as follows;
on ButtonSmooth pressed do
(
ViewPortVal = SIterations.value
RenderVal = RIterations.value
modPanel.addModToSelection (TurboSmooth ()) ui:on
$.modifiers[#TurboSmooth].iterations = ViewPortVal
$.modifiers[#TurboSmooth].useRenderIterations = on
$.modifiers[#TurboSmooth].renderIterations = RenderVal
)
As I'm sure you can guess, it simply turbosmooth's the object. And it works fine on one object, however I want to be able to use this on multiple objects at a time but it throws an error at me when I try it. Can anyone see why it wouldn't work on a selection of objects?
Any help is much appreciated!
Thanks,
Matty
Replies
foreach(object in selection)
{
do stuff
}
what you`ll need to do is go over each element and run that same bit of code
so for example
To fix your code, just use a variable to adjust the modifier. This will result in an instanced modifier on all the objects. So changing one turbosmooth will change the rest.
If your intention wasn't to have an instanced modifier. You can loop the selection.
But if you really did want an instanced modifier, I would do it this way. It's shorter, uses less variables, and doesn't rely on the modifier panel.
Thanks Again,
Matty
monster: good examples! also a lot shorter ^^