How to: Add a line


Topic:

Add a line


Class hierarchy:

IPCsApplication IPCsDocument IPCsDrawing IPCsPage IPCsLine


Description:

Create a variable of IPCsLine to store access to a line. A Line can be modified through this variable


Sourcecode:
[+] Delphi
uses DPSCAD_TLB;

var
  ADocument : IPCsDocument;
  APage : IPCsPage;
  ALine : IPCsLine;
  Point3D : TPCsPoint3d;
begin
  {check if we're connected to Automation}
  if CheckConnection() then    // (See function here)
    begin
      {active project}
      ADocument := PCsApplication.ActiveDocument;
      {active page}
      APage := ADocument.ActivePage;
      {create line}
      ALine := APage.Lines.Add;

      {first point on the line}
      Point3D.X := 10000;
      Point3D.Y := 10000;
      Point3D.Z := 0;
      ALine.AddPoint(Point3D);

      {second point on the line}
      Point3D.X := 10000;
      Point3D.Y := 30000;
      Point3D.Z := 0;
      ALine.AddPoint(Point3D);

      {third point on the line}
      Point3D.X := 20000;
      Point3D.Y := 20000;
      Point3D.Z := 0;
      ALine.AddPoint(Point3D);

      {update drawing in Automation through IPCsApplication}
      PCsApplication.Redraw;
    end;
end;

[+] Visual Basic
Dim ADocument As Dpscad.PCsDocument
Dim APage As Dpscad.PCsPage
Dim ALine As Dpscad.PCsLine
Dim Point3D As Dpscad.TPCsPoint3D

'check if we're connected to Automation
If CheckConnection() Then   // (See function here)
  'active project
  ADocument = PCsApplication.ActiveDocument
  'active page
  APage = ADocument.ActivePage
  'create line
  ALine = APage.Lines.Add()
  
  'first point on the line
  Point3D.X = 10000
  Point3D.Y = 10000
  Point3D.Z = 0
  ALine.AddPoint(Point3D)
  
  'second point on the line
  Point3D.X = 10000
  Point3D.Y = 30000
  Point3D.Z = 0
  ALine.AddPoint(Point3D)
  
  'third point on the line
  Point3D.X = 20000
  Point3D.Y = 20000
  Point3D.Z = 0
  ALine.AddPoint(Point3D)
  
  'update drawing in Automation through IPCsApplication
  PCsApplication.Redraw()
End If

[+] C#
Dpscad.PCsDocument ADocument;
Dpscad.PCsPage APage;
Dpscad.PCsLine ALine;
Dpscad.TPCsPoint3D Point3D;

/*check if we're connected to Automation*/
if (CheckConnection())   // (See function here)
{
  /*active project*/
  ADocument = PCsApplication.ActiveDocument;
  /*active page*/
  APage = ADocument.ActivePage;
  /*create line*/
  ALine = APage.Lines.Add();

  /*first point on the line*/
  Point3D.X = 10000;
  Point3D.Y = 10000;
  Point3D.Z = 0;
  ALine.AddPoint(Point3D);

  /*second point on the line*/
  Point3D.X = 10000;
  Point3D.Y = 30000;
  Point3D.Z = 0;
  ALine.AddPoint(Point3D);

  /*third point on the line*/
  Point3D.X = 20000;
  Point3D.Y = 20000;
  Point3D.Z = 0;
  ALine.AddPoint(Point3D);

  /*update drawing in Automation through IPCsApplication*/
  PCsApplication.Redraw();
}