Friday, November 16, 2007

new version of script

this version of the script will give you all the node values in the form of a list.

The list is formated as Value, X,Y,Z

x,y = get("grid.size")
print("Cells", x, y)
count = 0

for j = 0, y-1 do

line = ""

for i = 0, x-1 do
value = get("grid.cell", i, j, 0)
a, b, c = get("grid.position", i, j)

line = value

excel("start", "Testing")

excel("cell", 1, count)
excel("value", line)
excel("cell", 2, count)
excel("value", a/100)
excel("cell", 3, count)
excel("value", b/100)
excel("cell", 4, count)
excel("value", c/100)

count = count + 1
end

end

Sunday, October 28, 2007

Friday, October 26, 2007

sun tracking commands

If any one wants to have objects track objects in your file these are good commands to start your research with.

--find the orientation to the sun
--query that result
cmd("object.normal", objNum, 0)
--asumiuth
azm = get("object.angle", objNum, 3)
--altitude
alt = get("object.angle", objNum, 1)

--orient the alt and use the lock angle for the azmith
cmd("object.orient", objNum, azm, angLock)

Friday Class

This is the sript we wrote in class friday. Enjoy....

x,y = get("grid.size")
print("Cells", x, y)

for j = 0, y-1 do

line = ""

for i = 0, x-1 do
value = get("grid.cell", i, j, 0)

line = value

excel("start", "Testing")

excel("cell", j, i)
excel("value", line)

end

end

Tuesday, October 2, 2007

Cycling Through Dates





This script gives builds on the previous example. This example cycles through months and checks the temperature of a wall after doing a spatial comfort calculation.

filename = getUserFile(1, "Save Script Output to...")


file = openfile (filename, "w")

for i = 0,11,1 do

set("model.date", 21, i, 14)
wallTemp = get("object.attr2", 1)
write(file, wallTemp)
write(file, "\n")

end

closefile(file)

For the second iteration of this script we will tell the script to check what happens when you change the material of the surface that we are analyzing. To do this you will need to build an array of material index numbers. To do this you execute the following commands.

matIndex = {}
matIndex[0] = get("material.index", "ConcBlockPlaster")
matIndex[1] = get("material.index", "FramedTimberPlaster")

print(matIndex[1])

set("object.material", 1, matIndex[1])

Now, we need to build this into the existing script that we have been working on by adding a second loop that iterates through the materials.

matIndex = {}
matIndex[0] = get("material.index", "ConcBlockPlaster")
matIndex[1] = get("material.index", "FramedTimberPlaster")

filename = getUserFile(1, "Save Script Output to...")

for x = 0,1,1 do

set("object.material", 1, matIndex[x])

cmd("app.menu", "calculate.comfort", 0)

file = openfile (filename, "a")

for i = 0,11,1 do

set("model.date", 21, i, 14)
wallTemp = get("object.attr2", 1)
write(file, wallTemp)
write(file, "\n")

end
end

closefile(file)


Sunday, September 30, 2007

Drag and Drop



These few video tutorials show you how the script editor in Ecotect makes it extremely easy to write scripts using the "drag and drop" style code editor.



first you will open the ecotect script editor



to start you will want to write this simple framework for exporting data to a txt file.

the code will look like this.

filename = getUserFile(1, "Save Script Output to...")

file = openfile (filename, "w")

write(file, "Print this text to the selected file.")

closefile(file)



next you will want to use the drag and drop code editor to drop in some predefined code that iterates though the analysis grid in ecotet.

under the script editor language help you will go to Example Code templates > User Defined Templates > Customizing your templates > Cycle through grid data and drop that item into your editor window.

when you are done your code will look like this...

filename = getUserFile(1, "save script output to....");

file = openfile (filename, "w");

x,y = get("grid.size")
print("Cells", x, y)

for j = 0, y-1 do

line = ""

for i = 0, x-1 do
value = get("grid.cell", i, j, 0)
line = line..format("%0.4f, ", value);
write(file, value);
write(file, "\n");
end

print(line)

end


closefile(file);

Basics

variable types

integers
x = 1
x,y,z = 5

strings are in quotations
name = "string"

tables can store many variables

table = {1,2,3,4,5,6}
print(table[1])
print(table[4])


you can organize you code into functions if you plan to reuse the same command many times.

function function_name ( args ) body end

function count(n)
return n*2
end

// use the count function

cont(7)

loops

this for loop will print the letter i 11 times
for i = 0, 10 do
print(i)
end