Skip to content

Command line ​

openbim-ifc validates, converts and inspects IFC files from a shell or a CI job. It is one binary over the openbim-ifc facade: every answer is a facade call, so the command reads exactly what the library reads. Source: openbim-ifc-cli.

Install ​

On Linux and macOS, the install script picks the archive for the machine, checks it against the release's SHA256SUMS and installs the binary to ~/.local/bin:

bash
curl -fsSL https://raw.githubusercontent.com/openbimrs/ifc/main/crates/openbim-ifc-cli/install.sh | sh
curl -fsSL https://raw.githubusercontent.com/openbimrs/ifc/main/crates/openbim-ifc-cli/install.sh | sh -s -- --version 0.1.0 --prefix /usr/local

It refuses to install when the checksum does not match. Without --version it installs the newest openbim-ifc-cli release; --print-target shows the archive it would choose.

Windows ​

In PowerShell (Windows PowerShell 5.1 or PowerShell 7), the install script does the same for Windows x64 and Arm64: it checks the .zip against SHA256SUMS with Get-FileHash, refuses a mismatch, installs openbim-ifc.exe to %LOCALAPPDATA%\Programs\openbim-ifc\bin and offers to add that directory to your user PATH:

powershell
irm https://raw.githubusercontent.com/openbimrs/ifc/main/crates/openbim-ifc-cli/install.ps1 | iex

With options, run it as a script block:

