[Closed] Billboards from all bitmaps in a folder
I am working on a script to build image planes from tif files (could be anything with an alpha). I have learned and pieced it together from several other scripts. You can see I’m using VRay. That part should be easy for anyone to adopt to their own renerer.
I had it working and created 100 billboards, but after restarting max, the script no longer works. I had help from our scripting guy along the way but he has gone home. I obviously had defined some global that it still was using… but now I can’t remember what it was…
I’m sure it is something simple.
(I can’t include the full path here, subsituted part of it. I also tried to shorten the indents to make it read better here)
files = getFiles "\\\\--UNC_Path\\resources\\materials\\images\\People\\RealWorldImagry\\urbanmoods\\32bitTIFimages\ emp\\*.tif" --will be variable later
(for f = 1 to files.count do
(
local theMap = bitmap 10 10 color:white
theMap.filename = files[f]
-- Get the ratio of the bitmap and set the length and width acordingly
local planeRatio = (theMap.width as float)/(theMap.height as float)
(
local theLength = 68 --will be variable later
local theWidth = theLength*PlaneRatio
)
--Set naming
local refPlaneName = (getFilenameFile theMap.filename)
--build material
local matName = (getFilenameFile theMap.filename)
local theMaterial = VRayMtl() name = refPlaneName
theMaterial.texmap_diffuse = Bitmaptex bitmap:theMap name:(refPlaneName + "_Diffuse")
theMaterial.texmap_diffuse.coords.blur = 0.01
theMaterial.texmap_opacity = Bitmaptex bitmap:theMap name:(refPlaneName + "_Opacity")
theMaterial.texmap_opacity.rgboutput = 1
theMaterial.texmap_opacity.monooutput = 1
theMaterial.texmap_opacity.coords.blur = 0.01
showTextureMap theMaterial theMaterial.texmap_diffuse on
--build plane
local refPlane = plane name:refPlaneName length:theLength width:theWidth lsegs:1 wsegs:1 mapCoords:true
refplane.material = theMaterial
refplane.realWorldMapSize = off
refplane.lengthsegs = 1
refplane.widthsegs = 1
--position the plane
in coordsys (transmatrix refplane.transform.pos) refplane.rotation = (eulerangles -90 0 0)
ResetXForm refplane ; CollapseStack refplane
refplane.pivot = [(refplane.max.x+refplane.min.x)/2, refplane.min.y, refplane.min.z]
refplane.pos = [0,0,0]
)
)
I get the error:
#("\\--UNC_Path\resources\materials\images\People\RealWorldImagry\urbanmoods\32bitTIFimages emp\peopl400.tif", "\\--UNC_Path\resources\materials\images\People\RealWorldImagry\urbanmoods\32bitTIFimages emp\peopl401.tif", "\\--UNC_Path\resources\materials\images\People\RealWorldImagry\urbanmoods\32bitTIFimages emp\peopl402.tif", "\\--UNC_Path\resources\materials\images\People\RealWorldImagry\urbanmoods\32bitTIFimages emp\peopl403.tif", "\\--UNC_Path\resources\materials\images\People\RealWorldImagry\urbanmoods\32bitTIFimages emp\peopl404.tif", "\\--UNC_Path\resources\materials\images\People\RealWorldImagry\urbanmoods\32bitTIFimages emp\peopl405.tif")
-- Error occurred in f loop; filename: C:\Program Files (x86)\Autodesk\3ds Max 9\Scripts\UserScripts\MyTools_BitmapPlanesFromFiles.ms; position: 817
-- Frame:
-- theMaterial: VRayMtl:VRayMtl
-- planeRatio: 1.33333
-- refPlane: undefined
-- refPlaneName: "peopl400"
-- name: "peopl400"
-- matname: "peopl400"
-- theLength: 68
-- thewidth: 90.6667
-- f: 1
-- called in anonymous codeblock
-- Frame:
-- Runtime error: Assignment failed, the bitmap should be saved first, BitMap:\\--UNC_Path\resources\materials\images\People\RealWorldImagry\urbanmoods\32bitTIFimages emp\peopl400.tif
OK
Any help would be primo,
Thanks,
Jonah
Only thing unusual I see is the length and width being defined as “local” and inside () but somehow being seen outside. I would have expected them to be local to the () but somehow they’re escaping. what happens if yout ake the length and width definitions outside of the ()?
Can you add some “print “1″” “Print “2″” declarations along the way to determine exactly where it’s failling? Or does it highlight a specific line?
wow thanks for the fast reply.
same error
-- Error occurred in f loop; filename: C:\Program Files (x86)\Autodesk\3ds Max 9\Scripts\UserScripts\MyTools_BitmapPlanesFromFiles.ms; position: 856
-- Frame:
-- theMaterial: VRayMtl:VRayMtl
-- theMap: BitMap:------\resources\materials\images\People\RealWorldImagry\urbanmoods\32bitTIFimages emp\peopl400.tif
-- planeRatio: 1.0
-- refPlane: undefined
-- refPlaneName: "peopl400"
-- name: "peopl400"
-- matname: "peopl400"
-- theLength: 68
-- thewidth: 68.0
-- f: 1
-- called in anonymous codeblock
-- Frame:
-- Runtime error: Assignment failed, the bitmap should be saved first, BitMap:
I should have credited Jon Seagull for his script Proportional Planes
http://www.scriptspot.com/3ds-max/proportional-plane
I’m a bit confused as to which line it’s happening on.
It looks like it’s happening after the VRay Material is defined but *before the plane is created.
Could you verify that by inserting a couple of print statements to see what the last printed print statement is?
I could if I knew what you meant…:hmm:
I assume you mean, for example:
print theMaterial
which variables should I print?
local theMaterial = VRayMtl() name = refPlaneName
I’m suspicious of this line. That isn’t proper Maxscript grammar.
It should be something like
thematerial = VrayMtl()
thematrial.name = refPlaneName
or
TheMaterial = VrayMtl name:refPlaneName
No need to print specific variables. Just print “Hello 1” “hello 2” “hello 3”
What’s important is where the last print successfully executed before crashing not what it prints.
that looks familiar… like i had that somewhere before…
This is what I get for butchering other people’s work.
I’ll give it a go and get back…
Thanks for the continued help.
It looks like it is breaking on the next line now
theMaterial.texmap_diffuse = Bitmaptex bitmap:theMap name:(refPlaneName + "_Diffuse")
Error:
Runtime error: Assignment failed, the bitmap should be saved first, BitMap:....\resources\materials\images\People\RealWorldImagry\urbanmoods\32bitTIFimages emp\peopl400.tif
this was all working an hour ago. I have a scene file with 100 planes with materials and maps named accordingly…
EDIT: I see what you mean with the printing. that helps to see how far into the script it gets and wheather or not the results are as expected. Nice tip for the nooby me.
What’s the error? I don’t have VRay so I can’t help on any VRay Mat specific stuff.
Ok I just rewrote it to work with standard and I get the same error as you are getting… weird… It’s not Vray related and it’s definitely in that BitmapTex line.