How to: Add a circle


Topic:

Add a circle


Class hierarchy:

IPCsApplication IPCsDocument IPCsDrawing IPCsPage IPCsArc


Description:

Create a variable of IPCsArc to store access to a circle. A Circle can be modified through this variable


Sourcecode:
[+] Delphi
uses DPSCAD_TLB;

var
  ADocument : IPCsDocument;
  APage : IPCsPage;
  AArc : IPCsArc;
  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;

      {set position for circle}
      Point3D.X := 50000;
      Point3D.Y := 50000;
      Point3D.Z := 0;
      {set radius}
      ARadius := 15000;
      {set startangle}
      AStartAngle := 900;
      {set endangle}
      AEndAngle := 2700;

      {create circle}
      AArc := APage.AArcs.Add(Point3D,ARadius,AStartAngle,AEndAngle);

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

[+] Visual Basic
Dim ADocument As Dpscad.PCsDocument
Dim APage As Dpscad.PCsPage
Dim AArc As Dpscad.PCsArc
Dim Point3D As Dpscad.TPCsPoint3D
Dim ARadius, AStartAngle, AEndAngle As Integer

'check if we're connected to Automation
If CheckConnection() Then   // (See function here)
  'active project
  ADocument = PCsApplication.ActiveDocument
  'active page
  APage = ADocument.ActivePage

  'set position for circle
  Point3D.X = 50000
  Point3D.Y = 50000
  Point3D.Z = 0
  'set radius
  ARadius = 15000
  'set endangle
  AEndAngle = 2700

  'create circle
  AArc = APage.Arcs.Add(Point3D, ARadius, AStartAngle, AEndAngle)

  'update drawing in Automation through IPCsApplication
  PCsApplication.Redraw()
End If

[+] C#
Dpscad.PCsDocument ADocument;
Dpscad.PCsPage APage;
Dpscad.PCsArc AArc;
Dpscad.TPCsPoint3D Point3D;
int ARadius, AStartAngle, AEndAngle;

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

  /*set position for circle*/
  Point3D.X = 50000;
  Point3D.Y = 50000;
  Point3D.Z = 0;
  /*set radius*/
  ARadius = 15000;
  /*set endangle*/
  AEndAngle = 2700;

  /*create circle*/
  AArc = APage.Arcs.Add(Point3D, ARadius, AStartAngle, AEndAngle);

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