Giter VIP home page Giter VIP logo

ifctool's Introduction

ifctool

Command line tool for working with IFC models. It extracts IFC elements by ID or types (via web-ifc), and exports as JSON or CSV (via json2csv).

Getting Started

Build

yarn install

Run

node tool/src/main.js index.ifc

Dist

yarn prepare # first time only
yarn build
yarn test

Via npx

Use NPX to run ifctool without cloning this repo. Always prefer @latest to avoid npx cacheing issues.

> npx @bldrs-ai/ifctool@latest model.ifc

Usage

> npx @bldrs-ai/ifctool@latest --help
usage: ifctool <file.ifc>

options:
  --elts=id1[,id2,...]    Print the IFC elements with the given IDs
  --types=t1[,t2,...]     Print the IFC elements of the given types, case insensitive
  --deref                 Dereference complex elements (work in progress)
  --out=json|csv          Print as JSON (default) or CSV.  See https://github.com/buildingSMART/ifcJSON
    --fmt=...             Format CSV, see: https://www.npmjs.com/package/json2csv
  --omitExpressId         Omit expressID
  --omitNull              Omit fields will null values
  --log=[enum =>]         Set log level to one of: {off,error,exception,info,debug,verbose}.
                            default=info
  --version               Print the version of this tool, same as in package.json.
  --help                  Print these usage instructions.

Version: ifctool 5.0.1

# Processing

The tool uses web-ifc to extract data from the IFC.
See https://github.com/tomvandig/web-ifc


## ifcJSON

The output JSON is the result of JSON.stringify, with post-processing
to coerce web-ifc's object representation to ifcJSON.  This is a Work
in Progress.


# Examples

Print the root element of the model in JSON:

  node src/main.js model.ifc

with dereferncing and output as CSV

  node src/main.js model.ifc --deref --out=csv

with custom formatting

  node src/main.js model.ifc --types=IFCWALL,IFCWINDOW --out=csv \
    --fmt='["expressID","OverallWidth","OverallHeight"]'

e.g. with the included index.ifc:

> node src/main.js index.ifc --elts=5 --deref --omitNull
{
  "type": "ifcJSON",
  "version": "0.0.1",
  "originatingSystem": "IFC2JSON_js 3.0.2",
  "preprocessorVersion": "web-ifc 0.0.34",
  "time": "2022-06-25T15:38:56.359Z",
  "data": [
    {
      "expressID": 5,
      "type": "IFCTELECOMADDRESS",
      "Purpose": "USERDEFINED",
      "UserDefinedPurpose": "Phone",
      "TelephoneNumbers": [
        "+00 11 101 10 10"
      ],
      "WWWHomePageURL": "http://bldrs.ai"
    }
  ]
}
> node src/main.js src/testdata/IFC_2x3/7m900_tue_hello_wall_with_door.ifc --types=IFCDOOR --out=csv --deref --fmt='["OverallHeight","OverallWidth"]'
"OverallHeight","OverallWidth"
1.4,0.7000000000000001

Versions

Following semver, backwards-incompatible API changes use a new major version number.

  • 5.x: Full extract now includes PropertySets.
  • 4.x: Full extract now includes all top-level elts with globalIds. Better arg checking and error logging.
  • 3.x: JSON output now includes header section, towards ifcJSON compliance.
  • 2.x: Flag changes: no more --elt. Instead --elts and --types now support lists
  • 1.x: Let's see how web-ifc's JSON looks!

ifctool's People

Contributors

conorstokes avatar mkeshavarzi avatar pablo-mayrgundter avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

ifctool's Issues

Web-ifc line at the beginning ouf the output

Steps to reproduce:

Download the sample ifc.

Run:
node src/main.js SEESTRASSE.ifc > seestrasse.json

Expected result:

seestrasse.json is a valid json file.

Actual result:

There is an additional line at the beginning of the output.

web-ifc: 0.0.34 threading: 0

IFCTool: Implement IFC unit testing according to IDS spec

IDS is the emerging bSmart standard to specify test cases. Presented at bSmart Boston Sep 2022.. will move soon:
https://github.com/Moult/tmp-ids-spec
https://github.com/Moult/tmp-ids-spec/blob/main/developer-guide.md
https://technical.buildingsmart.org/resources/software-implementations/

ifctool should implement enough of the spec to get listed on these pages.

Test runner Dion demo'd:
https://github.com/IfcOpenShell/IfcOpenShell/tree/v0.7.0/src/ifctester

Default for no arguments given should be an array of all elts with globalIds as in ifc2json

Here's an extended sample extraction using one of the buildingSmart test files.

Vertigo Building from Eindhoven Uni.

Reference input: src/testdata/IFC_2x3/7m900_tue_hello_wall_with_door.ifc
Reference output: src/testdata/IFC_2x3/7m900_tue_hello_wall_with_door.json

