Import
Example
Notes
- Both functions take a
BuildingEditCommand.applyBuildingEditResolvedtakes eachkind.applyBuildingEditrejects some wall and opening commands, such ascreate-wallandadd-hosted-opening, with the coderesolved-edit-required. add-element,replace-elementandremove-elementchange one entry of a list of a storey:slabs,roofs,spaces,stairs,columns,beams,railings,instances,annotationsorroomSeparators.add-elementrejects an id that the list has.replace-elementandremove-elementreject an id that the list does not have. The new element ofreplace-elementmust have the same id.add-asset,replace-assetandremove-assetchange one asset of the model.add-assetrejects an id that exists.replace-assetandremove-assetreject an id that does not exist.remove-assetrejects an asset that an instance uses.add-wall-type,replace-wall-typeandremove-wall-typechange one wall type of the model: its wholedefinition, anameand itslayers.add-wall-typerejects atypeIdthat exists.replace-wall-typeandremove-wall-typereject atypeIdthat does not exist, asinvalid-target.remove-wall-typerejects a type that walls use, with onewall-type-in-useissue 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.applyBuildingEditrefusesreplace-wall-typewithresolved-edit-requiredwhen a storey with a wall of the type has hosted openings, saved joins or trims;applyBuildingEditResolvedrefuses new layers that make an opening stop fitting.add-opening-typeandremove-opening-typeedit the model’s opening type library. A referenced type cannot be removed. Theopening-type-in-useissue names its hosted and free openings.set-opening-typeassigns a matching type to one opening. Leave outwallIdfor a free opening. PasstypeId: nullto detach the type and keep the opening’s saved values. A hosted assignment or detachment requiresapplyBuildingEditResolvedor a session.replace-opening-typereplaces the definition and stamps every hosted and free opening that uses it, across all storeys, in one edit. If the edit changes hosted openings, useapplyBuildingEditResolvedor a session. If openings stop fitting,opening-does-not-fitnames them and the whole edit is refused.replace-wall-settingscan settypeRef, andflipped, in place ofthicknessandmaterial. Settings withtypeRefmust not havethicknessormaterial(type-sets-thickness); settings withouttypeRefneedthickness(missing-thickness).create-walltakestypeRefin the same way.add-storey,remove-storeyandreplace-storey-settingschange the storeys of one building.add-storeyrejects a storey id that the building has.remove-storeyrejects the last storey of a building.replace-storey-settingsreplaces thename, theelevation, theheight, theusageand theareaKindtogether. TheareaKindis what the plate of the storey counts as (gross,balcony,core,basement,parkingormechanical); a value that is not one of these is refused asinvalid-command.insert-storeyputs an empty storey on top ofbelowIdand raises the storeys above by its height.copy-storeycopiesfromIdon top of itself with new ids and raises the storeys above. Both take anewStoreyIdand refuse a taken id asinvalid-target.replace-storey-settingswithrestack: truemoves the storeys above by the change of the storey’s top.copy-storey-tocopies the elements of storeystoreyIdonto each storey oftargetStoreyIds(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 theirtypeRefandassetRef, 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 withinvalid-target, and a copy id that the model already uses withinvalid-targetand the issueduplicate-id.applyBuildingEditrefuses a copy with walls withresolved-edit-required.partsnames the lists thatcopy-storey-tocopies (walls,unhostedOpenings,slabs,roofs,columns,beams,spaces,ramps,stairs,railings,instances,annotations,roomSeparators,modelObjects); without it, every list is copied.wallsbrings 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 needwalls, railings on a stair needstairs, and a stair that cuts a slab of its storey needsslabs. Each is refused withinvalid-command, and the message names the item.replace: trueempties 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 withinvalid-command: withparts: ['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; replacingstairsunder a railing that stays needsrailings; and replacingslabsthat 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-masssets 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-buildingadds a whole building, last in the list: its storeys, their elements and its optionalmass. Each id in it must be new in the whole model. The smallest valid building has one storey, and for a massing study amasswith one segment whosestoreyIdsnames that storey and whoseheightis the height of the storey.remove-buildingremoves a building and all it holds; it rejects the last building of the model.replace-sitereplaces the site whole:boundary,lotLines,elevation,geoAnchor,trueNorthDegand thezoningrules. Withoutsite, the model has no site any more. The model check refuses a self-intersecting boundary and alotLineslist that does not have one class per boundary edge. RunevaluateZoningagain after the step; the command does not run it.- A
batchapplies itscommandsin 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 ascommand 2 of 3:. A batch cannot be empty and cannot hold a batch. replace-free-openingreplaces one free door or window whole in one step: its permitted fields, such as position, yaw and label. Itsopening.idmust equal itsopeningId, and a different kind is refused withinvalid-target.add-hosted-openingadds a door, a window or a void.add-free-openingadds a door or window at its saved pose. For a typed door or window, supplytypeRefand dimensions the type marks asown. Dimensions supplied by the type can be omitted. The type sets its governed fields.replace-wall-settingsreplaces all settings of one wall:thickness,height,material,color,labelName,locationLine,locationOffset,priority,joins,curtainand 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 withopening-does-not-fitand the fit numbers inissues; if the walls cannot be built, withwall-not-buildable. In a storey with hosted openings, saved joins or trims,applyBuildingEditrefuses it withresolved-edit-required.split-wallcuts one wall atstation, 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 getsnewWallIdand 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 thejoinssetting 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 withinvalid-command. A station inside an opening is refused withinvalid-geometry; the issue has the codesplit-inside-openingand gives the opening id and its span. A station 1 mm or less from a corner is refused withinvalid-geometryand the codesplit-segment-too-short. AnewWallIdthat is the id of anything in the model is refused withinvalid-target.insert-wall-pointadds a corner to wallwallIdatstation, the distance in metres along the wall from its first point. The point goes on a straight segment, which becomes two; it is pointsegmentIndex + 1of 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 itsoffset, so it stays where it is. Move the new point withmove-wall-pointin the samebatchfor one undo step. A station at an end or outside the wall is refused withinvalid-command. A station inside an opening is refused withinvalid-geometryand the codeinsert-inside-opening, a station 1 mm or less from a corner withinsert-segment-too-short, and a station on an arc segment withinsert-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,applyBuildingEditrefuses it withresolved-edit-required.move-wall-arcmoves the arc of segmentsegmentIndexso that it runs throughthrough. The two ends stay. A straight segment is refused withinvalid-target. A point on the chord is refused withinvalid-geometryand an issue with the codearc-collinearatarcs[i].through.merge-wallsjoins wallotherWallIdto wallwallIdwhere their ends meet, within 1 mm, and removesotherWallId. The merged wall keeps the id, the place, the label and the property sets ofwallId. 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 lineleftandrightswap, and its doors keep their hinge and swing (doorQuadrantq 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 thejoinssetting 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 withinvalid-targetand onemerge-settings-differissue for each field, with both values. Walls that do not meet, or a closed wall, are refused withinvalid-target.applyBuildingEditResolvedand a session check each split and merge on the resolved walls. In a storey with hosted openings, saved joins or trims,applyBuildingEditrefusessplit-wallandmerge-wallswithresolved-edit-required.replace-hosted-openingreplaces one door, window or hole of a wall in one step. Itsopening.idmust equal itsopeningId, and the opening keeps its kind and itsoffset; a different kind is refused withinvalid-target, a different offset withinvalid-command. If an opening that fitted stops fitting, the command is refused withopening-does-not-fitand the fit numbers inissues.applyBuildingEditrefuses it withresolved-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 sameopeningFitnumbers asmove-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 aheightabove 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
-0in a command is saved as0, because JSON has no-0. The command that you gave is not changed.NaNandInfinityare rejected asinvalid-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 setsorphan: trueon 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, withinvalid-targetand the issuemissing-ref-element. So adelete-wallof 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.applyBuildingEditResolved
Apply an immutable edit with exact junction-aware hosted-opening decisions.massSegmentHeightCommand
Thereplace-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 areplace-mass command; its elements are not part of it.