DIAdem Help

Collection: LegendItems

  • Updated2024-09-12
  • 3 minute(s) read

Collection: LegendItems

The LegendItems object provides a collection of the Legend entries of an axis system or a contour display in DIAdem VIEW. Use the LegendItems collection to delete legend items or to add new legend items.

The following example displays a name for each legend entry. The DisplayObjType must be a Bode, CurveChart2D, Polar, Orbit, ShaftCenterline, or Contour type:

VBScriptPython

 

Dim oMyLegends, oMyLegendItem, sOutput
Set oMyLegends = View.ActiveSheet.ActiveArea.DisplayObj.LegendItems
sOutput = "Names of legend items: " & vbCrLf
For Each oMyLegendItem in oMyLegends
 sOutput = sOutput & oMyLegendItem.Name & vbCrLf
Next
Call MsgBox(sOutput)

The following examples add legend entries. The DisplayObjType must be a Bode, CurveChart2D, Polar, Orbit, ShaftCenterline or Contour type.

Legend with predefined, curve-related legend parameters, for example x-coordinates:

VBScriptPython

 

Dim oMyLegend1
Set oMyLegend1 = View.ActiveSheet.ActiveArea.DisplayObj.LegendItems.Add("CursorX")
oMyLegend1.Format ="d.dd"

Legend with channel-related base properties or custom properties, for example, channel length:

VBScriptPython

 

Dim oMyLegend2
Set oMyLegend2 = View.ActiveSheet.ActiveArea.DisplayObj.LegendItems.Add("Length")
oMyLegend2.Format = "d"

Legend with static text:

VBScriptPython

 

Dim oMyLegend3
Set oMyLegend3 = View.ActiveSheet.ActiveArea.DisplayObj.LegendItems.Add("<freetext>")
oMyLegend3.Title = "Free Text"
oMyLegend3.Format = "Any descriptive text"

Legend with variable contents:

VBScriptPython

 

Dim oMyLegend4
Set oMyLegend4 = View.ActiveSheet.ActiveArea.DisplayObj.LegendItems.Add("<freetext>")
oMyLegend4.Title = "Current Date"
oMyLegend4.Format = "Date: @CurrDate@"

Legend with script expressions or user commands:

VBScriptPython

 

Dim oMylegend5
Set oMyLegend5 = View.ActiveSheet.ActiveArea.DisplayObj.LegendItems.Add("<freetext>")
oMyLegend5.Title = "Y difference"
oMyLegend5.Format = "@@CurrentYDiff@@"

Properties

Count

Methods

Add | Item | Remove