Saturday, May 9, 2009

MAXScript: Removing Spaces From Names

Here is a quick snippet of code that will remove all the spaces in your object names and replace them with underscores. Simple yet elegant.


for s in selection do
(
oldname = filterString s.name " "
temp = oldname[1]
for i = 2 to oldname.count do
(
temp = temp + "_" + oldname[i]
)

s.name = temp
)


Select all the objects first, and run this script.

Friday, May 8, 2009

MEL: Breaking out of infinite loops

I read a great article today about how to break out of an infinite for or while loop in MEL. It happens to all of us at some point. Every so often you forget to add a counter or you miss a variable somewhere and you create a never-ending loop that you'd need to force quit maya in order to stop. This is a cool trick to prevent that.

http://www.naughtynathan.co.uk/?p=59

Great stuff. He also has a version for Python.