First time here? Check out the Help page!
1 | initial version |
This code will do the trick
import eppy
# open some files form the example folder
fname1 = "/Applications/EnergyPlus-9-3-0/ExampleFiles/1ZoneEvapCooler.idf"
idf1 = eppy.openidf(fname1) # will search and find the IDD file if it can :-)
fname2 = "/Applications/EnergyPlus-9-3-0/ExampleFiles/1ZoneParameterAspect.idf"
idf2 = eppy.openidf(fname2) # will search and find the IDD file if it can :-)
# code to merge the idf2 into idf1
for key in idf2.idfobjects:
for idfobject in idf2.idfobjects[key]:
idf1.copyidfobject(idfobject)
idf1.saveas('a.idf') # maybe ....
2 | No.2 Revision |
This code will do the trick
import eppy
# open some files form from the example folder
fname1 = "/Applications/EnergyPlus-9-3-0/ExampleFiles/1ZoneEvapCooler.idf"
idf1 = eppy.openidf(fname1) # will search and find the IDD file if it can :-)
fname2 = "/Applications/EnergyPlus-9-3-0/ExampleFiles/1ZoneParameterAspect.idf"
idf2 = eppy.openidf(fname2) # will search and find the IDD file if it can :-)
# code to merge the idf2 into idf1
for key in idf2.idfobjects:
for idfobject in idf2.idfobjects[key]:
idf1.copyidfobject(idfobject)
idf1.saveas('a.idf') # maybe ....
3 | No.3 Revision |
This code will do the trick
import eppy
# open some files from the example folder
fname1 = "/Applications/EnergyPlus-9-3-0/ExampleFiles/1ZoneEvapCooler.idf"
idf1 = eppy.openidf(fname1) # will search and find the IDD file if it can :-)
fname2 = "/Applications/EnergyPlus-9-3-0/ExampleFiles/1ZoneParameterAspect.idf"
idf2 = eppy.openidf(fname2) # will search and find the IDD file if it can :-)
# code to merge the idf2 into idf1
for key in idf2.idfobjects:
for idfobject in idf2.idfobjects[key]:
idf1.copyidfobject(idfobject)
idf1.saveas('a.idf') # maybe ....
I just noticed that your question says that you do not want to loop thru using copyidfobject(). I can't think of any way of doing the merge without looping through. There is no merge function in eppy. That looping thru is your merge function. I guess eppy is not as eppy-sh as it should be.
4 | No.4 Revision |
This code will do the trick
import eppy
# open some files from the example folder
fname1 = "/Applications/EnergyPlus-9-3-0/ExampleFiles/1ZoneEvapCooler.idf"
idf1 = eppy.openidf(fname1) # will search and find the IDD file if it can :-)
fname2 = "/Applications/EnergyPlus-9-3-0/ExampleFiles/1ZoneParameterAspect.idf"
idf2 = eppy.openidf(fname2) # will search and find the IDD file if it can :-)
# code to merge the idf2 into idf1
for key in idf2.idfobjects:
for idfobject in idf2.idfobjects[key]:
idf1.copyidfobject(idfobject)
idf1.saveas('a.idf') # maybe ....
I just noticed that your question says that you do not want to loop thru using copyidfobject(). I can't think of any way of doing the merge without looping through. There is no merge function in eppy. That looping thru is your merge function. I guess eppy is not as eppy-sh as it should be.
# if you have 5 or 6 idfs
# idfs = [idf1, idf2m idf3, idf4, idf5, idf6]
# untested code follows
version = idfs[0].idfobjects['version'][0]
version_number = version.Version_Identifier
idf_merged = eppy.newidf(version=version_number)
for idf in idfs:
or key in idf.idfobjects:
for idfobject in idf.idfobjects[key]:
idf_merged.copyidfobject(idfobject)
5 | No.5 Revision |
This code will do the trick
import eppy
# open some files from the example folder
fname1 = "/Applications/EnergyPlus-9-3-0/ExampleFiles/1ZoneEvapCooler.idf"
idf1 = eppy.openidf(fname1) # will search and find the IDD file if it can :-)
fname2 = "/Applications/EnergyPlus-9-3-0/ExampleFiles/1ZoneParameterAspect.idf"
idf2 = eppy.openidf(fname2) # will search and find the IDD file if it can :-)
# code to merge the idf2 into idf1
for key in idf2.idfobjects:
for idfobject in idf2.idfobjects[key]:
idf1.copyidfobject(idfobject)
idf1.saveas('a.idf') # maybe ....
I just noticed that your question says that you do not want to loop thru using copyidfobject(). I can't think of any way of doing the merge without looping through. There is no merge function in eppy. That looping thru is your merge function. I guess eppy is not as eppy-sh as it should be.
# if you have 5 or 6 idfs
# idfs = [idf1, idf2m idf3, idf4, idf5, idf6]
# untested code follows
version = idfs[0].idfobjects['version'][0]
version_number = version.Version_Identifier
idf_merged = eppy.newidf(version=version_number)
for idf in idfs:
or for key in idf.idfobjects:
for idfobject in idf.idfobjects[key]:
idf_merged.copyidfobject(idfobject)
6 | No.6 Revision |
This code will do the trick
import eppy
# open some files from the example folder
fname1 = "/Applications/EnergyPlus-9-3-0/ExampleFiles/1ZoneEvapCooler.idf"
idf1 = eppy.openidf(fname1) # will search and find the IDD file if it can :-)
fname2 = "/Applications/EnergyPlus-9-3-0/ExampleFiles/1ZoneParameterAspect.idf"
idf2 = eppy.openidf(fname2) # will search and find the IDD file if it can :-)
# code to merge the idf2 into idf1
for key in idf2.idfobjects:
for idfobject in idf2.idfobjects[key]:
idf1.copyidfobject(idfobject)
idf1.saveas('a.idf') # maybe ....
I just noticed that your question says that you do not want to loop thru using copyidfobject(). I can't think of any way of doing the merge without looping through. There is no merge function in eppy. That looping thru is your merge function. I guess eppy is not as eppy-sh as it should be.
# if you have 5 or 6 idfs
# idfs = [idf1, idf2m idf3, idf4, idf5, idf6]
# untested code follows
version = idfs[0].idfobjects['version'][0]
version_number = version.Version_Identifier
idftxt = "" # empty string
from io import StringIO
fhandle = StringIO(idftxt) # we can make a file handle of a string
idf_merged = eppy.newidf(version=version_number)
IDF(fhandle) # initialize the IDF object with the file handle
for idf in idfs:
for or key in idf.idfobjects:
for idfobject in idf.idfobjects[key]:
idf_merged.copyidfobject(idfobject)
7 | No.7 Revision |
This code will do the trick
import eppy
# open some files from the example folder
fname1 = "/Applications/EnergyPlus-9-3-0/ExampleFiles/1ZoneEvapCooler.idf"
idf1 = eppy.openidf(fname1) # will search and find the IDD file if it can :-)
fname2 = "/Applications/EnergyPlus-9-3-0/ExampleFiles/1ZoneParameterAspect.idf"
idf2 = eppy.openidf(fname2) # will search and find the IDD file if it can :-)
# code to merge the idf2 into idf1
for key in idf2.idfobjects:
for idfobject in idf2.idfobjects[key]:
idf1.copyidfobject(idfobject)
idf1.saveas('a.idf') # maybe ....
I just noticed that your question says that you do not want to loop thru using copyidfobject(). I can't think of any way of doing the merge without looping through. There is no merge function in eppy. That looping thru is your merge function. I guess eppy is not as eppy-sh as it should be.
# if you have 5 or 6 idfs
# idfs = [idf1, idf2m idf3, idf4, idf5, idf6]
# untested code follows
idftxt = "" # empty string
from io import StringIO
fhandle = StringIO(idftxt) # we can make a file handle of a string
idf_merged = IDF(fhandle) # initialize the IDF object with the file handle
for idf in idfs:
or for key in idf.idfobjects:
for idfobject in idf.idfobjects[key]:
idf_merged.copyidfobject(idfobject)
8 | No.8 Revision |
This code will do the trick
import eppy
# open some files from the example folder
fname1 = "/Applications/EnergyPlus-9-3-0/ExampleFiles/1ZoneEvapCooler.idf"
idf1 = eppy.openidf(fname1) # will search and find the IDD file if it can :-)
fname2 = "/Applications/EnergyPlus-9-3-0/ExampleFiles/1ZoneParameterAspect.idf"
idf2 = eppy.openidf(fname2) # will search and find the IDD file if it can :-)
# code to merge the idf2 into idf1
for key in idf2.idfobjects:
for idfobject in idf2.idfobjects[key]:
idf1.copyidfobject(idfobject)
idf1.saveas('a.idf') # maybe ....
I just noticed that your question says that you do not want to loop thru using copyidfobject(). I can't think of any way of doing the merge without looping through. There is no merge function in eppy. That looping thru is your merge function. I guess eppy is not as eppy-sh as it should be.
# if you have 5 or 6 idfs
# idfs = [idf1, idf2m idf3, idf4, idf5, idf6]
# untested code follows
from eppy.modeleditor import IDF
idftxt = "" # empty string
from io import StringIO
fhandle = StringIO(idftxt) # we can make a file handle of a string
idf_merged = IDF(fhandle) # initialize the IDF object with the file handle
for idf in idfs:
for key in idf.idfobjects:
for idfobject in idf.idfobjects[key]:
idf_merged.copyidfobject(idfobject)
idf_merged.saveas('merged.idf') # save() won't work, since you don't have a file name