Notifications
Clear all

[Closed] assigning a texturemap via maxscript

I’m currently writing a little tool to go through all textures assigned to geo in my scene and change their texture-maps from .psd to .tga. I have got all my loops working fine to take their existing filename and create a string which is the corresponding .tga version (all textures will share the same name but with the different extension).

However I seem to have hit a roadblock actually using this string to change the currently used texture. So going back to basics I have just written the following;

myBmp = “c:\512.tga”
isValid = doesFileExist myBmp
$.mat.materialList[1].diffuseMap = myBmp

What I am not understanding is that I get an error saying;

– Unable to convert: “c:\512.tga” to type: TextureMap

Now I know that that texture exists because isValid returns true. I’m sure I am doing something blatently obvious but I can’t figure what!

Any suggestions would be great.

2 Replies

I think the issue is because you need to stick the map inside a bitmap texture map. You are trying to map an image off disk, but the image must be placed inside the bitmap. So create a bitmaptexture and assign your map to it, then assign it to the diffuse slot or, assign a bitmaptexture to the diffusemap, then set .filename parameter to the image file.

meditamterials[1].diffusemap = bitmaptexture
meditmaterials[1].diffusemap.filename = myBmp

or

myBmp = bitmaptexture filename:"c:\512.tga"
meditmaterials[1].diffusemap = myBmp

-Eric

awesome thanks very much