EditCommand Class

An EditCommand performs an editing action on the backend. Any writes to the iModel in an editing session should be done from an EditCommand:

  • All changes to an iModel are made within a transaction (Txn).
  • Calling SaveChanges ends the current Txn and starts a new one.
  • Using EditCommand ensures all of the changes in a Txn are from the same source, as only one EditCommand may be active at a time.
  • Because there is currently no way to enforce this, it is important that all applications follow this rule. EditCommands are usually paired with and driven by EditTools on the frontend that can either be interactive tools or immediate tools. Interactive EditTools:
  • Can be a PrimitiveTool.
  • Can be an InputCollector in special cases such as EditManipulator.HandleTool.
  • Should not be a ViewTool, these should never write changes to the iModel. Immediate EditTools:
  • As direct subclasses of Tool that perform their function without further input or becoming the active tool, they potentially leave the current PrimitiveTool in an invalid state.
  • To avoid issues, immediate tools that start an EditCommand must call ToolAdmin.restartPrimitiveTool when they complete. EditCommands have a commandId that uniquely identifies them, so they can be found via a lookup in the EditCommandAdmin. Each EditCommand must be registered in the EditCommandAdmin with register or registerModule. Every time an EditCommand runs, a new instance of (a subclass of) this class is created.

@see BasicManipulationCommand for an example EditCommand.

Extended by

Implements

Methods

Name Description
constructor(iModel: IModelDb, ..._args: any[]): EditCommand    
onStart(): Promise<any>    
ping(): Promise<[propName: string]: any>    
requestFinish(): Promise<string> Called when another EditCommand wishes to become the active EditCommand.  

Properties

Name Type Description
commandId Static string The unique string that identifies this EditCommand class.  
ctor Accessor ReadOnly    
iModel Readonly IModelDb The iModel this EditCommand may modify.  
version Static string    

Defined in

Last Updated: 17 May, 2024