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



Cubits - create an array of cubes

This script will create a grid of cubes with user defined quantity, size and spacing.

Script Contents (Lang: lua)

cmd("wizard.load cubes1.wzd")




set("wizard.Page1.XCubes.OnChange HandleXChange")
set("wizard.Page1.YCubes.OnChange HandleYChange")
set("wizard.Page1.Length.OnChange HandleLengthChange")
set("wizard.Page1.Space.OnChange HandleSpace")

function HandleXChange(pageName, itemName)
    set("wizard.Page1.Visible", true)
end

function HandleYChange(pageName, itemName)
    set("wizard.Page1.Visible", true)
end

function HandleLengthChange(pageName, itemName)
    set("wizard.Page1.Visible", true)
end

function HandleSpace(pageName, itemName)
    set("wizard.Page1.Visible", true)
end

cmd("wizard.show")
cmd("app.activate")
cmd("model.new")

CubesZone = get("zone.index", "Cubes")
if CubesZone > 0 then
    set("zone.current", CubesZone)
else -- Create new zone called 'Cubes'.
    add("zone", "Cubes")
end


-- setup variables
XDir = get("wizard.Page1.XCubes.Text")
YDir = get("wizard.Page1.YCubes.Text")
Space = get("wizard.Page1.Space.Text")
Length = get("wizard.Page1.Length.Text")


-- set origin
set("model.origin", 0, 0, 0)

-- draw a cube
function DrawCube(x,y,size)
   obj = add("object", "floor", "plane", true)
   add("node", obj, 0, x, y, 0)
   add("node", obj, 1, x+size, y, 0)
   add("node", obj, 2, x+size, y+size, 0)
   add("node", obj, 3, x, y+size, 0)
   set("object.done")
   cmd("object.extrude", obj, 0, 0, size)
end


for x = 1, XDir, 1 do
cmd("view.redraw")
pause(200)
      for y = 1, YDir, 1 do
           DrawCube (x*(Length*Space), y*(Length*Space), Length)

      end
end


cmd("view.fit")
cmd("view.redraw")

AttachmentSize
cubes1.wzd149.65 KB

HOW WOULD YOU RATE THIS SCRIPT ?

No votes yet


Navigation

User login

Translate Site To: