Notifications
Clear all

[Closed] Applying a texture on creation of an object?

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

5 Replies

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 up

firstMaterial = Standardmaterial()
 meditMaterials[1] = firstMaterial

Next, we need to assign the “default” bitmap to this texture’s diffuse slot

txtBitmap = bitmaptexture filename:<insert the path/name for your default bitmap>
 firstMaterial.diffuseMap = txtBitmap
 firstMaterial.diffuseMapEnabled = true

And finally, add the material to your object

myNewlyCreatedObject.material = firstMaterial

Now obviosuly, you well need to replace “myNewlyCreatedObject” with the reference to your object, but that should help

Shane

Thanks a lot for the response! It’s all working just fine.

 PEN

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.

Dang, I’ve been out done

Don’t give up Rusty! Keep at it, and great explaination! +5

-Colin