[Closed] Batch diffuse map from folder
Hi everyone,
I’m trying to write a batch script to get all the jpg files from a selected folder into the diffuse slot of all the different materials in the material editor. However, I’m having problems finding out how (if at all) it can be done.
I found a similar script which its diffuse map bitmap based on the scene objects name. I’m trying to do the opposite, which is, getting the bitmap into the diffuse map slot , from there create planes with the bitmap’s name and assign the bitmap onto it.
Any ideas anyone? Thanks in advance for any replies
Hi,
thanks for the quick reply
after tweaking the script I got this
(
files=getfiles "D:\\Image\\*.jpg"
for i=1 to files.count do
(
m=standard()
m.diffuseMap=bitmaptexture filename:files[i]
m.selfIllumAmount = 100
meditMaterials[i]=m
newplane = plane widthsegs:1 lengthsegs:1
newplane.material = m
newplane.length = newplane.material.diffusemap.bitmap.height
newplane.width = newplane.material.diffusemap.bitmap.width
showtexturemap newplane.material on
)
)
But its still far from complete. Gonna rename the materials and object to their respective bitmap, reposition the planes and figure out how solve the error if there are more the 24 bitmap files… maybe by reseting material edit slot everytime it reaches 25.
Thanks again for help out a noobie
You don’t need to load the material into the editor to edit it in MaxScript…
Look at “StandardMaterial” in the MaxScript help… all of those variables are available to you WITHOUT loading it to the editor…
You may want to define the bitmap texture to a temp variable, then you can easly get the .filename property…
TempBitmap = bitmapTexture filename:files[i]
TempMat = StanardMaterial()
TempMat.DiffuseMap = TempBitmap
Use ,( getfilenamefile TempBitmap.filename ), and you can name your object and material with the name of the bitmap file…
Newplane.name = getfilenamefile TempBitmap.filename
Newplane.height = TempBitmap.height
ect.
good luck