# - Save it to the disk # # Here are the steps to do that # <codecell> # some initial steps from eppy.modeleditor import IDF iddfile = "../eppy/resources/iddfiles/Energy+V7_2_0.idd" # IDF.setiddname(iddfile) # Has already been set # - Let us first open a file from the disk fname1 = "../eppy/resources/idffiles/V_7_2/smallfile.idf" idf_fromfilename = IDF(fname1) # initialize the IDF object with the file name idf_fromfilename.printidf() # <codecell> # - now let us open a file from the disk differently fname1 = "../eppy/resources/idffiles/V_7_2/smallfile.idf" fhandle = open(fname1, 'r') # open the file for reading and assign it a file handle idf_fromfilehandle = IDF(fhandle) # initialize the IDF object with the file handle idf_fromfilehandle.printidf() # <codecell> # So IDF object can be initialized with either a file name or a file handle # - How do I create a blank new idf file
fname1 = "../eppy/resources/idffiles/V_7_2/smallfile.idf" # <codecell> IDF.setiddname(iddfile) idf1 = IDF(fname1) # <markdowncell> # idf1 now holds all the data to your in you idf file. # # Now that the behind-the-scenes work is done, we can print this file. # <codecell> idf1.printidf() # <markdowncell> # Looks like the same file as before, except that all the comments are slightly different. # <markdowncell> # As you can see, this file has four objects: # # - VERSION # - SIMULATIONCONTROL # - BUILDING # - SITE:LOCATION # <markdowncell>
BuildingSurface:Detailed, z2 Roof 0001, !- Name Roof, !- Surface Type , !- Construction Name Thermal Zone 2, !- Zone Name Outdoors, !- Outside Boundary Condition , !- Outside Boundary Condition Object SunExposed, !- Sun Exposure WindExposed, !- Wind Exposure , !- View Factor to Ground , !- Number of Vertices 0.0, !- Vertex 1 Xcoordinate 0.0, !- Vertex 1 Ycoordinate 1.458, !- Vertex 1 Zcoordinate 0.0, !- Vertex 2 Xcoordinate 2.9, !- Vertex 2 Ycoordinate 1.458, !- Vertex 2 Zcoordinate -2.14, !- Vertex 3 Xcoordinate 2.9, !- Vertex 3 Ycoordinate 1.458, !- Vertex 3 Zcoordinate -2.14, !- Vertex 4 Xcoordinate 0.0, !- Vertex 4 Ycoordinate 1.458; !- Vertex 4 Zcoordinate """ idf = IDF() idf.initreadtxt(idftxt) idf.outputtype = 'compressed' idf.printidf()
# if you have not done so, uncomment the following three lines import sys # pathnameto_eppy = 'c:/eppy' pathnameto_eppy = '../../' sys.path.append(pathnameto_eppy) from eppy import modeleditor from eppy.modeleditor import IDF iddfile = "../resources/iddfiles/Energy+V7_2_0.idd" IDF.setiddname(iddfile) idftxt = "" # empty string from io import StringIO fhandle = StringIO(idftxt) # we can make a file handle of a string new_idf = IDF(fhandle) # initialize the IDF object with the file handle # add an object to the idf file objtype = "BUILDING" new_idf.newidfobject(objtype, Name="Taj Mahal") buildings = new_idf.idfobjects["BUILDING"] building = buildings[0] # print building new_idf.newidfobject("LIGHTS", Name="light one") lights = new_idf.idfobjects["LIGHTS"] light = lights[0] print(light) new_idf.printidf()
BuildingSurface:Detailed, z2 Roof 0001, !- Name Roof, !- Surface Type , !- Construction Name Thermal Zone 2, !- Zone Name Outdoors, !- Outside Boundary Condition , !- Outside Boundary Condition Object SunExposed, !- Sun Exposure WindExposed, !- Wind Exposure , !- View Factor to Ground , !- Number of Vertices 0.0, !- Vertex 1 Xcoordinate 0.0, !- Vertex 1 Ycoordinate 1.458, !- Vertex 1 Zcoordinate 0.0, !- Vertex 2 Xcoordinate 2.9, !- Vertex 2 Ycoordinate 1.458, !- Vertex 2 Zcoordinate -2.14, !- Vertex 3 Xcoordinate 2.9, !- Vertex 3 Ycoordinate 1.458, !- Vertex 3 Zcoordinate -2.14, !- Vertex 4 Xcoordinate 0.0, !- Vertex 4 Ycoordinate 1.458; !- Vertex 4 Zcoordinate """ idf = IDF() idf.initreadtxt(idftxt) idf.outputtype = "compressed" idf.printidf()
# # Here are the steps to do that # <codecell> # some initial steps from eppy.modeleditor import IDF iddfile = "../eppy/resources/iddfiles/Energy+V7_2_0.idd" # IDF.setiddname(iddfile) # Has already been set # - Let us first open a file from the disk fname1 = "../eppy/resources/idffiles/V_7_2/smallfile.idf" idf_fromfilename = IDF(fname1) # initialize the IDF object with the file name idf_fromfilename.printidf() # <codecell> # - now let us open a file from the disk differently fname1 = "../eppy/resources/idffiles/V_7_2/smallfile.idf" fhandle = open(fname1, "r") # open the file for reading and assign it a file handle idf_fromfilehandle = IDF( fhandle) # initialize the IDF object with the file handle idf_fromfilehandle.printidf() # <codecell> # So IDF object can be initialized with either a file name or a file handle