Bitbybit Docs
    Preparing search index...

    Class IFCModelsBeta

    Creates, reads, writes and inspects whole IFC models. A model is a value: every method that changes one returns a new model and leaves the one it was given as it was, so a change can be undone by keeping the earlier model.

    Objects are found by their GlobalId or by the id given when they were added, such as north-wall, which the model turns into a GlobalId of its own. Storeys are in spatial, building elements in walls, slabs, doors and the rest.

    Index

    Constructors

    create

    • Beta

      Starts a new IFC4 model with a project, its site and one building, ready for storeys.

      Every length later given to the model is in lengthUnit, millimetres by default. With a seed, the same calls always write the same file; without one, the GlobalIds are random.

      Parameters

      • inputs: CreateModelDto

        The project's name, the site and building names, the length unit and a seed

      Returns Promise<IfcModelPointer>

      A new model

      let model = await bitbybit.ifc.model.create({ name: "House", seed: "house-1" });
      model = await bitbybit.ifc.spatial.addStorey({ model, id: "ground", name: "Ground floor", elevation: 0 });

    edit

    • Beta

      Removes an element, an empty storey or space, or a type nothing is of, with what only it uses. A wall takes its openings with their doors and windows, and the walls it was joined to are trimmed again; a door or window leaves its opening; an opening takes its doors and windows.

      Parameters

      Returns Promise<IfcModelPointer>

      A new model without the object

      model = await bitbybit.ifc.model.remove({ model, element: "partition" });
      
    • Beta

      Moves an element or a space, and turns it about the vertical through its own origin; what is placed on it, such as a wall's openings, moves with it. A joined wall moves with walls.edit, and an opening, door or window with openings.edit.

      Parameters

      Returns Promise<IfcModelPointer>

      A new model with the element moved

      model = await bitbybit.ifc.model.move({ model, element: "column-1", translation: [500, 0, 0], rotation: 45 });
      
    • Beta

      Sets one attribute of an object to a text, a number, true or false, such as a wall's Name, Description or Tag.

      The value is checked against the IFC schema, and an attribute that holds a reference, a derived attribute or the GlobalId cannot be set this way.

      Parameters

      Returns Promise<IfcModelPointer>

      A new model with the attribute set

      model = await bitbybit.ifc.model.setAttribute({ model, element: "north-wall", attribute: "Description", value: "Load bearing" });
      

    io

    • Beta

      Reads an IFC file into a model to inspect, change and write back.

      Entities are decoded only when asked for, and unchanged ones are written back exactly as read. An IFC2X3 file is read through IFC4, to be shown and queried; upgradeToIfc4 makes it editable. An .ifczip archive is read from the .ifc file it holds.

      Parameters

      Returns Promise<IfcModelPointer>

      The model the file holds

      const model = await bitbybit.ifc.model.read({ data: ifcText });
      const summary = await bitbybit.ifc.model.summary({ model });
    • Beta

      Turns a model read from an IFC2X3 file into an IFC4 model, which can be changed and is written as IFC4.

      New attributes stay unset, a newly required enumeration takes NOTDEFINED, sets lose repeats and a merged entity becomes its parent; other rows are written as read. Anything else stops the upgrade, naming the entity.

      Parameters

      Returns Promise<IfcModelPointer>

      The upgraded model

      const old = await bitbybit.ifc.model.read({ data: ifc2x3Bytes });
      const model = await bitbybit.ifc.model.upgradeToIfc4({ model: old });
    • Beta

      Writes a model as the text of an .ifc file.

      The header records fileName and timeStamp; give a fixed timeStamp to write the same text every time. Entities read from a file and left unchanged are written as they were read, character for character.

      Parameters

      Returns Promise<string>

      The text of the IFC file

      const text = await bitbybit.ifc.model.write({ model, fileName: "house.ifc" });
      
    • Beta

      Writes a model as the bytes of an .ifc file, at any size.

      The header records fileName and timeStamp, as model.write's does. Entities read from a file and left unchanged are copied byte for byte, so a file of hundreds of megabytes writes in a moment, where its text would not fit one JavaScript string.

      Parameters

      Returns Promise<Uint8Array<ArrayBufferLike>>

      The bytes of the IFC file

      const bytes = await bitbybit.ifc.model.writeBytes({ model, fileName: "house.ifc" });
      

    query

    • Beta

      Describes what a model holds: its schema, its project, its unit, its storeys and how many elements of each type.

      Parameters

      Returns Promise<ModelSummaryDto>

      The model's summary

      const summary = await bitbybit.ifc.model.summary({ model });
      console.log(summary.elementCounts.IfcWall);
    • Beta

      Reads where a model sits on the Earth: the map conversion that places its coordinates in a projected coordinate reference system, and its site's reference latitude, longitude and elevation. A file without them gives the defaults, with mapped and located false.

      Parameters

      Returns Promise<GeoreferenceDto>

      The model's georeference

      const georeference = await bitbybit.ifc.model.georeference({ model });
      console.log(georeference.crs, georeference.eastings, georeference.northings);
    • Beta

      Lists the objects of one IFC type, its subtypes included, optionally only those standing in one storey or other spatial element. An aggregate's part stands where its whole stands.

      type is any type with a GlobalId, such as IfcWall, IfcDoor or IfcElement for every building element. The list is in the order the model holds them.

      Parameters

      Returns Promise<ElementInfoDto[]>

      Each object's GlobalId, type, name and the spatial element it stands in

      const walls = await bitbybit.ifc.model.elements({ model, type: "IfcWall", storey: "ground" });
      
    • Beta

      Describes one object of a model: its GlobalId, its type, its name and the spatial element it stands in.

      Parameters

      Returns Promise<ElementInfoDto>

      The object's GlobalId, type, name and the spatial element it stands in

      const wall = await bitbybit.ifc.model.element({ model, element: "north-wall" });
      
    • Beta

      Reads one attribute of an object, such as a wall's Name, Description or Tag.

      The value comes back as the model holds it: a text, a number, true or false, null when the attribute is unset, { enum } for an enumeration value, { type, value } for a typed value, { ref } for a reference to another entity, or a list of these.

      Parameters

      Returns Promise<IfcValue>

      The attribute's value

      const description = await bitbybit.ifc.model.getAttribute({ model, element: "north-wall", attribute: "Description" });
      
    • Beta

      Says which GlobalId an id stands for in a model: the GlobalId itself, or the one the model derives from an id of your own such as north-wall.

      The answer does not depend on whether the model holds such an object yet.

      Parameters

      Returns Promise<string>

      The GlobalId, 22 characters

      const globalId = await bitbybit.ifc.model.globalIdOf({ model, id: "north-wall" });