IfcPeek command-line filtering and reporting for IFC files

Here's a new tool. It is a command-line for querying an IFC model using the Selector syntax that we know from Bonsai BIM.

It is an interactive tool with history, tab completion, syntax highlighting etc.. so you can use it to explore your models. It is also scriptable, so you can pipe a query and save CSV output with formatted values. More information here:

https://github.com/brunopostle/ifcpeek

MoulttheoryshawsteverugiGerardTMassimowalpatlangcarlopavsemhustejJanFand 4 others.

Comments

  • Very, very cool!

  • @brunopostle looks amazing
    for us mortals not so used to these things, would you please show the actual installation steps? does it work in a terminal window ?

    pip install ifcopenshell prompt_toolkit
    pip install -e .
    

    the first went through ok but the second pip install -e . returned an error

    C:\Users\steve\OneDrive\Desktop\IFC>pip install -e .
    Obtaining file:///C:/Users/steve/OneDrive/Desktop/IFC
    ERROR: file:///C:/Users/steve/OneDrive/Desktop/IFC does not appear to be a Python project: neither 'setup.py' nor 'pyproject.toml' found.

    thanks for your help

  • @steverugi it hasn't been uploaded to pypi, so these are instructions to install it from a local clone of the git repository. I haven't tested installing on windows, but it should be fine. Please do ask until you get it working, you are the target audience for this tool.

    Nigelemiliotasso
  • @brunopostle

    Please do ask until you get it working

    do I have to repeat the pip intsall -e . until it works? OK will try again soon

    you are the target audience for this tool.

    wow! much obliged
    cheers

  • @steverugi you need to start with a git clone of the repository. If you can't manage that you can download a zip archive from Github, unzip it and install from there

  • thank you @brunopostle for your kind reply

    @steverugi you need to start with a git clone of the repository. If you can't manage that you can download a zip archive from Github, unzip it and install from there

    dealing with clones (in life or in a repository) is in my bucket list, will try again when the module will be made available, no problema
    cheers

  • edited June 6

    @steverugi I figured out how to make a package, install with pip:

    pip install https://github.com/brunopostle/ifcpeek/releases/download/1.0.0/ifcpeek-1.0.0-py3-none-any.whl
    
    steverugi
  • thank you @brunopostle

    it went through! no issue, now I'm on board with your new feature :)

    After using it for a little time I have to say the experience is quite impressive
    also, all is very well documented with a number of use cases.

    When data is what you need (I do) your IfcPeek can be of great help, it can be run on any computer with access to the .ifc file, really sleek
    I am going to test it in depth over the next few days to give you a better feedback.

    I am truly grateful

    brunopostleJanFMassimo
  • @brunopostle
    I used this to get a list of column and beams with their net volume m3, OK

    when the same query is used in the export to .csv as explained in your page

    Find all concrete elements and get quantities

    > IfcWall, IfcSlab, material=concrete ; Name ; type.Name ; Qto_.*Quantities.NetVolume

    Export to file for spreasheet analysis

    echo 'IfcWall, IfcSlab, material=concrete ; Name ; type.Name ; Qto_.*Quantities.NetVolume' | ifcpeek model.ifc > concrete_quantities.csv

    it returns an error:

    Thanks again for your work

    PS the example in your page
    Qto_.*Quantities.NetVolume should read /Qto_.*BaseQuantities/.NetVolume I think

  • @steverugi I think you have a backtick at the beginning of your command instead of a normal single-quote mark, this looks like a copy-paste error (though it could still be a problem with ifcpeek).

    This works here:

    $ echo 'IfcColumn, IfcBeam; type.Name ; Description ; /Qto_.*BaseQuantities/.NetVolume' | ifcpeek _test.ifc > concrete_quantities.csv 
    $ cat concrete_quantities.csv 
    external beam   Element Description 0.593160022219829
    external beam   An Element description  0.593159968486119
    

    Thanks, there were some errors in the README, fixed.

    There are also definitely some bugs, tab-completion doesn't work with Qto_BeamBaseQuantities.<TAB> when it should offer NetVolume and OuterSurfaceArea etc..

    steverugi
  • edited June 7

    Hi @brunopostle
    thanks for the quick reply
    maybe the backtick was added to format the string, let me paste here its full text (I just used yours changing only the .ifc file name):

    echo 'IfcColumn, IfcBeam; type.Name ; Description ; /Qto_.*BaseQuantities/.NetVolume' | ifcpeek "ST SB 003 1.ifc" > concrete_quantities.csv
    

    despite the same works fine inside ifcpeek, when used to output the error persists:

    thanks again for your assistance

    PS how would you use round() when the quantity selector contains .*?
    PS2 I created a dummy "_test.ifc" file to use your exact query and the result did not change

  • edited June 8

    I can definitely reproduce your error by including a ` at the beginning of the string. This could be a bug in the untested Windows support, as a workaround can you put the query in a text file? like this:

    cat myquery.txt
    IfcColumn, IfcBeam; type.Name ; Description ; /Qto_.*BaseQuantities/.NetVolume
    
    ifcpeek  _test.ifc < myquery.txt > concrete_quantities.csv
    

    It looks like round(), int() etc.. don't work when the content is a regular expression, another bug..

  • @brunopostle said:
    I can definitely reproduce your error by including a ` at the beginning of the string. This could be a bug in the untested Windows support, as a workaround can you put the query in a text file? like this:

    cat myquery.txt
    IfcColumn, IfcBeam; type.Name ; Description ; /Qto_.*BaseQuantities/.NetVolume
    
    python -m ifcpeek _test.ifc < myquery.txt > concrete_quantities.csv
    

    the workaround did work out!, thanks a lot

    maybe an improvement in the future could be to add the headers? ;)

  • @steverugi Ahh, figured it out, on Windows you have use " a double-quote character instead of a ' single-quote character to quote strings (which is a pain because the selector syntax uses double-quotes).

    steverugi
  • @steverugi said:

    maybe an improvement in the future could be to add the headers? ;)

    I'll add it to the TODO list

    steverugi
  • @brunopostle

    @steverugi Ahh, figured it out, on Windows you have use " a double-quote character instead of a ' single-quote character to quote strings (which is a pain because the selector syntax uses double-quotes).

    echo "IfcColumn, IfcBeam; type.Name ; Description ; /Qto_.*BaseQuantities/.NetVolume" | ifcpeek "ST SB 003 1.ifc" > concrete_quantities.csv
    

    alas, using double quotes returns the same error, but the workaround works fine

  • @brunopostle awesome, thanks!

  • I added a CSV headers feature, fixed the bug where formatting didn't work when the value was a regular expression, and improved the tab completion of Psets, Qtos, EPsets etc.. New release here:

    https://github.com/brunopostle/ifcpeek/releases/tag/1.0.1

    steverugiMassimotlangwalpaatomkarinca
  • Hi @brunopostle
    I am testing the update and looks OK
    how do you set headers in the csv using ifcpeek please?
    thanks

  • Oops forgot to update the README, just use:
    ifcpeek --headers

    steverugi
  • @brunopostle
    it works
    for next development I'd like to suggest introduction of alias, to avoid long headers like:

    in ifccsv I can use --headers "Type" "m3" for instance ..
    ..or it's there already?
    thanks again for your work

  • The round() formatting shouldn't appear, this is a bug

    steverugi
  • ping newcomer @IliaShkola
    welcome to the platform

    I'm also experimenting with terminal-based interfaces and lightweight automation to make BIM data more accessible — especially for quick QA tasks or exports.

    maybe you like ifcseek by @brunopostle here ?

  • @steverugi
    Yeah, I actually saw it and even gave it a quick test — but by the time I found it, I had already built my own XLSX export tool :D Mine takes a bit of a different route though — "Far Manager meets Vim-style navigation".

    brunopostlesteverugiJohn
  • @IliaShkola you should introduce your new tool in a new thread as I'm sure it is of interest. It's more interactive than ifcpeek, so it will have different use cases.

Sign In or Register to comment.