View Full Version : Auto Assign Material On Creation


SeanEG
12 December 2010, 04:36 AM
Hey guys, first post here. I decided to throw myself head first into MaxScript yesterday and I've come across my first barrier.

I can't figure out how to go about automatically assigning a material to an object upon creation. It was simple to assign a material to everything in the scene, but this is proving to be a lot more difficult. After searching through the MaxScript reference, I'm thinking I might have to do something with a callback script and #nodeCreated, but I'm not sure.

Any advice or input on how to go about doing this?

Thanks in advance.

Bobo
12 December 2010, 07:27 AM
Did you happen to find the topic "How To ... Assign Materials Automatically" in the MAXScript Help?

But yes, using the callback you found would be even better.

SeanEG
12 December 2010, 07:41 AM
Ah, how did I not see that before? I'll see what I can do with that, and come back if I hit another wall.

Thanks for the response!

PEN
12 December 2010, 06:04 PM
Try this

http://paulneale.com/scripts/autoMaterial/autoMaterial.htm

SeanEG
12 December 2010, 06:34 PM
Hey PEN, that looks great. But when I tried to drag and drop the .mzp into the viewport, I get this error.

http://dl.dropbox.com/u/832936/mzp_error.jpg

Any idea what the problem is?

JHN
12 December 2010, 12:00 PM
Do you have vista or win7 with UAC enabled? It probably didn't allow the script to copy the file to a program directory folder.

-Johan

PEN
12 December 2010, 11:15 PM
Ya disable the UAC in win 7. It will work then.

SeanEG
12 December 2010, 04:23 AM
Yup, that was it. Thanks guys.

PEN
12 December 2010, 01:37 PM
Let me know how that tool works out for you. I wrote it years ago for a friend and I don't know many people that have used it other then him.

denisT
12 December 2010, 01:57 AM
I wrote it years ago for a friend and I don't know many people that have used it other then him.

it's the same story for me. Just curious, why does anyone need to assign a material on EVERY node created?

PEN
12 December 2010, 02:31 AM
Well the company that was using it needed to have a material on every object that were exported to their game engine or the engine would crash.

The tool that I wrote also allows you to apply default gray colors instead of the colors that max uses.

denisT
12 December 2010, 02:46 AM
Well the company that was using it needed to have a material on every object that were exported to their game engine or the engine would crash.

The tool that I wrote also allows you to apply default gray colors instead of the colors that max uses.

i understand. but the ui has to have an option to activate the auto-assign mode. in code you have to have a filter for nodes to assign. and blah-blah-blah... in my experience it's much more easier to select a set of nodes and assign some material to them at once. ...and to have a warning message on export level if the material assignment is wrong.

PEN
12 December 2010, 12:33 PM
Once you turn mine on it stays on permanently. I find that rather easy all around. Plus it is always easiest to do what my clients ask for when I have no control over there pipeline.

CGTalk Moderation
12 December 2010, 12:33 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.


1