First time here? Check out the Help page!
1 | initial version |
This is not the best solution, but it's what has worked for me at the moment. I'm using Python to automate the process of launching the IDF Editor, opening an IDF file, changing the version number, saving the file (thus achieving the desired sorting), changing the version number back, saving again[, repeating if required until all files are sorted], and closing the IDF Editor.
When run from a folder it loops through all the IDF files in the folder and sorts them before closing the IDF Editor. This might mean you run into memory problems when sorting hundreds of files - I haven't tried it yet so don't know what the limits are - but it would be easy enough to adapt to take batches of say ten or twenty at a time.
I also had a look at pywinauto
but ran into problems finding the right place to enter values in the IDF Editor GUI. If anyone has any tips on that please let me know.
Hope this helps someone out.
"""
idf_editor.sorter
~~~~~~~~~~~~~~~~~
A simple script which controls the IDF Editor application, taking advantage of
the fact that it tidies up the file when saving.
It would be better if this could happen in the background but the simplest way
to control IDF Editor from Python is using SendKeys which requires the window
to be in the foreground.
This script should be run from the folder containing the IDF files to be sorted.
Filenames will be unaffected.
"""
import os
import time
import win32com.client
EPLUS_VERSION = '8.1' # The EnergyPlus version number of the IDFs to be sorted
IDF_EDITOR_PATH = "C:\EnergyPlusV8-1-0\PreProcess\IDFEditor\IDFEditor.exe"
shell = win32com.client.DispatchEx("WScript.Shell")
shell.Run(IDF_EDITOR_PATH)
shell.AppActivate("IDF Editor")
time.sleep(1)
def sort_idf(idf_name):
shell.SendKeys("^o")
time.sleep(1) # Wait for dialog to open
shell.SendKeys(idf_name + "{ENTER}")
shell.SendKeys("{TAB}" * 8)
shell.SendKeys("{F2}XX{ENTER}^s") # This is where the sorting occurs
shell.SendKeys("{F2}%s{ENTER}^s" % EPLUS_VERSION) # Write the correct value
idfs = (f for f in os.listdir('.') if os.path.splitext(f)[1] == '.idf')
for idf in idfs:
sort_idf(idf)
shell.SendKeys("%{F4}")
2 | No.2 Revision |
This is not the best solution, but it's what has worked for me at the moment. I'm using Python to automate the process of launching the IDF Editor, opening an IDF file, changing the version number, saving the file (thus achieving the desired sorting), changing the version number back, saving again[, repeating if required until all files are sorted], and closing the IDF Editor.
When run from a folder it loops through all the IDF files in the folder and sorts them before closing the IDF Editor. This might mean you run into memory problems when sorting hundreds of files - I haven't tried it yet so don't know what the limits are - but it would be easy enough to adapt to take batches of say ten or twenty at a time.
I also had a look at pywinauto
but ran into problems finding the right place to enter values in the IDF Editor GUI. If anyone has any tips on that please let me know.
Hope this helps someone out.
"""
idf_editor.sorter
~~~~~~~~~~~~~~~~~
A simple script which controls the IDF Editor application, taking advantage of
the fact that it tidies up the file when saving.
It would be better if this could happen in the background but the simplest way
to control IDF Editor from Python is using SendKeys which requires the window
to be in the foreground.
This script should be run from the folder containing the IDF files to be sorted.
Filenames will be unaffected.
"""
import os
import time
import win32com.client
EPLUS_VERSION = '8.1' # The EnergyPlus version number of the IDFs to be sorted
IDF_EDITOR_PATH = "C:\EnergyPlusV8-1-0\PreProcess\IDFEditor\IDFEditor.exe"
shell = win32com.client.DispatchEx("WScript.Shell")
shell.Run(IDF_EDITOR_PATH)
shell.AppActivate("IDF Editor")
time.sleep(1)
time.sleep(1) # Wait for the IDF Editor to open - you may need to increase this
def sort_idf(idf_name):
shell.SendKeys("^o")
time.sleep(1) # Wait for dialog to open
shell.SendKeys(idf_name + "{ENTER}")
shell.SendKeys("{TAB}" * 8)
shell.SendKeys("{F2}XX{ENTER}^s") # This is where the sorting occurs
shell.SendKeys("{F2}%s{ENTER}^s" % EPLUS_VERSION) # Write the correct value
idfs = (f for f in os.listdir('.') if os.path.splitext(f)[1] == '.idf')
for idf in idfs:
sort_idf(idf)
shell.SendKeys("%{F4}")
3 | No.3 Revision |
This is not the best solution, but it's what has worked for me at the moment. I'm using Python to automate the process of launching the IDF Editor, opening an IDF file, changing the version number, saving the file (thus achieving the desired sorting), changing the version number back, saving again[, repeating if required until all files are sorted], and closing the IDF Editor.
When run from a folder it loops through all the IDF files in the folder and sorts them before closing the IDF Editor. This might mean you run into memory problems when sorting hundreds of files - I haven't tried it yet so don't know what the limits are - but it would be easy enough to adapt to take batches of say ten or twenty at a time.
I also had a look at pywinauto
but ran into problems finding the right place to enter values in the IDF Editor GUI. If anyone has any tips on that please let me know.
Hope this helps someone out.
"""
idf_editor.sorter
~~~~~~~~~~~~~~~~~
A simple script which controls the IDF Editor application, taking advantage of
the fact that it tidies up the file when saving.
It would be better if this could happen in the background but the simplest way
to control IDF Editor from Python is using SendKeys which requires the window
to be in the foreground.
This script should be run from the folder containing the IDF files to be sorted.
Filenames will be unaffected.
"""
import os
import time
import win32com.client
EPLUS_VERSION = '8.1' # The EnergyPlus version number of the IDFs to be sorted
IDF_EDITOR_PATH = "C:\EnergyPlusV8-1-0\PreProcess\IDFEditor\IDFEditor.exe"
shell = win32com.client.DispatchEx("WScript.Shell")
shell.Run(IDF_EDITOR_PATH)
shell.AppActivate("IDF Editor")
time.sleep(1) # Wait for the IDF Editor to open - you may need to increase this
def sort_idf(idf_name):
shell.SendKeys("^o")
time.sleep(1) # Wait for dialog to open
open - you may be able to reduce this
shell.SendKeys(idf_name + "{ENTER}")
shell.SendKeys("{TAB}" * 8)
shell.SendKeys("{F2}XX{ENTER}^s") # This is where the sorting occurs
shell.SendKeys("{F2}%s{ENTER}^s" % EPLUS_VERSION) # Write the correct value
idfs = (f for f in os.listdir('.') if os.path.splitext(f)[1] == '.idf')
for idf in idfs:
sort_idf(idf)
shell.SendKeys("%{F4}")
4 | No.4 Revision |
This is not the best ideal solution, but it's what has worked for me at the moment. I'm using Python to automate the process of launching the IDF Editor, opening an IDF file, changing the version number, saving the file (thus achieving the desired sorting), changing the version number back, saving again[, repeating if required until all files are sorted], and closing the IDF Editor.
When run from a folder it loops through all the IDF files in the folder and sorts them before closing the IDF Editor. This might mean you run into memory problems when sorting hundreds of files - I haven't tried it yet so don't know what the limits are - but it would be easy enough to adapt to take batches of say ten or twenty at a time.
I also had a look at pywinauto
but ran into problems finding the right place to enter values in the IDF Editor GUI. If anyone has any tips on that please let me know.
Hope this helps someone out.
"""
idf_editor.sorter
~~~~~~~~~~~~~~~~~
A simple script which controls the IDF Editor application, taking advantage of
the fact that it tidies up the file when saving.
It would be better if this could happen in the background but the simplest way
to control IDF Editor from Python is using SendKeys which requires the window
to be in the foreground.
This script should be run from the folder containing the IDF files to be sorted.
Filenames will be unaffected.
"""
import os
import time
import win32com.client
EPLUS_VERSION = '8.1' # The EnergyPlus version number of the IDFs to be sorted
IDF_EDITOR_PATH = "C:\EnergyPlusV8-1-0\PreProcess\IDFEditor\IDFEditor.exe"
shell = win32com.client.DispatchEx("WScript.Shell")
shell.Run(IDF_EDITOR_PATH)
shell.AppActivate("IDF Editor")
time.sleep(1) # Wait for the IDF Editor to open - you may need to increase this
def sort_idf(idf_name):
shell.SendKeys("^o")
time.sleep(1) # Wait for dialog to open - you may be able to reduce this
shell.SendKeys(idf_name + "{ENTER}")
shell.SendKeys("{TAB}" * 8)
shell.SendKeys("{F2}XX{ENTER}^s") # This is where the sorting occurs
shell.SendKeys("{F2}%s{ENTER}^s" % EPLUS_VERSION) # Write the correct value
idfs = (f for f in os.listdir('.') if os.path.splitext(f)[1] == '.idf')
for idf in idfs:
sort_idf(idf)
shell.SendKeys("%{F4}")