Scripted Billboard people generator

posted here as a response to this thread:

Works on a folder full of images with alpha channels. Keeps the proportion. Makes all the billboards the same height…

-- simple Scripted Billboard creator. Operates on a folder full of images. Will add an interface and variables, saved paths etc later. Suggestions welcome jonahhawk at hotmail.com. 

files = getFiles "\\\\server\\path\\*.tif" --edit this to match the path to your images.

(        
    for f = 1 to files.count do 
        (    
            theMap = openBitMap files[f]
            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 --This is the height of the billboards... all of them. will add randomness maybe...
                    local theWidth = theLength*PlaneRatio
                    )

                --Set naming
                    local refPlaneName = (getFilenameFile theMap.filename)

                --build material 
                    local matName = (getFilenameFile theMap.filename)
                    local theMaterial = VRayMtl()
                    theMaterial.name = refPlaneName
                    theMaterial.texmap_diffuse = Bitmaptexture fileName:theMap.filename
                    theMaterial.texmap_diffuse.name = (refPlaneName + "_Diffuse")
                    theMaterial.texmap_diffuse.coords.blur = 0.01
                    theMaterial.texmap_opacity = Bitmaptexture fileName:theMap.filename
                    theMaterial.texmap_opacity.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 off

                --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]
                )
                --clean up
                freescenebitmaps()
                gc()
)