GithubHelp home page GithubHelp logo

andrewisen / bim-whale Goto Github PK

View Code? Open in Web Editor NEW
28.0 3.0 4.0 391 KB

A client-side IFC parser

Home Page: http://docs.bimvalen.se

License: MIT License

TypeScript 98.43% JavaScript 1.57%
ifc ifc2x3 bim cad revit parse parser javascript client bim-whale

bim-whale's Introduction


Logo

The BIM Whale Project

BIMWHALE.js | A simple client-side IFC parser
View the demo »

Explore docs · Access IFC sample files · Report Bug · Request Feature

Table of Contents
  1. About
  2. Getting Started
  3. Usage
  4. Roadmap
  5. Contributing
  6. License
  7. Contact
  8. Extra

About

The BIM Whale (Swedish: BIM-valen) is a project about the Industry Foundation Classes (IFC) format. The aim of this project is to:

I: Introduce and explain the basics of IFC schema

II: Teach people how to parse an IFC file and retrieve basic information

In more specific terms, the goal of this project is to:

A: Provide a simple and fast IFC parser

B: Provide learning resources (documentation, videos, power points) to people within the AEC industry

Goal A has been realized as BIMWHALE.js, i.e. this repo. BIMWHALE.js is a simple client-side IFC parser built using TypeScript.

Please note that the BIMWHALE.js is NOT supposed to be an all singing, all dancing parser. This project is only looking to parse information that we know exists, so-called User Defined IFC Property Sets.

Again, the focus with The BIM Whale Project is to educate people. The code itself and its functionality are secondary.

Explore the docs for more information.

FAQ

Question: What does The BIM Whale do?

Answer: Parse so-called User Defined IFC Property Sets from an IFC file

Q: What does The BIM Whale NOT do?

A: Parse entity attributes, parse geometry, follow the EXPRESS standard, etc. etc.

Q: What is an IFC file?

A: Industry Foundation Classes (IFC) is a standardized, digital description of a BIM model. See IFC for more information.

Q: What is a STEP file?

A: A STEP-File is the format IFC uses. See ISO 10303-21 for more information

Q: Is this code "hand made"?

A: Yes, the code is hand made. The parsing is not derived from an EXPRESS definition.

Q: Is the code ready for production?

A: No, not yet. See open issues for more info

Getting Started

  1. A compiled JS bundle file is available here:

https://cdn.jsdelivr.net/gh/andrewisen/bim-whale/dist/BIMWHALE.min.js

  1. Add it to your project
<script src="https://cdn.jsdelivr.net/gh/andrewisen/bim-whale/dist/BIMWHALE.min.js"></script>
  1. Use the FileReader API and create a new IfcFile object
// The libary is called: BIMWHALE
var fileReader = new FileReader();
fileReader.onload = function (e) {
    const lines = e.target.result.split(/\r\n|\n/);
    let ifcFile = new BIMWHALE.IfcFile(lines, config);
    ifcFile.parseIfcFile();
};
fileReader.readAsText(file);
  1. See the docs for more information: docs.bimvalen.se

Local Development

These next steps will guide you to set up your own development platform.

Prerequisites

This repository uses Deno as the runtime for TypeScript.

Installation

  1. Clone the repo

    git clone https://github.com/andrewisen/bim-whale.git
  2. Replace the following files with your own content.

  • index.ts
  • src/config.ts

The easiest approach is to copy content of the example.NAME.ts file.

In other words: Replace index.ts with the content inside example.index.ts.

  1. Make sure you update src/config.ts and provide a correct filePath. You can download some sample files here: https://github.com/andrewisen/bim-whale-ifc-samples

  2. Check if Deno is working

    deno run --allow-read checkDeno.ts

Any errors until this point are likely due to Deno. Submit an issue if have any problems.

Usage

  • Run the app with:
   deno run --allow-read index.ts

SimpleWall Sample File

Download the SimpleWall Sample File here. The sample consist of:

  • A wall
  • A door

Here's a screenshot:

Screenshot

The IFC file has a Property Set called Custom_Pset. Please note that the file only contains dummy data.

Screenshot

Make sure to update src/config.ts and provide a correct filePath. You should get the following result:

{
  TypeMark: "_TYPE-MARK_",
  Keynote: "_KEYNOTE_",
  StoreyName: "Level: Level 1",
  TypeDescription: "_DESCRIPTION_",
  StatusConstruction: "New Construction",
  NetArea: "14.04739",
  Height: "4000.",
  Width: "200.",
  Length: "4000.",
  Hyperlink: "_URL_"
}
{
  TypeMark: "20",
  Keynote: "--KEYNOTE--",
  StoreyName: "Level: Level 1",
  TypeDescription: "--DESCRIPTION--",
  StatusConstruction: "New Construction",
  NetArea: "3.18957899999998",
  Height: "2134.",
  Width: "915.",
  SillHeight: "0.",
  Hyperlink: "--URL--"
}

