Skip to main content

Get notes

Get notes from sequence diagram

Use the ISequenceDiagram.Notes property to get notes.

public void GetNotes(ICommandContext c, ICommandParams p) 
{
ISequenceDiagram sequenceDiagram = c.App.Workspace.CurrentEditor as ISequenceDiagram;
if (sequenceDiagram == null) return;

//Get notes
INoteShapeCollection notes = sequenceDiagram.Notes;

var no = 1;
foreach (INoteShape note in notes)
{
c.App.Output.WriteLine("sample", $"{no}th note : {note.Text}");
no++;
}
}

An example of getting related notes from an element.

public void GetNotesByElement(ICommandContext c, ICommandParams p) 
{
ISequenceDiagram sequenceDiagram = c.App.Workspace.CurrentEditor as ISequenceDiagram;
if (sequenceDiagram == null) return;

//Get the related notes from the note anchors connected to the selected element
ISequenceShape element = sequenceDiagram.GetSelectedShapes().FirstOrDefault();
var noteAnchors = sequenceDiagram.NoteAnchors.Where(a => element.Equals(a.Target));
var notes = noteAnchors.Select(a => a.Note);

var no = 1;
foreach (INoteShape note in notes)
{
c.App.Output.WriteLine("sample", $"{no}th note : {note.Text}");
no++;
}
}

An example of getting related elements from a note.

public void GetNotesByElement(ICommandContext c, ICommandParams p) 
{
ISequenceDiagram sequenceDiagram = c.App.Workspace.CurrentEditor as ISequenceDiagram;
if (sequenceDiagram == null) return;

//Get the related elements from the note anchors connected to the selected note
INoteShape note = sequenceDiagram.GetSelectedShapes().FirstOrDefault() as INoteShape;
var elements = note.NoteAnchors.Select(a => a.Target);

var no = 1;
foreach (ISequenceShape element in elements)
{
c.App.Output.WriteLine("sample", $"{no}th element (model name) : {element.Model.Name}");
no++;
}
}