Getting Mapped

Ok I admit it, I’m trying to help people learn maxscript and occasionally there will be things I don’t understand, often the process of writing out a blogpost helps solidify my knowledge and makes me ask the question of whether I actually know what I’m talking about (which I hope is most of the time by now!).

One thing that stumped me for ages and I just didn’t use, because I didn’t quite understand the why and where you would need it was mapped functions.  I saw a few examples and looked it up in the help but it didn’t seem to make a load of sense. It’s so different from a normal function that I was a bit lost.

A little while ago I looked at mapped functions again and now thanks to using MCG I’m familiar with the term ‘Map’, and I get how in MCG you have an array you map it with a function and the function gets run on each element in the array…. but hang on… maybe that’s how mapped functions work.. aha it is!

So here we go, as simply as I can make it, a mapped function  that changes the wirecolor of each item in the array that it gets passed.

mapped function testMe x =
x.wirecolor = (color 0 0 0)

a = selection as array

testMe a

Simples hey!? It’s just like saying for o in myArray do o.wirecolor = (color 0 0 0) etc….

I should have been using this a long time ago…. and will start using it more now.


About davewortley

Somewhere between an artist and a programmer, I like technical things, but being creative. I love problem solving and coming up with elaborate solutions. This blog is where I shall share ideas, tips, tutorials and anything that amuses me.
This entry was posted in MaxScript, Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s