Skip to main content
A pure edit applies one edit command to a building model and returns a new model. It needs no session, and it does not change the model that you give. Use it on a server, in a test, or when you do not need geometry.

Import

Example

Notes

  • Both functions take a BuildingEditCommand. applyBuildingEditResolved takes each kind. applyBuildingEdit rejects some wall and opening commands, such as create-wall and add-hosted-opening, with the code resolved-edit-required.
  • add-element, replace-element and remove-element change one entry of a list of a storey: slabs, roofs, spaces, stairs, columns, beams, railings, instances, annotations or roomSeparators. add-element rejects an id that the list has. replace-element and remove-element reject an id that the list does not have. The new element of replace-element must have the same id.
  • add-asset, replace-asset and remove-asset change one asset of the model. add-asset rejects an id that exists. replace-asset and remove-asset reject an id that does not exist. remove-asset rejects an asset that an instance uses.
  • add-wall-type, replace-wall-type and remove-wall-type change one wall type of the model: its whole definition, a name and its layers. add-wall-type rejects a typeId that exists. replace-wall-type and remove-wall-type reject a typeId that does not exist, as invalid-target. remove-wall-type rejects a type that walls use, with one wall-type-in-use issue that names the walls. The model check refuses a definition that is not a valid wall type, with the code and path of the problem. applyBuildingEdit refuses replace-wall-type with resolved-edit-required when a storey with a wall of the type has hosted openings, saved joins or trims; applyBuildingEditResolved refuses new layers that make an opening stop fitting.
  • add-opening-type and remove-opening-type edit the model’s opening type library. A referenced type cannot be removed. The opening-type-in-use issue names its hosted and free openings.
  • set-opening-type assigns a matching type to one opening. Leave out wallId for a free opening. Pass typeId: null to detach the type and keep the opening’s saved values. A hosted assignment or detachment requires applyBuildingEditResolved or a session.
  • replace-opening-type replaces the definition and stamps every hosted and free opening that uses it, across all storeys, in one edit. If the edit changes hosted openings, use applyBuildingEditResolved or a session. If openings stop fitting, opening-does-not-fit names them and the whole edit is refused.
  • replace-wall-settings can set typeRef, and flipped, in place of thickness and material. Settings with typeRef must not have thickness or material (type-sets-thickness); settings without typeRef need thickness (missing-thickness). create-wall takes typeRef in the same way.
  • add-storey, remove-storey and replace-storey-settings change the storeys of one building. add-storey rejects a storey id that the building has. remove-storey rejects the last storey of a building. replace-storey-settings replaces the name, the elevation, the height, the usage and the areaKind together. The areaKind is what the plate of the storey counts as (gross, balcony, core, basement, parking or mechanical); a value that is not one of these is refused as invalid-command.
  • insert-storey puts an empty storey on top of belowId and raises the storeys above by its height. copy-storey copies fromId on top of itself with new ids and raises the storeys above. Both take a newStoreyId and refuse a taken id as invalid-target. replace-storey-settings with restack: true moves the storeys above by the change of the storey’s top.
  • copy-storey-to copies the elements of storey storeyId onto each storey of targetStoreyIds (one or more, distinct, of the same building, not the source) in one step. Each copy gets the id ${id}@${targetStoreyId}, and the references inside the storey go with it: hosted openings, saved joins and face trims, the walls that dimensions follow, the stair of a railing, and a stair’s link to a slab hole of its own storey. A link to a slab hole of another storey is dropped, with an edit warning. Copies keep their typeRef and assetRef, because wall types and assets belong to the model. A railing path and a working plane are in world coordinates, so they move by the difference in elevation; a raised plane gets the id ${planeId}@${targetStoreyId}. A missing, repeated or source target is refused with invalid-target, and a copy id that the model already uses with invalid-target and the issue duplicate-id. applyBuildingEdit refuses a copy with walls with resolved-edit-required.
  • parts names the lists that copy-storey-to copies (walls, unhostedOpenings, slabs, roofs, columns, beams, spaces, ramps, stairs, railings, instances, annotations, roomSeparators, modelObjects); without it, every list is copied. walls brings the hosted openings, the saved joins and the wall network state. A copied item may not refer to an element that is not copied: dimensions that follow walls need walls, railings on a stair need stairs, and a stair that cuts a slab of its storey needs slabs. Each is refused with invalid-command, and the message names the item.
  • replace: true empties the copied lists of each target before the copy, so a repeated copy gives the same storeys and not a second set. An element that stays may not refer to one that goes, and is refused with invalid-command: with parts: ['walls'], a target with a dimension that follows a replaced wall is refused, so add 'annotations', which also replaces the target’s text and leader notes; replacing stairs under a railing that stays needs railings; and replacing slabs that a stair of another storey cuts is refused. A working plane that the copy makes again is replaced; a plane made by hand stays, even when nothing uses it any more.
  • replace-mass sets the mass of one building and the settings of all its storeys. A storey id that stays keeps its elements, a new id adds an empty storey, and a storey that is left out is removed. It rejects the removal of a storey that holds an element. massSegmentHeightCommand(model, buildingId, segmentId, height) gives this command for a new height of one segment.
  • add-building adds a whole building, last in the list: its storeys, their elements and its optional mass. Each id in it must be new in the whole model. The smallest valid building has one storey, and for a massing study a mass with one segment whose storeyIds names that storey and whose height is the height of the storey. remove-building removes a building and all it holds; it rejects the last building of the model.
  • replace-site replaces the site whole: boundary, lotLines, elevation, geoAnchor, trueNorthDeg and the zoning rules. Without site, the model has no site any more. The model check refuses a self-intersecting boundary and a lotLines list that does not have one class per boundary edge. Run evaluateZoning again after the step; the command does not run it.
  • A batch applies its commands in order and returns one model. If one command fails, the error has the code of that command, and its message starts with the place of the command, such as command 2 of 3:. A batch cannot be empty and cannot hold a batch.
  • replace-free-opening replaces one free door or window whole in one step: its permitted fields, such as position, yaw and label. Its opening.id must equal its openingId, and a different kind is refused with invalid-target.
  • add-hosted-opening adds a door, a window or a void. add-free-opening adds a door or window at its saved pose. For a typed door or window, supply typeRef and dimensions the type marks as own. Dimensions supplied by the type can be omitted. The type sets its governed fields.
  • replace-wall-settings replaces all settings of one wall: thickness, height, material, color, labelName, locationLine, locationOffset, priority, joins, curtain and the property sets. The settings follow the rules of a saved wall, and a setting that you leave out is removed. The wall keeps its id, its points, its place and its openings. The points are the location line, so a new thickness keeps that line in place. If an opening of the storey stops fitting, the command is refused with opening-does-not-fit and the fit numbers in issues; if the walls cannot be built, with wall-not-buildable. In a storey with hosted openings, saved joins or trims, applyBuildingEdit refuses it with resolved-edit-required.
  • split-wall cuts one wall at station, the distance in metres along the wall from its first point, into two walls with the same settings. The first part keeps the wall id and its place in the list. The second part gets newWallId and comes right after it. Each door, window and void goes to the part that holds it, at the same place. A closed wall becomes two open walls that meet at both ends, so the loop stays closed. The first part keeps the joins setting of the start and the second part the one of the end; the ends at the cut join as by default. A saved join of the wall moves to the part that has its end, and a saved join at the cut is removed. A station at an end or outside the wall is refused with invalid-command. A station inside an opening is refused with invalid-geometry; the issue has the code split-inside-opening and gives the opening id and its span. A station 1 mm or less from a corner is refused with invalid-geometry and the code split-segment-too-short. A newWallId that is the id of anything in the model is refused with invalid-target.
  • insert-wall-point adds a corner to wall wallId at station, the distance in metres along the wall from its first point. The point goes on a straight segment, which becomes two; it is point segmentIndex + 1 of the wall, or the last point when it is on the closing segment of a closed wall. The wall keeps its shape, its id, its settings and its place in the list, and each door, window and void keeps its offset, so it stays where it is. Move the new point with move-wall-point in the same batch for one undo step. A station at an end or outside the wall is refused with invalid-command. A station inside an opening is refused with invalid-geometry and the code insert-inside-opening, a station 1 mm or less from a corner with insert-segment-too-short, and a station on an arc segment with insert-on-arc. A saved join and a dimension reference stay on the segment that holds them. In a storey with hosted openings, saved joins or trims, applyBuildingEdit refuses it with resolved-edit-required.
  • move-wall-arc moves the arc of segment segmentIndex so that it runs through through. The two ends stay. A straight segment is refused with invalid-target. A point on the chord is refused with invalid-geometry and an issue with the code arc-collinear at arcs[i].through.
  • merge-walls joins wall otherWallId to wall wallId where their ends meet, within 1 mm, and removes otherWallId. The merged wall keeps the id, the place, the label and the property sets of wallId. The openings of the other wall get their offset on the merged wall. A wall that runs the other way is turned round first, in the same place: its location line left and right swap, and its doors keep their hinge and swing (doorQuadrant q becomes 5 - q). So a merge works in either order. A joint point on a straight line is removed. Two walls that meet at both ends become one closed wall. The merged wall keeps the joins setting of its two free ends; saved joins at those ends stay, and a saved join at the joint is removed. All other settings must be equal: if one is different, the command is refused with invalid-target and one merge-settings-differ issue for each field, with both values. Walls that do not meet, or a closed wall, are refused with invalid-target.
  • applyBuildingEditResolved and a session check each split and merge on the resolved walls. In a storey with hosted openings, saved joins or trims, applyBuildingEdit refuses split-wall and merge-walls with resolved-edit-required.
  • replace-hosted-opening replaces one door, window or hole of a wall in one step. Its opening.id must equal its openingId, and the opening keeps its kind and its offset; a different kind is refused with invalid-target, a different offset with invalid-command. If an opening that fitted stops fitting, the command is refused with opening-does-not-fit and the fit numbers in issues. applyBuildingEdit refuses it with resolved-edit-required.
  • A wall point move, a wall end move or a wall transform that makes a door, window or void stop fitting is refused with opening-does-not-fit. Its issue gives the same openingFit numbers as move-hosted-opening: the range where the opening fits on the edited wall and the nearest offset.
  • An edit whose wall cannot build is refused with wall-not-buildable, with an issue at the wall or at its field, such as a height above 1000 m.
  • A rejected command throws BmEditError. The model that you gave is not changed.
  • A command that is not valid because of one field names that field, its path and its value, such as command.settings.thickness: thickness must be > 0, got -0.2.
  • A -0 in a command is saved as 0, because JSON has no -0. The command that you gave is not changed. NaN and Infinity are rejected as invalid-command.
  • Some steps run only in a BuildingSession. A pure edit does not move the dimensions that follow a wall (startRef, endRef): only a session step moves them with the wall, moves their references on a split or a merge, and sets orphan: true on a dimension whose wall is deleted. The functions refuse a result in which a dimension refers to a wall that is not on its storey, with invalid-target and the issue missing-ref-element. So a delete-wall of a wall that a dimension follows is refused here; apply it with a session.
  • The functions check the full result. For an edit in an app, use a BuildingSession. It also builds the geometry and keeps undo and redo.

applyBuildingEdit

Apply one saved edit of a building model, or one batch of edits, and return a validated new model.
Throws: {BmEditError} If the command, target, or resulting geometry is invalid.

applyBuildingEditResolved

Apply an immutable edit with exact junction-aware hosted-opening decisions.

massSegmentHeightCommand

The replace-mass command that gives one segment of a saved mass the height height, snapped to whole storeys at the pitch of its top storey; undefined when the snapped height is the saved one.

BmEditError

A rejected edit; issues carries model-validation details when available.

Types

BmEditErrorCode

Stable category for a rejected building edit.

ReplaceMassCommand

Replace the mass of a building and the settings of its whole storey list in one step.

MassStoreySettings

The settings of one storey in a replace-mass command; its elements are not part of it.
string
required
string
number
required
World Y of the floor of the storey, in metres.
number
required
Floor-to-floor height in metres.
string
AreaKind
What the plate of the storey counts as; see BmStorey.areaKind.

BuildingCommand

Add or remove a whole building of a model.

ReplaceSiteCommand

Replace the site of a model whole: boundary, lot lines, grade, geo anchor, true north and zoning rules.
Last modified on December 4, 2026