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

Format IDF files using command line

asked 2019-12-05 15:41:58 -0600

mldichter gravatar image

Is there a way to run whatever the IDF Editor runs to format the txt of the IDF file, meaning one field per line, field name added as comment, field lines indented, order objects in the IDF file by type, etc?

Based on the comments in the txt file after being formatted, I need a command line something for whatever does this,

!-Generator IDFEditor 1.50
!-Option SortedOrder

The only way I know to get the IDF file formatted and sorted is by opening the IDF Editor, adding a new object, saving the IDF, deleting the newly created object, then saving again.

I need correct formatting for a script I have written to compare PNNL models at different years and in different geographical locations. This very concisely summarizes what ASHRAE standards changed that were applicable to the building type, but the comparison is highly dependent on standard formatting and correct field names.

edit retag flag offensive close merge delete


@mldichter if you're mostly interested in ordering objects in a consistent manner, you could use Eppy to open and save the file.

Jeremy gravatar image Jeremy  ( 2019-12-05 17:32:57 -0600 )edit

There's definitely a python script somewhere on Unmethours that Jamie Bull wrote (for windows only). Edit: cf

Julien Marrec gravatar image Julien Marrec  ( 2019-12-06 02:16:55 -0600 )edit

@Jeremy The order doesn't matter within an object type, but having the objects types separated into groups does matter. More importantly, adding the field names as comments and indenting consistently.

mldichter gravatar image mldichter  ( 2019-12-06 10:12:35 -0600 )edit

@Jamie Bull Do you have a windows python script for this?

mldichter gravatar image mldichter  ( 2019-12-06 10:13:44 -0600 )edit

@mldichter if the order doesn't matter, reading and saving the file using Eppy will output an idf file with objects types separated into groups. I think the script Julien refers to is to mimic what the IDF Editor does.

Jeremy gravatar image Jeremy  ( 2019-12-06 18:29:35 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted

answered 2019-12-17 10:44:00 -0600

mldichter gravatar image

Thanks to @Julien Marrec, there is a post with a python script that does the job. I submitted an answer at the bottom of the post that could run on my laptop, but the script is a little dangerous.

edit flag offensive delete link more

Your Answer

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

Add Answer

Training Workshops

Question Tools

1 follower


Asked: 2019-12-05 15:41:58 -0600

Seen: 175 times

Last updated: Dec 17 '19