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)


No comments: