Question-and-Answer Resource for the Building Energy Modeling Community
Get started with the Help page
Ask Your Question
3

call an idf object field value for use in another object field

asked 2016-08-23 16:23:36 -0600

Alex Vlachokostas's avatar

updated 2016-08-23 16:24:20 -0600

I want to dynamically assign the Vertex values of the following surface

Shading Surface 1, !- Name , !- Transmittance Schedule Name , !- Number of Vertices 0, 2.5, 4.572, !- X,Y,Z Vertex 1 {m} 0, 0, 4.572, !- X,Y,Z Vertex 2 {m} 1.22, 0, 4.572, !- X,Y,Z Vertex 3 {m} 1.22, 2.5, 4.572; !- X,Y,Z Vertex 4 {m}

based on some calculations that include the latitude of the site.

Site:Location, Tampa International Ap, !- Name 27.97, !- Latitude {deg} -82.53, !- Longitude {deg} -5, !- Time Zone {hr} 6; !- Elevation {m}

I would like to call the 27.97 latitude value. Any tips? The following example is useful but not exactly what I am looking for: Group Parametrics

Thank you.

edit retag flag offensive close merge delete

Comments

You need something that works outside of the IDF file. Like an OpenStudio Measure or Eppy.

__AmirRoth__'s avatar __AmirRoth__  ( 2016-08-23 16:25:24 -0600 )edit

Thank you @__AmirRoth__ !

Alex Vlachokostas's avatar Alex Vlachokostas  ( 2016-08-23 19:10:36 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
3

answered 2016-08-23 17:48:13 -0600

As @__AmirRoth__ says, you need something outside of EnergyPlus to do this. That could be Eppy, as in the script below.

from eppy.iddcurrent import iddcurrent
from eppy.modeleditor import IDF
from future.moves.itertools import zip_longest
from six import StringIO


iddsnippet = iddcurrent.iddtxt
iddfhandle = StringIO(iddcurrent.iddtxt)
IDF.setiddname(iddfhandle)

def adjust_coords(surface, latitude):
    coords = surface.coords

    # do what you want with the coords here

    # make the coords into a flattened list
    coords = [i for point in coords for i in point]
    # find the vertex fields
    n_vertices_index = surface.objls.index('Number_of_Vertices')
    last_item = len(surface.obj)
    first_item = n_vertices_index + 1 # X of first coordinate
    vertex_fields = surface.objls[first_item:last_item]

    # set the vertex field values
    for field, x in zip_longest(vertex_fields, coords, fillvalue=""):
        surface[field] = x


idf = IDF()
idf.initreadtxt('my_base.idf')
shading_surfaces = idf.idfobjects['SHADING:BUILDING:DETAILED']
latitude = idf.getobject('SITE:LOCATION', 'Tampa International Ap').Latitude

for surface in shading_surfaces:
    adjust_coords(surface, latitude)

idf.save('my_new.idf')
edit flag offensive delete link more

Comments

1

Thank you @Jamie Bull for the code example! Extremely helpful!

Alex Vlachokostas's avatar Alex Vlachokostas  ( 2016-08-23 19:12:56 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Training Workshops

Careers

Question Tools

1 follower

Stats

Asked: 2016-08-23 16:23:36 -0600

Seen: 121 times

Last updated: Aug 23 '16