Import
Example
Notes
- Add
session.rootto your scene one time. It stays valid after each edit. - Read
session.revisionwhen an edit starts, and pass it toapply. If a different edit came first,applythrowsstale-revision. - The session of a
ProjectManagerhas the revision of the manager. It also goes up after each step of the views, sheets and markers, and a step of them makes an older revision stale. - An edit that fails changes nothing.
- Pass
onProgressto see the cost of each element of a build: the session calls it for each element of the first build and of each edit, and last for the flush, withdone,totalandelapsedMs. - A
-0in a command is saved as0, because JSON has no-0.lastEditCommandhas the0.NaNandInfinityare rejected asinvalid-command. - A new edit clears the redo list.
undoandredoreturnnullwhen there is nothing to do. snapshot()returns a copy of the building model. Save this copy.- After an edit, get the elements again from
currentBuildby their ids. A changed element can be a new object, and Floorkit then disposes the old object. A changed wall, and a door, a window or a hole on a wall, can also stay the same object with new geometry. add-element,replace-elementandremove-elementchange one slab, roof, room, stair, column, beam, railing or instance. Anaddrejects an id that the list has. Areplaceor aremoverejects an id that the list does not have, and the new element of areplacemust have the same id.add-asset,replace-assetandremove-assetchange one asset of the model.remove-assetrejects an asset that an instance uses.add-wall-type,replace-wall-typeandremove-wall-typechange one wall type of the model, each as one undo step.remove-wall-typerejects a type that walls use, with onewall-type-in-useissue that names the walls.add-wall-typeandremove-wall-typebuild nothing again.replace-wall-typebuilds again only the walls of the storeys that hold a wall of the type; only the walls whose thickness or join changes get new bodies, so the work does not grow with the size of the building. The session refuses new layers that make a door or window of a wall stop fitting, with the fit numbers, and then nothing changes.replace-wall-settingswithtypeRefgives a wall the thickness of its type. The location line stays in place and the openings keep their stations; the session refuses the step when a door or window stops fitting, with the fit numbers, as for a newthickness.add-storey,remove-storeyandreplace-storey-settingschange the storeys of a building.add-storeyrejects a storey id that the building has, andremove-storeyrejects the last storey.replace-masssets the mass of a building and the settings of all its storeys in one step.storeysis the new storey list, in its order. A storey id that stays keeps its walls and 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. Withoutmass, the building has no mass.massSegmentHeightCommand(model, buildingId, segmentId, height)gives this command for a new height of one segment, snapped to whole storeys.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. The session builds again only the storeys and the mass of the added or removed building, or only the site.- A
batchapplies several commands as one step: one revision, one build and one undo step. If one command fails, nothing changes, and the message of the error starts with the place of the command, such ascommand 2 of 3:. After a batch,lastEditCommandis the batch. - A session does not know the saved views of a project. Thus a
remove-storey, areplace-massor aremove-buildingthat removes a storey that a plan view names passes in a session.ProjectManager.applyrejects it. - The history is not saved in the project file.
Constructor
.op sources for the document’s external-op assets, keyed by their uri, as either a raw
buffer or an already-parsed definition. Fetching is the CALLER’s pre-step so this function stays
synchronous — the same split .opbase uses (OPBaseOptions.assetSources). An embedded-op asset
needs nothing here.The colour of a mass part by its use,
#rrggbb by use name, used for a part when neither it nor
its mass has a color. Replaces MASS_COLORS_BY_USE whole; a use it does not list takes
#a0b8c8. Pass it where the project is opened (ProjectManager build) so that the live build,
the plan drawings and the sheets take the same colours.Called after each element of the build and after the final flush, with its cost in
elapsedMs. A
build is synchronous: show the reports after it, or log them.Properties
Read-only. Stable scene node. The app may mount it once and retain it across edits.
Read-only. Goes up by one after each edit, undo or redo. The session of a
ProjectManager shares
the revision of the manager: it also goes up after each step of the views, sheets and markers.Read-only. Caller-owned identity of the latest successfully published edit or history replay;
after a batch it is the batch.
Methods
snapshot
apply
undo
redo
refreshDisplay
liveIds (of the whole build when omitted): their materials, shader hooks (onBeforeCompile, customProgramCacheKey) and shadow flags, also where a storey draws them through a batch, an instanced mesh or a merged fill.
setOutlineWidth
px CSS pixels wide: a wall’s outline, a body’s feature outline (setAppearance({ outline })) with the silhouette of its curved faces, and the other plain lines of a storey, whether a storey merges or bakes them or an element draws them itself (a selected or hovered element).
Throws: {RangeError} when px is not a finite number of at least 1.
subscribe
dispose
BuildingSessionError
Types
BuildingEditCommand
A single, serializable edit to an authored building model.BuildingSessionChange
What made the step.
restore is no saved step: a step failed after it changed built objects, and
the session built them again from the saved model.The live ids (keys of
currentBuild.elementsById and modelObjectsById) that the step built
again, added or removed, where a removed id is in the list and not in the build; absent when the
whole building was built again. An element that was built again is a new object, or the same
object with new geometry.BuildingSessionErrorCode
BatchCommand
Several edits as one step, in order: all of them or none.ReplaceBuildingModelCommand
Replace the complete strict building model as one compiled history step.ModelObjectEditCommand
One complete saved object edit; replacement preserves authored identity and kind.ElementListCommand
One saved edit of a storey list; a replacement keeps the element id and its list.BuildingElementCommand
One saved edit of a building list, as the element commands edit a storey list.AssetCommand
One saved edit of the block definitions of a model; an instance names its definition by id.WallTypeCommand
The package does not export this type by name.OpeningTypeCommand
Reserved edits of the model’s stamped opening-type library.MaterialCommand
The package does not export this type by name.SetPhaseCommand
Set or remove the phase of elements of one building, hosted openings included.RoofJoinCommand
Trim one roof against another roof of its building, on any storey, or undo it: the part ofroofId inside the mass of toRoofId goes, and the valley where they meet is a true edge.
StoreyCommand
One saved edit of the storeys of a building; the settings of a storey are replaced whole.StoreyCopyCommand
Copy the elements of one storey onto one or more existing storeys of the same building, as one step;copy-storey instead makes a new storey on top of its source.
One storey or more of the same building: distinct, and none of them the source.
true empties those lists of each target before the copy (walls also its saved joins and wall
network state), so copying walls onto storeys that already hold the same walls gives no second
wall. A working plane that this copy makes again
(${planeId}@${targetStoreyId}) and that only the removed model objects used
is replaced; any other plane stays, a plane made by hand included, even when nothing uses it any
more. An element that stays may not refer to one that goes (invalid-command): replacing walls
under a dimension that follows one needs annotations (which also replaces the target’s text and
leader notes), stairs under a railing need railings, and slabs that a stair cuts need that stair
replaced too. Absent or false: the copies are added.BuildingMoveCommand
Move buildingbuildingId by translation (world XZ metres), after turning it yawDeg degrees about origin when both are given, as one step: every storey’s walls with their doors, windows and voids, loose doors and windows, slabs, roofs with their rooflights and dormers, rooms, stairs, railings, ramps, columns, beams, chimneys, soil stacks, placed blocks, plan notes and room separators, and the building’s grid lines, working planes and mass.
The package does not export this type by name.
The turn in degrees, counter-clockwise seen from above (+X toward −Z), before the translation.
Given with
origin or not at all.SiteRoadCommand
Add, replace or remove one road of the site (BmSite.roads), as one saved step.
SiteWaterCommand
Add, replace or remove one water of the site (BmSite.waters), as one saved step, exactly as SiteRoadCommand does a road.
ContextBuildingCommand
Add, replace or remove one context building of the site (BmSite.contextBuildings), as one saved step, exactly as SiteRoadCommand does a road.
SlabTransformCommand
One saved slab transform in world XZ coordinates, retaining its vertical placement.SpaceTransformCommand
One saved space transform in world XZ coordinates, retaining its vertical placement.RoofTransformCommand
One saved roof transform in world XZ coordinates, retaining its vertical placement.StairTransformCommand
One saved stair transform in world XZ coordinates, retaining its vertical placement.StairSlabHoleFitCommand
Fit the slab hole a stair links to (slabHole) to the stair’s plan outline, grown by margin metres, as a shaft opening is sized from its stair.
The package does not export this type by name.
ElementReshapeCommand
NetworkWallTranslateCommand
Translate one compiled segment by a world XZ delta through its storey’s WallNetwork: the walls joined at its ends follow.Where the openings of a wall that follows go.
keep-place (default): an opening stays where it is
in the world while its segment keeps its line, and keeps its distance from the fixed end of a
segment that turns. keep-station: it keeps its distance from the start of its segment. An
opening that would leave its segment refuses the move and is named.NetworkWallEndMoveCommand
Move one end of a compiled segment through its storey’s WallNetwork.Where the openings of the segments that change go.
keep-place (default): an opening stays where
it is in the world while its segment keeps its line, and keeps its distance from the fixed end of
a segment that turns. keep-station: it keeps its distance from the start of its segment. An
opening that would leave its segment refuses the move and is named.WallCreateCommand
Append one complete authored wall run; openings require their own saved edit.WallDeleteCommand
Remove the complete authored run, including every segment of a closed wall.What becomes of the wall’s doors and windows:
'detach' (the default) keeps them as loose
openings where they are drawn; 'delete' deletes them with their host, as a person deleting a
wall in the editor means. Undo brings them back either way.WallSplitCommand
Cut wallwallId at station (metres along its centreline from its first point) into two walls with the same settings.
The package does not export this type by name.
WallMergeCommand
Join wallotherWallId to wall wallId where their ends meet (within 1 mm) and remove otherWallId.
The package does not export this type by name.
WallPointInsertCommand
Add a point to wallwallId at station (metres along its centreline from its first point), on a straight segment, which becomes two.
The package does not export this type by name.
WallsTranslateCommand
Translate the wallswallIds of one storey by translation, as one step.
The package does not export this type by name.
FilletWallsCommand
Round the corner where an end of wallwallIdA meets an end of wall wallIdB with a new curved wall newWallId of radius metres, in one step.
The package does not export this type by name.
BendWallCommand
The package does not export this type by name.HostedOpeningRemoveCommand
Remove one authored opening from its exact wall without changing its wall axis.FreeOpeningRemoveCommand
Remove one exact storey-owned free door or window without changing any wall.HostedOpeningCreateCommand
Add an authored door, window or void to its explicitly chosen wall.FreeOpeningCreateCommand
Add one physical door or window at an explicit free pose in a storey.FreeOpeningReplaceCommand
Replace one free door or window whole: its size, pose, type or label. The package does not export this type by name.HostedOpeningDetachCommand
Explicitly remove a door/window from its host and place it in world XZ metres. The package does not export this type by name.HostedOpeningRehostCommand
Move one door, window or void from its wall to a place on another wall of the same storey.ReshapeOpeningRule
Where a wall reshape puts the hosted openings of a segment that it changes. The package does not export this type by name.ElementLists
The storey lists that the element commands edit, with the element type of each list.BuildingElementLists
The building lists that the building element commands edit, with the element type of each.StoreyCopyPart
A list of a storey thatcopy-storey-to can copy.
ProfileTransform
A rigid world XZ transform shared by authored polygon families. The package does not export this type by name.Relative degrees. In a command, counter-clockwise seen from above: +X turns toward −Z. The
transforms here take it turned the other way, +X toward +Z (
oppositeYaw).SlabReshapeCommand
Replace one slab’s outline and thickness.RoofReshapeCommand
Replace one roof’s outline and its eave height above the storey.SpaceReshapeCommand
Replace one room’s outline and, when given, its height.StairReshapeCommand
Put one stair’s start point at a new place and height above the storey; a given size replaces its own.OpeningCreateInput
The package does not export this type by name.FramedOpening
The package does not export this type by name.Related
BmAssetInstanceBmAssetRefBmBeamBmChimneyBmColumnBmContextBuildingBmDoorBmGridLineBmLevelBmMaterialBmModelObjectBmOpeningBmOpeningTypeBmPhaseBmRailingBmRampBmRoadBmRoofBmRoomSeparatorBmSlabBmSoilStackBmSpaceBmStairBmStoreyBmStoreyAnnotationBmUnhostedOpeningBmWallBmWallSettingsBmWallTypeBmWaterBmWindowBuildingCommandBuildingModelBuildOptionsBuildResultPointXZPolygonProfileReplaceMassCommandReplaceSiteCommandWallEnd