Skip to main content
It keeps the views, the sheets and the markers of the project, and it owns the one 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 cannot hold a command of the project lists.

Checks of a command

  • Floorkit checks a project command as save() checks the project. A command that fails throws ProjectFileError and changes nothing.
  • The value -0, the value undefined and an object that is not plain give the code invalid-json-value.
  • The other codes of a project command are duplicate-item, unknown-item, item-id-mismatch and invalid-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 undo that reaches the “add view” step fails with view-in-use. Dispose that plan editor first.
  • Through manager.apply you cannot remove a storey while a plan view names it. The manager throws ProjectFileError with the code storey-in-use and the path of the view. Remove the view first. A remove-storey in a batch has the same check, also when the batch adds the storey again.
  • Through manager.apply you cannot remove a building while a saved view shows it: a plan view of one of its storeys, a section or elevation view with its buildingId, or a view whose elementIds lists anything the building holds. The code is building-in-use, with the path of the view. A bound 3D editor has the same check.
  • Through manager.apply you cannot remove the site, or give it a new id, while the elementIds of a view lists it. The code is site-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 throws ProjectFileError and changes nothing.

History

  • apply, undo and redo return the new revision. undo and redo return null when there is no step.
  • 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.
  • subscribe reports each step with its revision, its part (building or project) and its cause (apply, undo, redo or restore). A restore is 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, undo or redo in a listener. The manager throws an error with the code reentrant-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, call manager.apply, manager.undo and manager.redo. A direct manager.session.apply is counted as a step. A direct manager.session.undo or redo, 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 that save() 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 with manager.apply.

Files and errors

  • ProjectManager.open throws ProjectFileError for a bad file. A file that is valid, but whose building does not compile, throws BmBuildError or Error.
  • A project file from an earlier version opens, and the project commands work on it. save() writes the current version.
  • Add root to your scene one time. It stays the same object after each edit.
  • You make the GUIEditor and you dispose it. dispose() of the manager removes the plan editors and the session.
  • After dispose(), exportPdf gives a promise that rejects.
  • A deployed site needs a valid hostname key for exports, including a non-commercial demo. See Licensing.

Constructor

Pick<BuildOptions, "assetSources" | "massColors" | "stampMembership">
Build options of the one building session, for example the sources of external assets.
number
Metres from every wall beyond which a dragged door or window leaves its wall; default 0.35.
((error: unknown) => void)
Called when an editor rejects an edit, or cannot draw a step of the project lists.

Properties

BuildingSession
Read-only. The one building session of this project.
Group
Read-only. The built building. Add it to the Three.js scene one time.
number
Read-only. Goes up by one for each applied, undone or redone step.

Methods

open

Read project text, check it and build the building.

snapshot

The current views, sheets and markers, with the current building.

save

The current project as text.

apply

Apply one command.

undo

Undo the last step.

redo

Redo the last undone step.

subscribe

Call listener after each completed step.

mountPlanEditor

Mount a 2D plan editor for one saved plan view.

bindSceneEditor

Connect a 3D editor to this project; its edits pass the same storey checks as apply, and Delete of a part of a mass keeps a storey that a saved plan view shows.

setBuildableEnvelope

Show or hide the buildable envelope of the site in the 3D scene (root).

exportPdf

Export the given sheets, or each sheet, of the current project as one PDF.

dispose

Remove the plan editors of this manager, then the session.

Types

ProjectManagerOptions

ProjectCommand

One command of a project manager: an edit of the building or a change of the project lists.

ProjectListCommand

One change of the list of views, sheets or markers.

ProjectChange

One completed step of a project manager, as a subscriber gets it.
number
required
The revision of the manager after the step. A restore leaves the revision as it was.
'building' | 'project'
required
building is an edit of the session; project is a change of the project lists.
'apply' | 'undo' | 'redo' | 'restore'
required
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.
readonly string[]
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.
Last modified on October 13, 2026