Maxscript for replacing bitmap path // Help needed


#1

Hi,
I’m trying to create a script with max script that replaces a texture path multiple times in single bitmap. Is there someone that can help me with this? See below a example:

Bitmap1 = the bitmap inside a wood material that contains the wood texture

Bitmap1 = C:\textures\wood1
Render in framebuffer
save framebuffer as C:\renders\wood1

Bitmap1 = C:\textures\wood2
Render in framebuffer
save framebuffer as C:\renders\wood2

Bitmap1 = C:\textures\wood3
Render in fr…


#2

why you say this was replace ?
if you want to change path , retarget to new path
if you want to archive , copy files after retarget
all things need is atsops Retargetting method


#3

It is indeed about changing the path of a bitmap.
Or replacing one path with another.

The properties of the bitmap would preferably not be changed or reset while changing the path.

Could you give an example of how an ATSOps line for changing a path will look like?

Thanks,


#4

there are lots of examples at this forum


#5

Hi AEI,

As someone who has not come further than creating Maxscrips from copying Max Listener.
Therefor all the Maxscript terminology is still unclear for me.
Could you give me some direction to look for on the form.

This is where I have come up with so far:

bitmapname = “bitmap1”

for bmt in getClassInstances bitmaptex do
(
if bmt.name == bitmapname do
bmt.filename = “C:\Users\Desktop\wood1.jpg”
)
actionMan.executeAction 0 “50030”
img = getlastrenderedimage()
img.filename = “C:\Users\Desktop\renders\wood1.jpg”
Save img

for bmt in getClassInstances bitmaptex do
(
if bmt.name == bitmapname do
bmt.filename = “C:\Users\Desktop\wood2.jpg”
)
actionMan.executeAction 0 “50030”
img = getlastrenderedimage()
img.filename = “C:\Users\Desktop\renders\wood2.jpg”
Save img

wood3, wood4, wood5 ect…


#6

are U trying to create maxscript which will :

  1. change material diffuse texture
  2. then will render a frame (save it under name of texture)
  3. repeat

what renderer ?


#7

Correct.

Renderer is Corona Render.

Maps is only not the direct diffuse map, but is a couple of levels deeper (different effects like falloff). That is why I hope to use the bitmap name as variable.


#8

are those maps always on same place (path in material tree) ?


#9

Yes maps are always on the same place in the material tree.
Name of all elements (maps) will stay the same. And material structure will not be altered during running of the script.
Textures are also always in the same folder on the computer (although it would be preferable to be able to use specific paths per texture)


#10

it depend over how many bitmaps ( materials ) would U like to iterate upon.
What kind of folder structure U are using or what naming convention (name of material _ name of texture)?
if U have selected object with material in question and folder structure with textures in png format with naming convention like :
wood1_texmapDiffuse.png, wood1_texmapBump.png, wood1_texmapDisplace.png and
wood2_texmapDiffuse.png, wood2_texmapBump.png, wood2_texmapDisplace.png and
wood3_texmapDiffuse.png, wood3_texmapBump.png, wood3_texmapDisplace.png and
U coud use script like (not real working code just a demo):

path = @"something/something/wood" --put path here
for i = 1 to 3 do
(
    $.material.texmapDiffuse.filename = path + ( i as string) + "_texmapDiffuse.png"
    $.material.texmapBump.filename = path + ( i as string) + "_texmapBump.png"
    $.material.texmapDisplace.filename = path + ( i as string) + "_texmapDisplace.png"

    bm = render()
    bm.filename = @"something/something/out/wood" + ( i as string) + ".png"  -----------------out path
    save bm
    free bm
)

please read help files start small.


#11

what you want is a thumbnail creator
you can create an empty .ifl file in C:\textures\ , if not C drive , can auto create with mxs no need administrator
then set the ifl to your bitmaptex , set render path and other settings

f = openFile @"C:\textures\frames.ifl" mode:"w+"
ofile = getFiles @"C:\textures\*.jpg"
for i in ofile do
format "%\n"  i to:f
close f

up mxs will write all jpg in C:\textures\ to ifl file

max quick render

render all frames , or click render button

nfile=getFiles @"C:\renders\*.jpg"
for i = 1 to ofile.count do
renameFile nfile[i] ((getFilenamePath nfile[i]) + (filenameFromPath ofile[i]))

up mxs will rename files in C:\renders with C:\textures\ names