The output json data section has the following elts, listed in order of the data array, with their expressID prefix from the IFC file. Note, all items in the data array have a globalId, but the marked items (e.g.#79 shaperep) have globalIds that don't seem to come from the input; implies they are being generated on the fly.

#1 project
#23 site
#29 Building
#35 storey
#45 wallstdcase
#52 propset
#97 openingelt
#124 door
#79 shaperep — NO UUID in IFC, but exists in ifc2json json
#83 shaperep — NO UUID in IFC, but exists in ifc2json json 
#110 shaperep — NO UUID in IFC, but exists in ifc2json json
#150 shaperep — NO UUID in IFC, but exists in ifc2json json
#2 history — NO UUID in IFC, but exists in ifc2json json
#20 geometricrep — NO UUID in IFC, but exists in ifc2json json
#41 relaggregates
#42 relaggregates
#43 relaggregates
#44 relcontained
#74 relassociates
#63 reldefines
#109 relvoids
#131 relfills

Currently, the ifctool only extracts referenced elements with --elts or --types or the spatial representation root if no arguments are given.

TODO: the default for no arguments given should be an array of all elts with globalIds as in ifc2json.

IFCTool: Expand "children" column in CSV output

I am not sure if this one is important since we may decide to focus on the json format. Nevertheless, I understood from Markus that he envisioned a matrix between elements and properties.

Steps to reproduce:

Download the sample ifc.

Run:
node src/main.js SEESTRASSE.ifc --out=csv --deref > seestrasse.csv

Expected result:

There is one column in the CSV for each IFC property (matrix between of elements of properties).

Actual result:

The properties are hierarchically stored inside the "children" column.

web-ifc: 0.0.34 threading: 0
"expressID","type","children"
86,"IFCPROJECT","[{""expressID"":109,""type"":""IFCSITE"",""GlobalId"":""2JVRWWE0fQTJBOMjht6CZc"",""OwnerHistory"":{""type"":5,""value"":28},""Name"":{""type"":1,""value"":""Gel\\X2\\00E4\\X0\\nde""},

IFCTool: Discussion: mapping of properties

Copied from a draft spec we have. I guess it would make more sense to aim for a separate tool to cover mapping instead of merging this into ifctool. Nevertheless I am recording this here since it is a related topic.

Also I believe the tool should not be a generic "json mapping" tool but should be specific to ifcjson so that we can have specific parameters geared towards this use case.

ifcjsonmapper

Implement a command-line tool that provides the functionality described below.

ifcjsonmapper <inputfile> <outputfile> [--mapping <mappingfile>]

Example:
ifcjsonmapper input.json output.json --mapping mapping.json

Behavior:

  • The tool expects a valid ifcJSON-4 file as inputfile
  • The tool optionally expects a valid select-transform template as mappingfile
  • The tool provides a valid ifcJSON-4 file as outputfile

Remarks:
Reconsider/evaluate if is select-transform is the proper library for the job.

Umlauts are not properly encoded

Steps to reproduce:

Download the sample ifc.

Run:
node src/main.js SEESTRASSE.ifc > seestrasse.json

Expected result:

Umlauts are encoded in UTF-8.

Actual result:

web-ifc: 0.0.34 threading: 0
{
  "type": "ifcJSON",
  "version": "0.0.1",
  "originatingSystem": "IFC2JSON_js 3.0.2",
  "preprocessorVersion": "web-ifc 0.0.34",
  "time": "2022-07-05T07:00:22.798Z",
  "data": [
    {
      "expressID": 86,
      "type": "IFCPROJECT",
      "children": [
        {
          "expressID": 109,
          "type": "IFCSITE",
          "GlobalId": {
            "type": 1,
            "value": "2JVRWWE0fQTJBOMjht6CZc"
          },
          "OwnerHistory": {
            "type": 5,
            "value": 28
          },
          "Name": {
            "type": 1,
            "value": "Gel\\X2\\00E4\\X0\\nde" <----------- should be encoded as "Gelände" in UTF-8
          },

IFCTool: centralize version tracking

Version is now hardcoded in 4 places, which must be kept in sync manually. This should be centralized.

tool/package.json
lib/package.json
lib/src/version.js

Preferred approach currently is similar to https://github.com/bldrs-ai/Share/blob/main/src/utils/version.mjs, probably just modify this code to modify the string in a list of files.

Alternately, could import package.json but this isn't backwards compatible with node 14, which is still in our support set.

Feature Request: Usage as a library

I imagine two ways to use the tool:

  • As a CLI
  • As a library

When using as a library, one could pass in input & output streams instead of file handles. Other parameters would stay the same.

I assume it would be pragmatic to keep both in the same repo.

Btw: For the acoustic rating app we currently went the other way around: We have the UI and service, we have the TS library with the calculation, but we do not have the CLI yet that exposes the library to the console. I imagine that all the vyzn apps will have UI, service, library, CLI.

IFCTool: Extract: Levels

Extend ifctool with a processor to convert an input IFC into multiple new IFCs that represent each level of a building.

Built tool fails on dynamic import

I'm guessing it's log4js, but not sure

> yarn build && node dist/main.js
file:///Users/pablo/bldrs-ai/ifctool/dist/main.js:14
  throw new Error('Dynamic require of "' + x + '" is not supported');
        ^

Error: Dynamic require of "tty" is not supported
    at file:///Users/pablo/bldrs-ai/ifctool/dist/main.js:14:9
    at node_modules/debug/src/node.js (file:///Users/pablo/bldrs-ai/ifctool/dist/main.js:610:15)

Cannot read properties of undefined (reading 'error')

(base) markussteinbrecher@MacBook-Pro-3 Seestrasse % npx @bldrs-ai/ifctool@beta Seestrasse.ifc --type=IFCWALL
Need to install the following packages:
@bldrs-ai/ifctool@beta
Ok to proceed? (y) y
/Users/markussteinbrecher/.npm/_npx/fe9b048579684b87/node_modules/web-ifc/web-ifc-api-node.js:6175
throw ex;
^

TypeError: Cannot read properties of undefined (reading 'error')
at internalError (file:///Users/markussteinbrecher/.npm/_npx/fe9b048579684b87/node_modules/@bldrs-ai/ifctool/src/utils.js:15:12)
at processArgs (file:///Users/markussteinbrecher/.npm/_npx/fe9b048579684b87/node_modules/@bldrs-ai/ifctool/src/main.js:101:7)
at async file:///Users/markussteinbrecher/.npm/_npx/fe9b048579684b87/node_modules/@bldrs-ai/ifctool/src/main.js:117:20
(base) markussteinbrecher@MacBook-Pro-3 Seestrasse %

using this ifc and the test.ifc and others, same error.

IFCTool: Extract: Reference coordinates from IFC

In order to have a correct and precise reference for coordination between various ifc models, the architect defines a reference line/plane per building element (e.g. wall, slab, roof). This reference is stored in the ifc (as x, y, z coordinates and a vector) but this data is not easily extractable via common BIM/ifc-tools.

As a BIM coordinator I want to be able to use this information across various workflows and across various tools. The reference coordinates also enable me to get information regarding relationships of building elements (e.g. a wall connecting to another wall).

In a first step the reference coordinates could be extracted for all elements in a structured way (e.g. csv). In a next step, buildrs could offer an API that gives easy access to this information.

Example reference coordinates in ifc (file under buildrs/Share/src/Models/:

For this wall:

#2497= IFCWALL('3CLJkEIxT2IA4qBE524feg',#12,'tbd',$,$,#2074,#2456,'CC553B8E-4BB7-4248-A134-2CE142129A2A');

the reference coordinates are stored under:

#2074= IFCLOCALPLACEMENT(#144,#2073);

#2073= IFCAXIS2PLACEMENT3D(#2071,#2069,#2067);

here is the xyz coordinate (2071) and the vector (2067, 2069)

#2067= IFCDIRECTION((1.,0.,0.));
#2069= IFCDIRECTION((0.,0.,1.));
#2071= IFCCARTESIANPOINT((10.4294608578,24.9077803753,-0.139999999999));

So far the wall I get the point (10.42, 24.91, -0.14).

export of property sets / properties needs to reference the element

Did some testing with project Seestrasse and exported to csv using: npx @bldrs-ai/ifctool@latest Seestrassev2.ifc --out=csv >test1.csv

The results are here.

The properties are exported, e.g. length of a wall but I do not understand the way they are structured. The entries do not seem to be linked to the element they belong to, or am I missing it?

IFCTool: Feature Request: ifcJSON-4 compliance

It would be great to have support for the ifcJSON-4 file format.

I did some checks to see how much deviation we currently have:

Check against schema

  1. Download the sample ifc.
  2. Run:node src/main.js SEESTRASSE.ifc > seestrasse_fromifctool.json
  3. Edit seestrasse_fromifctool.json and drop the first line
  4. Navigate to https://www.jsonschemavalidator.net/
  5. Upload the ifcJSON-4 schema
  6. Upload see seestrasse_fromifctool.json
  7. Run check

Result: Found 1523 error(s)

Check against reference implementation

  1. Install the ifcJSON-4 reference implementation as documented here
  2. Run python ifc2json.py -i ..\..\ifctool\seestrasse.ifc -o seestrasse_refimpl.json --compact

Result:
seestrasse_ifctool.zip
seestrasse_refimpl.zip

IFCTool: Serializing all PropertySets is slow

Reported by ryguga1 on Discord.
https://discord.com/channels/853953158560743424/867403749042159647/1020700598997360778

Initial look says property sets:

> time node tool/src/main.js ../../ifcjs/test-ifc-files/Schependomlaan/IFC\ Schependomlaan.ifc
timer: 11.576ms after reading file
timer: 13.847ms start
timer: 643.488ms after open
timer: 786.449ms after CreateIfcGuidToExpressIdMapping
timer: 894.031ms after getItemProperties (default)
timer: 18:50.272 (m:ss.mmm) after getPropertySets
timer: 18:50.548 (m:ss.mmm) after getAllItemsOfType
timer: 18:50.549 (m:ss.mmm) after extractIfcProps
timer: 18:50.549 (m:ss.mmm) after maybeDeref
timer: 18:52.606 (m:ss.mmm)

real    18m52.967s
user    16m53.085s
sys    0m5.550s

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.