BuildingSession that builds the building. It mounts the plan editors, connects the 3D editor, saves the project and exports the sheets. Each change is one step in one history, so one undo works for the building and for the sheets.
Import
Example
Notes
Project commands
apply takes an edit command of the building, or one of these commands of the project lists. Each item has an id. An edit command of the building can be a batch. A batch of project list commands is one step too, and it can hold building edits as well (see below).
Several list changes as one step
Put the commands of the project lists in onebatch when one change of the user changes a sheet and its markers. The manager applies the commands in order and adds one step to the history. One undo takes all of them back, and one redo puts them back.
undo takes back the building edits and the list changes together. A refused batch keeps the building, the lists, undo and redo as they were. BuildingSession.apply still takes building edits only.
- A batch is all or nothing. If one command fails,
applythrows the error of that command and nothing changes. The message starts with the place of the command, such ascommand 2 of 3:. - The checks of the project file run on the lists after the last command. Thus a marker can come before the view that it targets.
- A batch can hold project list commands and building commands together. The building edits are checked as the session checks them, and the project file is checked on the final building and lists. A batch in a batch, a gap in the list or an item that is not a command gives
ProjectFileErrorwith the codeinvalid-commandand the path of that item, such as$.commands[1]. - A batch with no command goes to the building session, which refuses it with
BmEditErrorand the codeinvalid-command.
Sheet order
Pass every existing sheet ID exactly once. The command keeps each sheet’s contents, viewports and resource references. Save/open and the default PDF export use the saved order. Duplicate, missing or unknown IDs giveinvalid-sheet-order; malformed command fields give invalid-command.
An unchanged order returns the current revision without a history step or notification. A batch containing only reorders that ends in the original order has the same no-op behavior. A batch containing other commands keeps its normal history behavior.
Checks of a command
- Floorkit checks a project command as
save()checks the project. A command that fails throwsProjectFileErrorand changes nothing. - The value
-0, the valueundefinedand an object that is not plain give the codeinvalid-json-value. - The other codes of a project command are
duplicate-item,unknown-item,item-id-mismatchandinvalid-command. - You cannot remove a view that a mounted plan editor shows, and you cannot make it a view that is not a plan. The code is
view-in-use. - If a plan editor shows a view that you added in this session, an
undothat reaches the “add view” step fails withview-in-use. Dispose that plan editor first. - Through
manager.applyyou cannot remove a storey while a plan view names it. The manager throwsProjectFileErrorwith the codestorey-in-useand the path of the view. Remove the view first. Aremove-storeyin abatchhas the same check, also when the batch adds the storey again. - Through
manager.applyyou cannot remove a building while a saved view shows it: a plan view of one of its storeys, a section or elevation view with itsbuildingId, or a view whoseelementIdslists anything the building holds. The code isbuilding-in-use, with the path of the view. A bound 3D editor has the same check. - Through
manager.applyyou cannot remove the site, or give it a new id, while theelementIdsof a view lists it. The code issite-in-use. - An undo or a redo of a step of the project lists is checked as
save()checks the project. A step that fails throwsProjectFileErrorand changes nothing.
History
apply,undoandredoreturn the new revision.undoandredoreturnnullwhen there is no step.revisioncounts the steps of the building and the steps of the views, sheets and markers.session.revisionis always the same number. Userevision; see The revision number.- A drag in an editor is a building step in the same history. The undo key in each editor undoes the last step of the manager.
subscribereports each step with itsrevision, itspart(buildingorproject; a mixed batch isproject) and itscause(apply,undo,redoorrestore). Arestoreis no new step and the revision stays as it was: a step of the building failed after it changed built elements, and the session built them again from the saved model.- Do not call
apply,undoorredoin a listener. The manager throws an error with the codereentrant-transition.dispose()in a listener during a building step throws the same code. - After a project step, the manager draws each mounted plan again. Thus one project step costs one plan draw for each mounted plan editor.
- With a
ProjectManager, callmanager.apply,manager.undoandmanager.redo. A directmanager.session.applyis counted as a step. A directmanager.session.undoorredo, and a storey command sent to the session while a view names that storey, can leave a step that the manager cannot undo, or a project thatsave()refuses. While a view names a missing storey, the undo of each project step is refused. To repair it, undo the building step, or remove the view withmanager.apply.
Files and errors
ProjectManager.openthrowsProjectFileErrorfor a bad file. A file that is valid, but whose building does not compile, throwsBmBuildErrororError.- A project file from an earlier version opens, and the project commands work on it.
save()writes the current version. - Add
rootto your scene one time. It stays the same object after each edit. - You make the
GUIEditorand you dispose it.dispose()of the manager removes the plan editors and the session. - After
dispose(),exportPdfgives a promise that rejects. - A deployed site needs a valid hostname key for exports, including a non-commercial demo. See Licensing.
Constructor
Build options of the one building session, for example the sources of external assets.
Called when an editor rejects an edit, or cannot draw a step of the project lists.
Properties
Read-only. Goes up by one for each applied, undone or redone step, of the building or of the
views, sheets and markers.
session.revision is the same number.Methods
open
snapshot
save
apply
undo
redo
subscribe
listener after each completed step.
mountPlanEditor
bindSceneEditor
apply, and Delete of a part of a mass keeps a storey that a saved plan view shows.
replaceFields
undo reverts.
Throws: {BmEditError} edit-not-available when the element has no saved fields to change;
the refusal of an edit that cannot be saved (onError hears it first). Nothing changes then.
filletRadius
setBuildableEnvelope
root).
renderSheetPreview
exportPdf
live-edit-open (the promise rejects) while a bound editor has a
gesture open; export again in its onGestureEnd.
dispose
Types
ProjectManagerOptions
ProjectCommand
One command of a project manager: an edit of the building, a change of the project lists, or abatch that holds both.
ProjectListCommand
One change of the list of views, sheets, markers or map sources.ProjectChange
One completed step of a project manager, as a subscriber gets it.building edits only the session; project changes lists, possibly with building edits.What made the step.
restore is no saved step: a step of the building failed after it changed
built objects, and the session built them again from the saved model.The live ids of the built elements that the step built again, added or removed, where a removed id
is in the list and not in the build; empty for a step of the project lists, and 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.
SelectedPart
EditorChange
Emitted after every write-back, viaGUIEditor.onChange or createModelRenderer().onChange.
The edited element’s id, where the surface knows it — the 2D plan view always does, because it
resolved the element from a picked
ogid in the first place. This is what lets a host write the
edit back to its own store without searching for which element changed. EditableTarget is a bare
THREE.Object3D and carries no id of its own.The elements whose built objects the step changed.
ogid and target name the element of the
last command of the step whose element changed.ManagerExportOptions
The export options of aProjectManager: its own session gives what the export reads.
The package does not export this type by name.