Search code examples
scripting3dsmaxmaxscript

Import object location from text file MaxScript


How i can read/import object location data (for every object/model in scene) from textile in MaxScript?

My TextFile: x,y,z,modelname

Thanks.


Solution

  • New line for each record?

    (
        file = memStreamMgr.openFile @"C:\sample.ext"
    
        while NOT file.eos() do
        (
            local line = filterString (file.readLine()) ", "
            if line.count == 4 AND isValidNode (local obj = getNodeByName line[4]) do
                obj.pos = [line[1] as float, line[2] as float, line[3] as float]
        )
        memStreamMgr.close file
    )