In summary: We have performed a simple parsing.

We have only included walls and doors in our config file. See: const selectedEntities: string[] = ["IFCDOOR", "IFCWALLSTANDARDCASE"];

TODO

Roadmap

This project is still in it's early development. And yes, it still has some bugs. Please be patience!

See the open issues for a list of proposed features (and known issues).

Contributing

This project is still in it's early development. But, any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

See LICENSE for more information.

Contact

Extra

Not what you're looking for? Check out these projects instead!

bim-whale's People

Contributors

andrewisen avatar dependabot[bot] avatar

Stargazers

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

Watchers

 avatar  avatar  avatar

bim-whale's Issues

Remove Deno

Deno is an unnecessary dependancy. Replace with a regular JS bundler.

Update IFC naming convention

The term entity instance is a bit confusing.

What is the difference between "entity", "instance" and "entity instance"?

For example, the method generateStepInstance( ) doesn't make that much sense.
Things become more chaotic when we introduce instanceId and entityName.

Try to update the IFC naming convention to make the code more readable.

Add test

Deno has built in testing.
Add a simple test to make development easier.

Difficult properties to parse

Some IfcPropertySingleValue that are difficult to parse

'Type',$,IFCLABEL('Table-Night Stand: 24" x 24" x 30"'),$
'URL',$,IFCLABEL('http://www.website.com/anchor#!/800X800-1'),$
'SystemID',$,IFCLABEL('Piping System: KB03R'),$
'TypeDescription',$,IFCTEXT('Circular, smooth,R=D'),$
'AboveGround',$,IFCLOGICAL(.U.),$
'StoreyName',$,IFCTEXT('Level: 02 - Floor'),$
'Diameter',$,IFCPOSITIVELENGTHMEASURE(315.),$
'TypeDescription',$,IFCTEXT('K30, R\X2\00F6\X0\rsk\X2\00E5\X0\l mineralull ytbekl armerad al-folie difft\X2\00E4\X0\t'),$
'Render Appearance Properties',$,IFCTEXT('{2, 15},{39, RPC-16-FXGQ-QK7X-PJ74-6000-ST1L-LVER-AU},{1, 0},{1, 0},{2, 36},{1, 8},{5, Color},{1, 0},{1, 0},{3, 0.8},{3, 0.8},{3, 0.8},{1, 8},{7, BBoxMin},{1, 0},{1, 0},{1, 0},{1, 0},{1, 0},{1, 8},{7, BBoxMax},{1, 0},{1, 0},{1, 0},{1, 0},{1, 0},{2, 11},{9, RPCTypeId},{1, 0},{1, 0},{39, RPC-16-FXGQ-QK7X-PJ74-6000-ST1L-LVER-AU},{1, 6},{14, RPCPlantHeight},{1, 0},{1, 0},{7, 18.0446},{2, 11},{7, keyword},{1, 0},{1, 0},{140, :Geometry:RPC:Golden-chain :Laburnum:Laburnums are very small trees native to southern Europe.  The common cultivar in Canada is ''Watereri''.},{2, 11},{8, category},{1, 0},{1, 0},{16, :Trees [General]},{2, 11},{12, LocalizedUID},{1, 0},{1, 0},{13, Golden-chain },{2, 14},{6, Height},{1, 0},{1, 0},{7, 18.0446},{1, 2},{16, Cast Reflections},{1, 0},{1, 0},{1, 0},{1, 2},{12, Cast Shadows},{1, 0},{1, 0},{1, 1},{1, 2},{9, Lock View},{1, 0},{1, 0},{1, 0},{1, 4},{5, ViewC},{1, 0},{1, 0},{1, 0},{2, 11},{11, RPCFilePath},{1, 0},{1, 0},{99, C:\\RevitRender\\Version2015940\\2017\\assetlibrary_base.fbm\\RPCs\\ArchVision_Stills_T5_Golden_Chain.rpc},{2, 11},{20, AdvancedUIDefinition},{1, 0},{1, 0},{0, },{2, 11},{10, AssetLibID},{1, 0},{1, 0},{36, 4D3F6E72-3F99-4203-98E9-AF80B3C7A7A4},{2, 11},{10, BaseSchema},{1, 0},{1, 0},{9, RPCSchema},{2, 11},{12, ExchangeGUID},{1, 0},{1, 0},{0, },{1, 2},{6, Hidden},{1, 0},{1, 0},{1, 0},{1, 4},{11, RPCCategory},{1, 0},{1, 0},{1, 0},{2, 11},{8, RPCImage},{1, 0},{1, 0},{0, },{1, 4},{13, SchemaVersion},{1, 0},{1, 0},{1, 5},{2, 11},{12, UIDefinition},{1, 0},{1, 0},{0, },{2, 11},{6, UIName},{1, 0},{1, 0},{39, RPC-16-FXGQ-QK7X-PJ74-6000-ST1L-LVER-AU},{2, 11},{11, VersionGUID},{1, 0},{1, 0},{9, RPCSchema},{2, 11},{9, assettype},{1, 0},{1, 0},{11, RPCGeometry},{2, 11},{11, description},{1, 0},{1, 0},{0, },{2, 11},{9, localname},{1, 0},{1, 0},{3, RPC},{2, 11},{9, localtype},{1, 0},{1, 0},{3, RPC},{1, 4},{8, revision},{1, 0},{1, 0},{1, 1},{2, 11},{9, thumbnail},{1, 0},{1, 0},{0, },{1, 4},{7, version},{1, 0},{1, 0},{1, 1},{1, 2},{20, RPC_Cast Reflections},{1, 0},{1, 0},{1, 1},{1, 2},{16, RPC_Cast Shadows},{1, 0},{1, 0},{1, 1},{1, 2},{13, RPC_Lock View},{1, 0},{1, 0},{1, 0},{1, 4},{9, RPC_ViewC},{1, 0},{1, 0},{1, 0},{21, assetlibrary_base.fbx},{1, 5},'),$
 '2moeq0lkL9rx1tiYe2hZKW',#42,'Pipe Insulation:K30:11937246',$,'Pipe Insulation:K30',#1365555,#1367655,'11937246',.INSULATION.

