Archive site for Autodesk Ecotect Analysis educational resources, notes and tutorials



Script example 07

GetGridCellData.scr

This script shows how you can obtain data directly from the current analysis grid. It is quite simple in that it just outputs the rows and columns as raw coma-separated data values, however it illustrates all the basics.

Script Contents (Lang: lua)

-- -----------------------------------------------
-- DISPLAY GRID CELL DATA:
-- This script cycles through the current analysis
-- grid and prints out its contents.
-- -----------------------------------------------

-- Specify index if data required (0-4).
gridData = 0

-- Print out basic info about grid.
print("Title:", get("grid.title"))
print("Data:", get("grid.description"), get("grid.units"))

-- Get current grid scale.
gmin,gmax,inc = get("grid.scale")
print("Scale:", gmin, gmax, inc)

-- Get rows and columns.
x,y = get("grid.size")
print("Cells:", x, y)

-- Cycle rows.
for j = 0, y-1 do

    -- Start with empty string.
    line = ""

    -- Cycle columns.
    for i = 0, x-1 do
                
        -- Get value in index 0 at column i and row j.
        value = get("grid.cell", i, j, 0)
                
        -- Append value to string.
        line = line .. format("%0.4f, ", value);

    end

    -- Print string.
    print(line) 

end

HOW WOULD YOU RATE THIS SCRIPT ?

No votes yet


Navigation

User login

Translate Site To: