Problem script addModifier

Hello Everyone! I'm encountering a problem with maxscript. Here it is:

for o in objects do for m in o.modifiers where classof m == Bend addModifier o (Squeeze())

As you can see this isn't a hard one but it doesn't work and something it makes 3ds max quit. It is because some of the objects don't have a bend modifier, so I have to use try()catch() but this fails as well.

All I want is to add the squeeze modifier on the selected objects that already has a bend modifier. Can you tell me where am I supposed to put the try/catch expression? The manual has too difficult examples that I don't get it. Cry

 

Thank you very much!

Comments

Comment viewing options

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

First you forgot "do" between

First you forgot "do" between "Bend" "addModifier".
Second your code is not correct. Better try this:

for o in objects where o.modifiers.count != 0 do 
(
	if (for m in o.modifiers where (classof m == Bend) collect m).count != 0 do addModifier o (Squeeze())
)

barigazy

Comment viewing options

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