powershell
& ([scriptblock]::Create((irm https://raw.githubusercontent.com/openbimrs/ifc/main/crates/openbim-ifc-cli/install.ps1))) -Version 0.1.0 -Prefix C:\Tools\openbim-ifc -AddToPath

-Version, -Prefix, -AddToPath (no question asked), -NoModifyPath and -PrintTarget mirror install.sh; under irm | iex the environment variables OPENBIM_IFC_VERSION, OPENBIM_IFC_PREFIX and OPENBIM_IFC_NO_MODIFY_PATH=1 set them instead. Both scripts download from OPENBIM_IFC_BASE_URL when it is set (a mirror, or a file:// directory in tests), with one directory per release tag.

Debian and Ubuntu ​

Each release attaches a Debian package per architecture, openbim-ifc_<version>_amd64.deb and openbim-ifc_<version>_arm64.deb. It holds the static binary as /usr/bin/openbim-ifc, the README and the licence in /usr/share/doc/openbim-ifc/, and depends on nothing. Download it, check it against SHA256SUMS, and install it with apt or dpkg:

bash
sha256sum --check --ignore-missing SHA256SUMS
sudo apt install ./openbim-ifc_0.1.0_amd64.deb
sudo apt remove openbim-ifc

There is no apt repository yet, so apt upgrade does not see new releases; install the next .deb the same way.

Nix ​

The repository is a Nix flake. It builds the command from source with the pinned toolchain (rust-toolchain.toml) and Cargo.lock, on x86_64 and aarch64 Linux and macOS:

bash
nix run github:openbimrs/ifc -- validate model.ifc
nix run github:openbimrs/ifc/openbim-ifc-cli-v0.1.0 -- --version   # a release
nix profile install github:openbimrs/ifc                           # onto PATH

The package is packages.<system>.openbim-ifc (also default), the app apps.<system>.default; nix develop opens a shell with the repository's Rust toolchain. A nixpkgs package may follow once the command has had a few releases.

Rust, Homebrew and archives ​

With a Rust toolchain:

bash
cargo install openbim-ifc-cli      # builds from source
cargo binstall openbim-ifc-cli     # takes the release binary

With Homebrew, once the tap exists (see Homebrew):

bash
brew install openbimrs/tap/openbim-ifc

Or download an archive from an openbim-ifc-cli-v*GitHub release and check it yourself:

PlatformArchive
Linux x86_64 (static)openbim-ifc-v<version>-x86_64-unknown-linux-musl.tar.gz
Linux aarch64 (static)openbim-ifc-v<version>-aarch64-unknown-linux-musl.tar.gz
macOS Intelopenbim-ifc-v<version>-x86_64-apple-darwin.tar.gz
macOS Apple siliconopenbim-ifc-v<version>-aarch64-apple-darwin.tar.gz
Windows x64openbim-ifc-v<version>-x86_64-pc-windows-msvc.zip
Windows Arm64openbim-ifc-v<version>-aarch64-pc-windows-msvc.zip
Debian, Ubuntu x86_64openbim-ifc_<version>_amd64.deb
Debian, Ubuntu aarch64openbim-ifc_<version>_arm64.deb
bash
sha256sum --check --ignore-missing SHA256SUMS

On Windows, compare (Get-FileHash openbim-ifc-v<version>-x86_64-pc-windows-msvc.zip).Hash with its line in SHA256SUMS.

Every one of these is tested before a release publishes it: each binary is installed through install.sh or install.ps1 from a local copy of its archive, a corrupted SHA256SUMS must be refused, and each .deb is installed with dpkg, run and removed on Ubuntu 22.04 (x86_64 and aarch64). Pull requests run the same scripts in .github/workflows/cli.yml, and .github/workflows/nix.yml builds the flake.

Commands ​

CommandAnswersFormats
validate FILE...Is each file legal against the schema its header declares?human, json, sarif
convert IN OUTThe model in STEP, ifcXML (native or XSD layout) or ifcZIPfrom the extension, or --to
info FILEHeader, declared schema, entity and type countshuman, json
psets FILE ENTITYProperty and quantity sets of one object or type objecttable, json, csv
tree FILEProject, site, building, storey and space, with their elementshuman, json
lint FILE...Products with geometry that no model viewer will drawhuman, json, sarif
select FILE QUERYThe entities a selector selects, with values read by pathtable, json, csv
edit FILE QUERY --set PATH VALUE...Values set by path on the selected entities, as one checked transaction, into a new filehuman, json
export-table FILE QUERY --column PATH...The selected entities as a table, one column per value pathcsv, tsv, xlsx
import-table FILE TABLEA table's edited cells written back by key, as one checked transaction, into a new filehuman, json
relations FILE ENTITYWhat one entity is related to, by kind, and every relationship naming ithuman, json
materials FILE [QUERY]The material definition of each selected entity, with its layers, profiles or constituentshuman, json
cost FILEEvery cost schedule as a tree of cost items, with values and totalshuman, json
schedule FILEEvery work schedule and work plan as a tree of tasks, with scheduled timeshuman, json
convert-units IN OUT --unit UNITThe model in another length unit, every length, area and volume rescaledSTEP; report human, json

openbim-ifc <command> --help lists every option. Each command reads STEP or ifcXML, chosen by content first and extension second, and an ifcZIP archive holding either, recognized by its ZIP signature.

validate ​

bash
openbim-ifc validate model.ifc
openbim-ifc validate --format json --deny-warnings models/*.ifc

Each file is validated against the tables of the release its own FILE_SCHEMA declares; a file declaring none, or a release this build does not bundle, is refused rather than checked against another release. A human report prints one line per finding, file:line: severity [rule] #12.Name: message, with the line of the entity's record in a STEP file, then a summary per file.

A file fails on an error, on an evaluation error (a rule that could not be decided for an instance), and on a truncated report (--max-findings reached, so the counts are lower bounds); with --deny-warnings, on a warning too. Rules this validator does not evaluate are counted in the summary and never fail a file; --include-unsupported lists them.

EXPRESS rules ​

bash
openbim-ifc validate --express IFC4.exp model.ifc
openbim-ifc validate --express IFC2X3_TC1.exp --express IFC4.exp models/*.ifc

--express FILE.exp also evaluates every WHERE rule, type rule and global rule of the release, and checks INVERSE cardinality, from the EXPRESS schema text you supply: the schemas are CC BY-ND, so none is bundled (the schema fetch script downloads all five). Repeat the option to cover several releases, one file per release. Every file is tried against each model's release, so the result never depends on the order of the options. A model is checked with the one file that declares its release; when none does, or when more than one does, it is refused with express-mismatch and the run exits 2, after the other files are checked. A file that does not parse is invalid-express, with its path in the message, and refuses every model. An .exp file that cannot be read ends the run before any model is checked. Files are read as UTF-8, or as Latin-1 when they are not.

A rule that evaluates to UNKNOWN is an indeterminate finding: listed and counted (the human summary adds N indeterminate), never a failure.

convert ​

bash
openbim-ifc convert model.ifc model.ifcxml                 # native layout
openbim-ifc convert model.ifc model.ifcxml --layout xsd    # buildingSMART XSD layout
openbim-ifc convert model.ifcxml model.ifc
openbim-ifc convert model.ifc - --to ifcxml | gzip > model.ifcxml.gz

The native layout is this library's lossless ifcXML for any release, with attribute names from the declared release's tables when the build bundles them. The XSD layout is the buildingSMART configuration of IFC4 ADD2 TC1 and IFC4X3 ADD2; a model it cannot carry exactly is refused with the codec's reason and nothing is written. On reading, the layout is detected from the root element (the native layout carries a schema attribute, the XSD layout declares its release's namespace); --input-layout names it when neither is present. An existing output is replaced only with --force.

bash
openbim-ifc convert model.ifc model.ifczip                          # STEP inside, as model.ifc
openbim-ifc convert model.ifc out.zip --to ifczip --inner ifcxml --layout xsd
openbim-ifc convert model.ifczip model.ifc

An ifcZIP archive holds one STEP or ifcXML document at its root, as the buildingSMART implementation agreement CV-2x3-154 fixes it; convert writes one Deflate entry named after the output file, STEP unless --inner ifcxml asks for ifcXML (whose layout --layout chooses). On reading, an archive with no .ifc or .ifcXML entry at its root, with several, or with an entry that is neither STEP nor ifcXML is refused as parse; an encrypted entry or a compression method other than Stored and Deflate as unsupported; and an entry that would inflate past 4 GiB, or past 200 times its compressed size once larger than 1 MiB, as budget-exceeded, before it is held in memory. info names the format as, for example, STEP in ifcZIP (model.ifc).

info, psets, tree ​

bash
openbim-ifc info model.ifc --all-types
openbim-ifc psets model.ifc '#1234'
openbim-ifc psets model.ifc '2O2Fr$t4X7Zf8NOew3FLOH' --format csv > wall.csv
openbim-ifc tree model.ifc --elements

psets takes #12, 12 or a 22-character GlobalId and resolves exactly: the object's own sets first, then the sets its type object holds (marked type #id), an occurrence property overriding an inherited one of the same set and name. A complex property's members follow it as Parent.Member rows in the table and CSV, and stay inside its value in JSON. Quote a GlobalId in the shell: it may contain $.

tree prints the containers from the project down, with each container's element count or, with --elements, its elements, followed by what the tree could not honour: a second parent, a containment in something that is no container, a relationship naming an entity the file lacks.

lint ​

bash
openbim-ifc lint model.ifc

Reports products with geometry that a model viewer will not draw: outside the spatial structure, or with geometry only in contexts a model viewer skips. Openings, parts, containers and products without a shape are legitimately outside the containment tree and are not reported. Any finding fails the run.

select ​

bash
openbim-ifc select model.ifc 'IfcWall, Pset_WallCommon.IsExternal=TRUE'
openbim-ifc select model.ifc 'IfcDoor + location="Level 1"' --value type.Name --value storey.Name
openbim-ifc select model.ifc 'IfcWall, material=Concrete' --value Qto_WallBaseQuantities.Length --format csv

Lists the entities a selector selects, in ascending id order, with their class, GlobalId and Name, and one column per --value path (type.Name, Pset_WallCommon.FireRating, materials.Name). The selector is evaluated against the release the header declares; one that does not parse, or that names a class or attribute the release does not declare, is refused as invalid-selector with the byte span it refuses, never answered with an empty list. JSON gives the query in its canonical form and the grammar version beside the entities. Quote the selector in the shell: it holds spaces, ! and $.

edit ​

bash
openbim-ifc edit model.ifc 'IfcWall, type=WT-200' --set Pset_WallCommon.FireRating F120 --dry-run
openbim-ifc edit model.ifc 'IfcWall, type=WT-200' --set type.Name WT-250 --set Description '$' -o edited.ifc
openbim-ifc edit model.ifc IfcSlab --set Pset_Custom.Note 'IFCLABEL(checked)' --in-place

Writes every --set PATH VALUE on every entity the selector selects, as one transaction checked against the release the header declares: an attribute (Name, type.Name, materials.Category) by its declared type, a property (Pset_WallCommon.FireRating) through the checked property edit in the type it already states, a Pset_ or Qto_ set against the PSD/QTO catalog. The value is text read as that type: TRUE, 2.5, an enumeration item in any case, #12 for a reference, $ for NULL (--null names another text). Where nothing says which type to write, the value names it: IFCLABEL(F90) for a property no object states yet, or a SELECT attribute.

--dry-run lists the changes, one line per value: the entity, the path, the entity a path such as type.Name reaches, and the value before and after; nothing is written. Otherwise the edited model goes to --output (STEP, ifcXML or ifcZIP by its extension, an existing file replaced only with --force) or, with --in-place, over the input in its own format. The input is never changed without --in-place. A value an entity already holds is left alone. Any refusal (text that is no value of the type, a path that names no value to write such as class or count, a property edit the catalog refuses) is printed with its entity, path and kind, every one of them, and the run writes nothing and exits 3. A selector or path that does not parse is refused as invalid-selector with its span (exit 2).

export-table, import-table ​

bash
openbim-ifc export-table model.ifc IfcWall -c Name -c type.Name -c Pset_WallCommon.FireRating -o walls.xlsx
openbim-ifc export-table model.ifc 'IfcDoor + IfcWindow' -c Name -c storey.Name --key id --to tsv
openbim-ifc import-table model.ifc walls.xlsx --dry-run
openbim-ifc import-table model.ifc walls.xlsx -o edited.ifc

export-table writes the selected entities as a table: the key column first (GlobalId, or id with --key id), then one column per --column path (class and Name by default), each headed by the path. The format is the output's extension (.csv, .tsv, .xlsx) or --to; standard output is CSV unless --to says otherwise. Every XLSX cell is text, so a GlobalId or a real survives a spreadsheet application.

import-table reads a table back: rows are matched by their key, every other cell is written by its header's path as one checked transaction, and a cell that reads what the model holds changes nothing, so an exported table imported unchanged writes an identical model. --dry-run, --output, --in-place and --force are those of edit. Every refusal is reported by row and column (row 3, column D: invalid-text: ...): a header that is no path (with its span), a missing, empty, unknown, ambiguous or repeated key, a row of another width, a cell that does not read as its target's type, two rows giving one type different names. Any refusal writes nothing and exits 3.

relations, materials, cost, schedule ​

bash
openbim-ifc relations model.ifc '#17'
openbim-ifc relations model.ifc '0TG0wWfbZOvmJHW7AuHJ$k' --traverse-up
openbim-ifc materials model.ifc 'IfcWall, type=WT-200' --format json
openbim-ifc cost model.ifc --depth 1
openbim-ifc schedule model.ifc

relations lists what one entity is related to, by kind: its container, its parent when that is not its container, its type or its occurrences, its material definition and materials, classification references, groups and systems, openings, fillings and the element an opening voids. Under them every relationship that references the entity is listed with the attribute it names it in, so nothing the kinds leave out is hidden. --traverse-up lists the chain of parents up to the project instead. A relationship the schema allows once and the file states twice is refused as invalid-model.

materials shows the material definition of each entity a selector selects (IfcElement + IfcElementType by default), its own or its type's, a usage read as the set it uses, with each layer's name, material and thickness, each profile's material and profile, each constituent's material and fraction. Entities without a material are left out.

cost shows every cost schedule with the cost items assigned to it as a tree of nested items, each with its own values (category, name, applied value, or the operator of a value composed of others) and two totals: its direct total, its own values, and, when it nests items, the rolled-up total of theirs. IFC does not say whether a parent's value summarises its children, so neither is called the total. schedule shows every work schedule and work plan with its tasks as a tree of sub-tasks, each with its scheduled start, finish and duration and whether it is a milestone. Both take --depth N to expand N levels and count the rest.

convert-units ​

bash
openbim-ifc convert-units model.ifc model-m.ifc --unit METRE
openbim-ifc convert-units model.ifc - --unit foot --dry-run --format json

Assigns a new project length unit (METRE with any SI prefix, inch, foot, yard, mile or US survey foot) and rescales every value the release's measure types make a length, area or volume: geometry, placements, profiles, quantities and property values. Areas and volumes take the square and cube of the new unit unless --keep-area-volume. Values with a unit of their own keep it, a map conversion with a MapUnit keeps its map coordinates and rescales its Scale, and a parameter value follows its curve (kept on a circle, where it is an angle). A value the conversion cannot carry, such as a parameter value on a curve whose parameter space IFC leaves undefined, refuses the run as unsupported with every such value listed, and nothing is written. The report goes to standard error, or with --dry-run to standard output while nothing is written.

Exit codes ​

CodeMeaning
0Success; for validate and lint, nothing that fails the run
1validate or lint found something that fails the run
2A usage error, an unreadable or unparseable file, or a refusal
3edit or import-table refused a planned change; nothing was written

A refusal prints its kind on stderr, openbim-ifc: <kind>: <detail>, and is never turned into an empty or guessed answer:

KindMeaning
usageThe arguments contradict each other or the input
ioA file could not be read or written
parseNot a STEP or ifcXML file, or it does not parse; an ifcZIP archive without exactly one model
unsupported-schemaNo schema declared, or one this build bundles no tables for
unsupportedSomething this tool or the library does not support for this input
missing-entityNo entity with that id or GlobalId
wrong-entity-typeThe entity cannot carry what was asked for
missing-referenceA reference names an entity the file lacks
invalid-modelThe file is malformed or ambiguous where an exact answer is needed
budget-exceededA traversal hit its bound before it could answer, or an ifcZIP entry would inflate past its budget
writeThe output format refused the model
invalid-selectorA selector, value path or column does not parse, or names a class or attribute the release does not declare; the detail names the byte span
express-mismatchNo --express file declares the release of the file being validated, or one disagrees with the release's tables
invalid-expressAn --express file does not parse as EXPRESS, or a rule in it names something that binds to nothing

edit and import-table report each refused change on stderr as openbim-ifc: refused: <where>: <kind>: <detail>, where <where> is the entity and --set path or the table's row and column, and exit 3. The kinds are invalid-text (no value of the target's type), type-mismatch (a value the declared type refuses, $ for a required attribute), not-settable (a computed key, a pattern, a list), conflicting-write, property-edit, untyped-value and, for a table, invalid-header, duplicate-column, no-key-column, ragged-row, empty-key, unknown-key, ambiguous-key and duplicate-key. --format json writes the changes and the refusals (with row, column, entity, path, kind, detail and span) as one document on standard output.

validate and lint take several files; one that cannot be checked is reported (in JSON as error, in SARIF as a tool execution notification), the others are still checked, and the run exits 2.

In CI ​

--format sarif writes SARIF 2.1.0: one result per finding with the file, the line of the entity's record, and the entity or attribute (#12, #12.Name) as a logical location. Errors and evaluation errors are error, warnings warning, unevaluated and indeterminate rules note. On GitHub:

yaml
- run: openbim-ifc validate --format sarif models/*.ifc > ifc.sarif
  continue-on-error: true
- uses: github/codeql-action/upload-sarif@v3
  with:
    sarif_file: ifc.sarif

--format json of validate is one document: tool, version, the run's passed verdict, and per file file, schema, passed, conformant, truncated, summary (errors, evaluation_errors, warnings, indeterminate, unsupported) and findings, each with severity, rule, path, entity, attribute_index, attribute_name, line and message; a file that could not be checked has error (kind, message) instead.

Homebrew ​

Each openbim-ifc-cli-v* release attaches openbim-ifc.rb, a formula generated from the release's SHA256SUMS by crates/openbim-ifc-cli/scripts/package.py (template: crates/openbim-ifc-cli/packaging/openbim-ifc.rb.in). The release workflow also pushes it to the tap repository when it can. Setting up the tap is a maintainer's step, done once:

  1. Create the public repository openbimrs/homebrew-tap with a Formula/ directory (an empty Formula/.gitkeep and a README are enough). Homebrew finds it as openbimrs/tap.
  2. Create a fine-grained personal access token (or a GitHub App token) with Contents: read and write on openbimrs/homebrew-tap only.
  3. Store it in openbimrs/ifc as the Actions secret HOMEBREW_TAP_TOKEN.
  4. On the next openbim-ifc-cli-v* tag, the cli-assets job of release.yml commits Formula/openbim-ifc.rb to the tap. For a release made before the token existed, copy openbim-ifc.rb from that release into Formula/ by hand.
  5. Check it: brew install openbimrs/tap/openbim-ifc && brew test openbim-ifc.

Without the secret the job still attaches the formula to the release and notes that no tap was updated.

Dual-licensed under AGPL-3.0-or-later or a commercial licence. ISO and CEN standards material is not redistributed.