How to: Make a selection


Topic:

Make a selection


Class hierarchy:

IPCsApplication IPCsDocument


Description:

This is how to mark/select items on a page.


Sourcecode:
[+] Delphi
uses DPSCAD_TLB;

var
  ASym : IPCsSymbol;
  AreaLow, AreaHigh : TPCsPoint3D;
  page : IPCsPage;
  TheHandle : cardinal;
begin
  {check if we're connected to Automation}
  if CheckConnection() then    // (See function here)
    begin
      {lets assume the TheHandle have a valid handle to a symbol}
      ASymbol := PCsApplication.ActiveDocument.Drawing.GetSymbolFromHandle(-1,TheHandle);
      {make the selection only on the coordinate the given symbol is on}
      AreaLow := ASym.Position;
      AreaHigh := ASym.Position;
      {make the page the symbol is on active}
      PCsApplication.ActiveDocument.ActivePage := ASymbol.Page;
      {call the selection method}
      PCsApplication.ActiveDocument.SelectInWindow(AreaLow, AreaHigh,ASymbol.Page,ASymbol.Layer,'');
      PCsApplication.Redraw;
    end;
end;

[+] Visual Basic
Dim ASymbol As Dpscad.PCsSymbol
Dim AreaLow, AreaHigh As Dpscad.TPCsPoint3D
Dim TheHandle As Integer = 0

'check if we're connected to Automation
If CheckConnection() Then   // (See function here)
  'lets assume the TheHandle have a valid handle to a symbol
  ASymbol = PCsApplication.ActiveDocument.Drawing.GetSymbolFromHandle(-1, TheHandle)
  'make the selection only on the coordinate the given symbol is on
  AreaLow = ASymbol.Position
  AreaHigh = ASymbol.Position
  'make the page the symbol is on active
  PCsApplication.ActiveDocument.ActivePage = ASymbol.Page
  'call the selection method
  PCsApplication.ActiveDocument.SelectInWindow(AreaLow, AreaHigh, ASymbol.Page, ASymbol.Layer, "")
  PCsApplication.Redraw()
End If

[+] C#
Dpscad.PCsSymbol ASymbol;
Dpscad.TPCsPoint3D AreaLow, AreaHigh;
int TheHandle = 0;

/*check if we're connected to Automation*/
if (CheckConnection())   // (See function here)
{
  /*lets assume the TheHandle have a valid handle to a symbol*/
  ASymbol = PCsApplication.ActiveDocument.Drawing.GetSymbolFromHandle(-1, TheHandle);
  /*make the selection only on the coordinate the given symbol is on*/
  AreaLow = ASymbol.Position;
  AreaHigh = ASymbol.Position;
  /*make the page the symbol is on active*/
  PCsApplication.ActiveDocument.ActivePage = ASymbol.Page;
  /*call the selection method*/
  PCsApplication.ActiveDocument.SelectInWindow(AreaLow, AreaHigh, ASymbol.Page, ASymbol.Layer, "");
  PCsApplication.Redraw();
}