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

# Revision history [back]

For the first question, you can create a second IDF and add the extracted objects to it.

surfaces = idf.idfobjects['BUILDINGSURFACE:DETAILED']
windows = idf.idfobjects['WINDOW']

idf2 = IDF()
idf2.new()
for s, w in zip(surfaces, windows):
idf.copyidfobject(s)
idf.copyidfobject(w)


For the second question, IDF.saveas() is just to change the filename. It doesn't really make sense to save it as a CSV since each object has different fields. I suppose you could do something like:

with open('out.csv', 'w') as f_out:
f_out.write(','.join(str(i) for i in headers) + '\n')
for row in rows:
f_out.write(','.join(str(i) for i in row) + '\n')


Alternatively you could open up the IDF in the OpenStudio SketchUp plugin to get a visualisation of the surfaces and windows in the model.

For the first question, you can create a second IDF and add the extracted objects to it.

surfaces = idf.idfobjects['BUILDINGSURFACE:DETAILED']
windows = idf.idfobjects['WINDOW']

idf2 = IDF()
idf2.new()
for s, w in zip(surfaces, windows):
idf.copyidfobject(s)
idf2.copyidfobject(s)
idf.copyidfobject(w)
idf2.copyidfobject(w)


For the second question, IDF.saveas() is just to change the filename. It doesn't really make sense to save it as a CSV since each object has different fields. I suppose you could do something like:

with open('out.csv', 'w') as f_out:
f_out.write(','.join(str(i) for i in headers) + '\n')
for row in rows:
f_out.write(','.join(str(i) for i in row) + '\n')


Alternatively you could open up the IDF in the OpenStudio SketchUp plugin to get a visualisation of the surfaces and windows in the model.

For the first question, you can create a second IDF and add the extracted objects to it.

# get the geometry objects
surfaces = idf.idfobjects['BUILDINGSURFACE:DETAILED']
windows = idf.idfobjects['WINDOW']

# make a new empty IDF
idf2 = IDF()
idf2.new()

# copy the geometry objects into the new IDF
for s, w in zip(surfaces, windows):
idf2.copyidfobject(s)
idf2.copyidfobject(w)

# save the geometry as an IMF for use by EPMacro
idf2.saveas('geometry.imf')


For the second question, IDF.saveas() is just to change the filename. It doesn't really make sense to save it as a CSV since each object has different fields. I suppose you could do something like:

with open('out.csv', 'w') as f_out:
f_out.write(','.join(str(i) for i in headers) + '\n')
for row in rows:
f_out.write(','.join(str(i) for i in row) + '\n')


Alternatively you could open up the IDF in the OpenStudio SketchUp plugin to get a visualisation of the surfaces and windows in the model.

For the first question, you can create a second IDF and add the extracted objects to it.

# get the geometry objects
surfaces = idf.idfobjects['BUILDINGSURFACE:DETAILED']
windows = idf.idfobjects['WINDOW']

# make a new empty IDF
idf2 = IDF()
idf2.new()

# copy the geometry objects into the new IDF
for s, w in zip(surfaces, windows):
idf2.copyidfobject(s)
idf2.copyidfobject(w)

# save the geometry as an IMF for use by EPMacro
idf2.saveas('geometry.imf')


For the second question, IDF.saveas() is just to change the filename. It doesn't really make sense to save it as a CSV since each object has different fields. I suppose you could do something like:

headers = surfaces[0].objls  # get the column headers as a list
rows = [s.obj for s in surfaces] # get the values as a list of lists
with open('out.csv', 'w') as f_out:
f_out.write(','.join(str(i) for i in headers) + '\n')
for row in rows:
f_out.write(','.join(str(i) for i in row) + '\n')


Alternatively you could open up the IDF in the OpenStudio SketchUp plugin to get a visualisation of the surfaces and windows in the model.

For the first question, you can create a second IDF and add the extracted objects to it.

# get the geometry objects
surfaces = idf.idfobjects['BUILDINGSURFACE:DETAILED']
windows = idf.idfobjects['WINDOW']

# make a new empty IDF
idf2 = IDF()
idf2.new()

# copy the geometry objects into the new IDF
for s, w in zip(surfaces, windows):
idf2.copyidfobject(s)
idf2.copyidfobject(w)

# save the geometry as an IMF for use by EPMacro
idf2.saveas('geometry.imf')


For the second question, IDF.saveas() is just to change the filename. It doesn't really make sense to save it as a CSV since each object has different fields. I suppose you could do something like:

headers = surfaces[0].objls  # get the column headers as a list
rows = [s.obj for s in surfaces] # get the values as a list of lists
with open('out.csv', 'w') as f_out:
f_out.write(','.join(str(i) for i in headers) + '\n')
for row in rows:
f_out.write(','.join(str(i) for i in row) + '\n')


Alternatively you could open up the IDF in the OpenStudio SketchUp plugin to get a visualisation of the surfaces and windows in the model.

In response to your comment, you need to tell eppy which output variable you want to remove from the IDF. The simple case first:

# to remove them all
for variable in idf.idfobjects['OUTPUT:VARIABLE']:
idf.removeidfobject(variable)


Removing a specific variable can be a bit tricky though. Since they don't have a Name field we can't select them using idf.getobject('OUTPUT:VARIABLE', name). They do have a Key_Value field, though this is often *, and a Variable_Name field. We can use those in a list comprehension to filter out the variable or variables to remove.

# to remove all variables of a given Variable_Name
name = "Electric Equipment Electric Energy"
variables = [v for v in idf.idfobjects['OUTPUT:VARIABLE'] if v.Variable_Name == name]
for variable in variables :
idf.removeidfobject(variable)

# to remove variables with a given Variable_Name with a specific Key_Value
key_value = "PrimaryHeater"
name = "Boiler Gas Energy"
variables = [v for v in idf.idfobjects['OUTPUT:VARIABLE']
if v.Variable_Name == name
and v.Key_Value == key_value]
for variable in variables :
idf.removeidfobject(variable)