undefined bitmap value for missing bitmap in scene
I'm working on a script that write a text file where collect all the bitmap path for each material in scene.
What I've done for now seems to works well, but only if all the maps are in some known folder.
If a material has a missing bitmapon it, it returns an error, due to a "undefined" value.
Here is my code.
txt = createfile "C:\bitmaplist.txt" MatID = 0 for mat in sceneMaterials do ( format "MATERIAL: = Mat-% = % = %\n" MatID mat.name (classof mat) to:txt for prop in (getPropNames mat) do ( propVal = ((getProperty mat prop) as string) if (matchPattern propVal pattern:"*Bitmap") == true do ( bitmapPath = (getProperty mat prop).bitmap bitmapFileName = trimleft (bitmapPath as string) "BitMap:" scenePath = substituteString (bitmapNewPath as string) "\\" "//" format " Mat-% = % = Bitmap:%%\n" MatID (prop as string) scenePath bitmapFileName to:txt ) ) format "\n\n" to:txt MatID = MatID + 1 )
There are 5 days that I try to find a solution, without results.
Someone can help me, please?
Comments
Max2013 + Vray. I created 2
Max2013 + Vray. I created 2 teapots and added bmp1.bmp to the Bump slot of Teapot001 and bmp2,bmp to the Bump slot of Teapot002.
When I run you rscript everything is fine. I rename bmp2.bmp to bmp3.bmp, run the script and again everything is fine. The script prints old bitmap name. Strange.
Try this
instead of this:
It works for me and returns the file Path and file name of the bitmap in both cases.
Maybe I am doing something wrong.
Tools and Scripts for Autodesk 3dsMax
Yeah!
Yeah! With .filename the script works perfectly, thanks! :)
Glad to help. :)
Glad to help. :)
Tools and Scripts for Autodesk 3dsMax
...
Maybe this can help somehow
Let say that we already collect all scene maps whitch contains some filename path in array named "scene_maps".
Then we can print anything in this case map name , property which include this path and file path
bga
...
I think that previous code supports any maps types (from differen render engines and plugins)
bga
I can't reproduce the error
I can't reproduce the error that you describes, but find which variable is undefined(when there is material with missing bitmaps) and on the next line of your script use
Tools and Scripts for Autodesk 3dsMax
Thanks miauuFor now i used
Thanks miauu
For now i used this solution to bypass the problem and continue to develop the rest of the script (writing path is only a little part of it).
But now I need absolutely to solve the problem... and I haven't found a solution yet.
To replicate the error, choose a scene that have a material with at least a bitmap.
Running the script, you get a txt file with the bitmap path wrote on it.
Here is what I see if the file is found:
Now, look at the folder where the bitmap is and temporary rename it.
Open the max file again and run the script.
You'll probably get something like this:
Looking on the material, at the bump node I see the name of the bitmap file used.
But if i call via script the texmap_bump value, maxscript give me "undefined" instead of the file name.
What make me crazy is that in
What make me crazy is that in the error message max returns correctly the name of the bitmap i need!!
Reading the message, seems like he's trying to open the file...but I don't want to open it. I need only his name, nothing more!!