Application: PostCommandWorkflow
Revit Platform: All
Revit Version: 2014.0
First Released For: 2014.0
Programming Language: C#
Skill Level: Advanced
Category: Basics
Type: ExternalApplication

Subject: Demonstration of use of PostCommand() to drive user workflows
Summary: 
Use PostCommand() as a part of a customized workflow.  When a document does not have a new revision added, prompt to add one before saving.

Classes: 
Autodesk.Revit.UI.AddInCommandBinding
Autodesk.Revit.UI.RevitCommandId
Autodesk.Revit.UI.UIApplication
Autodesk.Revit.UI.TaskDialog
Autodesk.Revit.UI.IExternalEventHandler
Autodesk.Revit.DB.DocumentSavingEventArgs
Autodesk.Revit.UI.Events.TaskDialogShowingEventArgs
Autodesk.Revit.UI.Events.BeforeExecutedEventArgs
Autodesk.Revit.UI.PushButton

Project Files: 
•	Application.cs - Implements the Revit add-in interface IExternalApplication
•	PostCommandRevisionMonitorCommand.cs – The external command to set up the revision monitor and execute tasks related to it.
•	PostCommandRevisionMonitor.cs - This class has the capabilities to monitor when a document is saved, and prompt the user to add a revision before save takes place.

Description: 
This sample demonstrates how to use the PostCommand() method and various events to drive user workflows.  In this sample, the required behavior is to have the user create a new revision before saving the document.  If this has not happened, the save is prevented and the user is automatically entered into the Issue Sheets/Revisions editing command.  Once the revision has been added, the external event posts the save command to be run again.

The workflow of events and activities looks like this:
•	User tries to save
•	BeforeSaving event called
•	Message to user about missing new revision
•	TaskDialogShowing event set up
•	ExternalEvent set up
•	BeforeSaving cancelled
•	TaskDialogShowing event called
•	TaskDialog about document not being saved is dismissed
•	Issue Sheets/Revision posted (PostCommand())
•	In BeforeExecuting event for this command, ExternalEvent is raised (allows callback immediately after command concludes)
•	User adds new revision(s) and closes dialog
•	IExternalEventHandler is called
•	Unneeded events are removed
•	Save command is posted (PostCommand()).
•	Save concludes

Instructions: 
Open Revit and any editable project. 
1.	Push the Add-ins->UI->Setup revision monitor button.
2.	Make any edit to the project (other than adding a new revision)
3.	Push the save command.
4.	Watch for the task dialog popup about needing a new revision.
5.	Choose Add Revision
6.	Watch for the posted Issue Sheets/Revisions dialog
7.	Add a new revision.
8.	Close the dialog.
9.	Confirm that save has now taken place.
10.	Push the Add-ins->UI->Remove revision monitor button to deactivate the monitor.