How to: Change position of a symbol


Topic:

Change position of a symbol


Class hierarchy:

IPCsApplication IPCsDocument IPCsDrawing IPCsPage IPCsSymbol TPCsRect


Description:

To get the coordinates from a symbols position, you should use a symbols GetRect-method. The Method takes a PsSymbolRectType as parameter, and returns a TPCsRect


Sourcecode:
[+] Delphi
uses DPSCAD_TLB;

const
  MoveRight = 10;
var
  PCsApplication : IPCsApplication;
  Page : IPCsPage;
  Rect : TPCsRect;
  i : integer;
begin
  PCsApplication := coApplication.Create();
  Page := PCsApplication.ActiveDocument.ActivePage;
  {running through all symbols on page}
  for i := 0 to Page.Symbols.Count - 1 do
    begin
      Rect := PCsApplication.Symbols[i].GetRect(rt_Raw);
      {move symbol 10 units to the right}
      Rect.Left := Rect.Left + MoveRight;
      Rect.Right := Rect.Right + MoveRight;
    end
end;

[+] Visual Basic
Const MoveRight As Integer = 10
Dim PCsApplication As Dpscad.IPCsApplication
Dim Page As Dpscad.PCsPage
Dim Rect As Dpscad.TPCsRect
Dim PCs As IPCsApplication

Set PCs = CreateObject("PCsELautomation.Application")
Page = PCsApplication.ActiveDocument.ActivePage
'running through all symbols on page
For i As Integer = 0 To Page.Symbols.Count - 1
  Rect = Page.Symbols(i).GetRect(Dpscad.PsSymbolRectType.rt_Raw)
  'running through all symbols on page
  Rect.Left += MoveRight
  Rect.Right += MoveRight
Next

[+] C#
const int MoveRight = 10;
Dpscad.IPCsApplication PCsApplication;
Dpscad.PCsPage Page;
Dpscad.TPCsRect Rect;

Type PCs = Type.GetTypeFromProgID("PCsELautomation.Application");
PCsApplication = (Dpscad.IPCsApplication)Activator.CreateInstance(PCs);
Page = PCsApplication.ActiveDocument.ActivePage;
/*running through all symbols on page*/
for (int i = 0; i < Page.Symbols.Count; i++)
{
  Rect = Page.Symbols[i].GetRect(Dpscad.PsSymbolRectType.rt_Raw);
  /*running through all symbols on page*/
  Rect.Left += MoveRight;
  Rect.Right += MoveRight;
}