Altova UModel 2024 Enterprise Edition

How to generate Sequence Diagrams from code

Home Prev Top Next

Sequence diagrams in UModel can be generated programmatically from an IUMLOperation element. The operation needs to exist in the model and have some source code associated to it.

 

The operation could possibly have been previously "read" by the reverse engineering functionality of UModel. Creating new Sequence Diagrams programmatically by reverse engineering source code using the UModel API involves two short steps:

 

Setting up the options for diagram generation

Invoking the diagram generation function

 

The following C# code shows how to set up the options and start the generation of the sequence diagram:

 

// starts the sequence diagram generation process based on an operation given as parameter
public static void reverseEngineerAndCreateSequenceDiagram(IApplication application, IUMLOperation operation)
{
  GenerateSequenceDiagramDlg dialog = application.Dialogs.GenerateSequenceDiagramDlg;
 
  // set some options
  dialog.ShowEmptyCombinedFragments = false;
  dialog.UseDedicatedLineForStaticCalls = true;
  dialog.ShowCodeOfMessagesDisplayedDirectlyBelow = true;
  dialog.ShowCodeInNotes = true;
   
  dialog.ShowDialog = true; // set this to true if you want the dialog to be displayed
 
  // generated the sequence diagram now
  application.ActiveDocument.GenerateSequenceDiagram(dialog, operation);
}

 

© 2018-2024 Altova GmbH