jonahhawk
07-24-2008, 02:24 AM
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\\temp\\*.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\temp\peopl400.tif", "\\--UNC_Path\resources\materials\images\People\RealWorldImagry\urbanmoods\32bitTIFimages\temp\peopl401.tif", "\\--UNC_Path\resources\materials\images\People\RealWorldImagry\urbanmoods\32bitTIFimages\temp\peopl402.tif", "\\--UNC_Path\resources\materials\images\People\RealWorldImagry\urbanmoods\32bitTIFimages\temp\peopl403.tif", "\\--UNC_Path\resources\materials\images\People\RealWorldImagry\urbanmoods\32bitTIFimages\temp\peopl404.tif", "\\--UNC_Path\resources\materials\images\People\RealWorldImagry\urbanmoods\32bitTIFimages\temp\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\temp\peopl400.tif
OK
Any help would be primo,
Thanks,
Jonah
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\\temp\\*.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\temp\peopl400.tif", "\\--UNC_Path\resources\materials\images\People\RealWorldImagry\urbanmoods\32bitTIFimages\temp\peopl401.tif", "\\--UNC_Path\resources\materials\images\People\RealWorldImagry\urbanmoods\32bitTIFimages\temp\peopl402.tif", "\\--UNC_Path\resources\materials\images\People\RealWorldImagry\urbanmoods\32bitTIFimages\temp\peopl403.tif", "\\--UNC_Path\resources\materials\images\People\RealWorldImagry\urbanmoods\32bitTIFimages\temp\peopl404.tif", "\\--UNC_Path\resources\materials\images\People\RealWorldImagry\urbanmoods\32bitTIFimages\temp\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\temp\peopl400.tif
OK
Any help would be primo,
Thanks,
Jonah
