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

Important Concepts/Commands

For this tutorial there are a few key concepts/commands you will need to understand if you want to begin to export your own data sets from Ecotect.

Firstly, it is important to know where you can store data after calculations are performed and how to access that data after calculations are finished.

- All objects in Ecotect can hold up to three attributes. What these attributes are will change depending on what you kind of calculations you ask the software to preform.

Accessing the attributes:

get.object.XXX object
set.object.XXX object value

result = get("object.attr1", object)

XXX can equal any of the following....



area Surface area (m²) - if planar.
exposure Surface area exposed to outside conditions (m²) - if planar.
length Total length (m) - if linear.
underground Surface area exposed to ground conditions (m²) - if planar.
panelarea Surface overlapping a WINDOW / DOOR in adjacent zone (m²)
resolution Curve resolution for virtual polylines.
attr1 Calculated Attribute Number 1.
attr2 Calculated Attribute Number 2.
attr3 Calculated Attribute Number 3.
index Calculated Numerical Index.

Exporting to Microsoft Excel:

excel("start", "Testing")

-- Fill up 15 rows of data
for i = 1, 15 do
excel("cell", 3, i)
excel("value", i*5)
end

-- Add a formula to the bottom cell.
excel("cell", 5, 16)
excel("value", "=SUM(E1:E15)")
excel("font bold")

-- Make the cell in the 9th row bold and italic.
excel("cell", 5, 9)
excel("font", "bold italic")


Export to a .txt file:

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

file = openfile (filename, "w")

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

closefile(file)


if you want to export the contents of ecotect's annalysis grid to a text file your code would look like this. (as outlined in the above tutorial.)


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);