How to: Get a symbol


Topic:

Get a symbol


Class hierarchy:

IPCsApplication IPCsDocument IPCsDrawing IPCsPage IPCsSymbol


Description:

Create a variable of IPCsSymbol to store access to a symbol. A Symbol can be modified through this variable


Sourcecode:
[+] Delphi
uses DPSCAD_TLB;

var
  PCSComOb : IPCsApplication;
  Symbol : IPCsSymbol;
  i : integer;
begin
  PCsApplication := coApplication.Create();

  {selecting specific symbol}
  Symbol := PCsApplication.ActiveDocument.ActivePage.Symbols.Item[i];

  {running through all symbols on page x}
  for i:= 0 to (PCsApplication.ActiveDocument.Drawing.Pages[x].Symbols.Count - 1) do
    begin
      Symbol := PCsApplication.ActiveDocument.Drawing.Pages[x].Symbols.Item[i];
      if (Symbol.SymbolType1 = st_Terminal) then
        Memo1.lines.add('Symbolname=' + Symbol.FullName + ' is a terminal');
    end;
end;

[+] Visual Basic
Dim PCsApplication As Dpscad.IPCsApplication
Dim Symbol As Dpscad.PCsSymbol
Dim PCs As IPCsApplication

Set PCs = CreateObject("PCsELautomation.Application")
'selecting specific symbol
Symbol = PCsApplication.ActiveDocument.ActivePage.Symbols(i)

'running through all symbols on page x
For i As Integer = 0 To PCsApplication.ActiveDocument.Drawing.Pages(x).Symbols.Count - 1
  Symbol = PCsApplication.ActiveDocument.Drawing.Pages(x).Symbols(i)
  If Symbol.SymbolType1 = Dpscad.psSymbolType.st_Terminal Then
    listBox1.Items.Add("Symbolname=" & Symbol.FullName & " is a terminal")
  End If
Next

[+] C#
Dpscad.IPCsApplication PCsApplication;
Dpscad.PCsSymbol Symbol;

Type PCs = Type.GetTypeFromProgID("PCsELautomation.Application");
PCsApplication = (Dpscad.IPCsApplication)Activator.CreateInstance(PCs);

/*selecting specific symbol*/
Symbol = PCsApplication.ActiveDocument.ActivePage.Symbols[i];

/*running through all symbols on page x*/
for (int i = 0; i < PCsApplication.ActiveDocument.Drawing.Pages[x].Symbols.Count; i++)
{
  Symbol = PCsApplication.ActiveDocument.Drawing.Pages[x].Symbols[i];
  if (Symbol.SymbolType1 == Dpscad.psSymbolType.st_Terminal)
  {
    listBox1.Items.Add("Symbolname=" + Symbol.FullName + " is a terminal");
  }
}