JSON parse error

See #3 for more information!

$,$,(#194,#212) is parsed into [$,"$",["#194","#212"]], which is wrong.

Improve attribute parser method

The method _parseStepInstanceAttributes is very slow and ugly.

            .replace(/\\/g, "") // backward slashes
            .replace(/\//g, "\\/") // forward slashes
            .replace(/\"/g, '\\"') // quotation marks
            .replace(/[^,]\'\'[^\)]/g, "") // Apostrophes
            .replace(/(\(|\,)(\..+\.)(\)|\,?)/g, "$1'$2'$3") // ".T.", ".F.", ".UNDEFINED.", etc.
            .replace(
                /([A-Z]+\()'?([0-9a-åA-Ö-_\/({}),.%&@$:;+=?*"#<> ]*)'?\)/g,
                "'$1$2)'"
            ) // 1. Functions
            .replace(/(,\$)/g, ",'$$'") // 2. Indefinite attribute A
            .replace(/(\$,)/g, "'$$',") // 2. Indefinite attribute B
            .replace(/(^|,)\((#\d+.*?)\)/g, "$1[$2]") // 3. Nested attributes:
            .replace(/([,\[])(#\d+)+/g, "$1'$2'") // 4. References to other entities
            .replace(/,(\d+[.]\d*)/g, ",'$1'") // / 5. Integers
            .replace(/'/g, '"') + // Convert apostrophes to quotes

This needs to be replaced (!).

I will go back to the drawing board and think of a better solution.

Roadmap

Things todo:

  • Improve parser (more specific parse-step-instance-attributes.ts)
  • Add support for IfcProductType
  • Add dist (JS Bundle File)
  • Add web example (using the dist)
  • Implement Web Workers
  • Add more samples
  • Update Docs/Wiki
  • Fix spelling/language
  • etc. etc

Will there be added features?

The parser is very simple... it doesn't do much. Will there be added features?

In short, no. The goal of this repo is to provide learning resources.
I do not intend to build "the best parser in the world".... not yet :)

Parse properties correctly

Current output:

{
  TypeMark: "IFCLABEL('20')",
  Keynote: "IFCLABEL('--KEYNOTE--')",
  StoreyName: "IFCTEXT('Level: Level 1')",
  TypeDescription: "IFCTEXT('--DESCRIPTION--')",
  StatusConstruction: "IFCLABEL('New Construction')",
  NetArea: "IFCAREAMEASURE(3.18957899999998)",
  Height: "IFCLENGTHMEASURE(2134.)",
  Width: "IFCLENGTHMEASURE(915.)",
  SillHeight: "IFCLENGTHMEASURE(0.)",
  Hyperlink: "IFCTEXT('--URL--')"
}

Remove IFCTEXT, IFCLABEL, etc.

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.