View Full Version : Applying a texture on creation of an object?

03-05-2008, 02:56 AM
Hi everyone!

I have these repetitive tasks to do and i'd like to save time by using a script.

Here's what i have so far...
By pushing a button I create a plane of the desired size, desired orientation and a reset XForm modifier is applied on it. The 1st material in the material editor is also applied on that plane.

What i'm missing...
I'd like the 1st material to have a texture assigned to it. That texture would be situated in a folder on my C: Drive. This is a "dummy" texture and i would replace it with the right one that is placed in a nearby folder.

What i have so far works fine, if I assign the right bitmap in the 1st material before creating the object. I would prefer not having to go dig out the texture every time I open 3DS Max.

Thanks everyone

03-05-2008, 09:55 PM
So first, we need to get the material in the first slot...the problem is, this may not be a "standard material", so I'm going to set it upfirstMaterial = Standardmaterial()
meditMaterials[1] = firstMaterialNext, we need to assign the "default" bitmap to this texture's diffuse slottxtBitmap = bitmaptexture filename:<insert the path/name for your default bitmap>
firstMaterial.diffuseMap = txtBitmap
firstMaterial.diffuseMapEnabled = trueAnd finally, add the material to your objectmyNewlyCreatedObject.material = firstMaterial
Now obviosuly, you well need to replace "myNewlyCreatedObject" with the reference to your object, but that should help


03-11-2008, 04:28 PM
Thanks a lot for the response! It's all working just fine.

03-11-2008, 04:32 PM
Check this out if you like http://www.paulneale.com/scripts/autoMaterial/autoMaterial.htm what it does is applies materials to objects as they are created with lots of options.

03-11-2008, 10:10 PM
Dang, I've been out done ;)

03-12-2008, 02:44 PM
Don't give up Rusty! Keep at it, and great explaination! +5


CGTalk Moderation
03-12-2008, 02:44 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.