02 - SP3DNetAPI - Commands
02 - SP3DNetAPI - Commands
Smart 3D .net API Training 2008. Intergraph Corporation. All Rights Reserved. Commands - 1
Types Of Commands
Basic Commands No further Graphic / Object inputs from Graphic Views/ Workspace Explorer after command is started.
Can be Modal or Non-Modal. Can get some inputs from a Form / RibbonBar* [non-modal commands].
Step Commands Can use Graphic, KeyBoard and Object Selection events.
Allow gathering inputs (objects, points) in steps and traverse between steps. Typically are non-modal, suspendable commands. Can get some inputs from a Form / RibbonBar*.
RibbonBar functionality in S3D .net API will be available later on. Till then, we can use Forms for the same purpose.
Smart 3D .net API Training 2008. Intergraph Corporation. All Rights Reserved. Commands - 2
Modal True/False Suspendable True/False EnableUIFlags prerequisites to run. Implement OnStart( ) OnSuspend ( ) User ModalCommand . .
OnStop ( ) OnResume ( )
Provide your implementation for the required properties and methods. Override only required Methods & Properties, leave alone others. It is as simple as that !!!
BaseGraphicCommand Specify AllowEvents True/False to indicate whether you want to receive events or not. Implement Mouse/Keyboard Event Handlers as required
User GraphicCommand . .
BaseStepCommand Setup Command Steps and Event handlers and implement as required. User StepCommand . .
Smart 3D .net API Training 2008. Intergraph Corporation. All Rights Reserved. Commands - 3
Command Manager checks this setting with the system state to decide whether to start the command or not.
Smart 3D .net API Training 2008. Intergraph Corporation. All Rights Reserved. Commands - 5
No
Yes
System invokes OnStart ( ) method and it runs till its logic completes and returns back to system.
Command Logic continues to run, event handlers responding to events (Mouse/KeyBoard/Selection change). OnSuspend( ) gets invoked when System (Command Mgr) suspends the command. OnResume( ) gets invoked when System (Command Mgr) resumes the command.
Manager)
True
False
OnStop( ) gets invoked when System (Command Mgr) stops the command. Command calls StopCommand ( ) to stop itself when appropriate. This results in OnStop( ) getting invoked.
Smart 3D .net API Training 2008. Intergraph Corporation. All Rights Reserved. Commands - 6
Command Implementation
User just provides an override implementation for those properties/methods which he needs to do something. Doesnt need to implement all methods/properties. Modal Property Return True / False as appropriate Suspendable Property Return True / False as appropriate EnableUISettings property Specify prerequisite conditions required for the command to run. See EnableUIFlagSettings flags.
Specify any combination of ActiveView / ActiveConnection / ActiveDocument / NonEmptySelectSet flags. Leaving it alone implies No Conditions required
Smart 3D .net API Training 2008. Intergraph Corporation. All Rights Reserved. Commands - 7
Command Implementation
OnStart ( ) Invoked by system when your command is started
for Modal Commands, this typically may do all the action, or show a form which has all logic. for Graphic / Step Commands, this typically does the initial setup and the event handlers have the functionality.
Smart 3D .net API Training 2008. Intergraph Corporation. All Rights Reserved. Commands - 8
Command Implementation
OnIdle( ) Invoked by system when it determines some idle time
Rarely commands have some implementation here, but you can do something like quick background processing of things without interfering with the main running functionality. For Graphic Commands, user implements required Graphic View Manager / Keyboard event handling (details in a later session) For Step Commands, user does Step Definition setup and implements Step / Graphic View Manager / Keyboard event handling (details in a later session)
Smart 3D .net API Training 2008. Intergraph Corporation. All Rights Reserved. Commands - 9
Command Priority
Commands are started with a preset priority, determined and requested by the starter (menuitem / toolbar icon / Custom commands dialog). Can be NormalPriority or HighPriority. HighPriority commands CANNOT commit/abort Transactions. Typically used for View manipulation, or any non-transacting non-dialog watch windows. Normal Priority used for most cases. Note : LowPriority has been deprecated and not to be used. May appear in the available options in the UI and the API enums, but still should not be used.
Smart 3D .net API Training 2008. Intergraph Corporation. All Rights Reserved. Commands - 10
If
CurrentCmd.Suspendable = True, and NewCmd.Priority > CurrentCmd.Priority
Then
Current Command is Suspended (OnSuspend( ) is invoked), and later resumed (OnResume( ) is invoked) when New Command stops.
All other cases, Current Command is stopped (OnStop( ) is invoked) when a new Command is started.
Smart 3D .net API Training 2008. Intergraph Corporation. All Rights Reserved. Commands - 11
Smart 3D .net API Training 2008. Intergraph Corporation. All Rights Reserved. Commands - 13
Implementation Expectations
Commands should not generally leave their modifications on the table, i.e. just modify things and leave them there for next command to commit to the database. i.e. either abort or commit the transaction (more on transactions later) before they are completely ended. Command should not generally inherit uncommitted changes done by other commands. Most cases, this can be simply handled by performing a TransactionMgr Abort in the initialization of the command. If it is a Helper command or a non-transaction based command, eg view manipulation etc, then it should not do an abort. There are few exceptions to above. In case of commands which do not perform any changes to business objects, or commands which do the changes and intentionally delegate the commit / abort responsibility to other commands (which they can start) Commands must withdraw their UI when they are suspended / stopped. There may be very rare exceptions to this. For example, the View Todo list command shows its form and the Form can be active after the Todo list command has exited. One can use other commands while the TODO list form is up. Wherever possible, all errors happening within the command logic must be handled internally in the command logic itself and not be propagated outward.
Smart 3D .net API Training 2008. Intergraph Corporation. All Rights Reserved. Commands - 14
When a command ends itself and there is no command in suspended state, the system starts the Default Command.
There exists an internal mechanism called Command Continuation which a Task can use to change this process as needed so as to restart the previously running command this mechanism is not yet available for End Users Automation as it is quite complex to use by end users. Eg : Route Pipe Insert Component & Finish notice the Route Pipe command continue
It is important to know this details because this knowledge helps to know the systems behavior and write better automation.
Smart 3D .net API Training 2008. Intergraph Corporation. All Rights Reserved. Commands - 15