How to: Modify a circle


Topic:

Modify 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;
  AArcs : IPCsArcs;
  AArc : IPCsArc;
  PosX, PosY, PosZ : integer;
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;
      {all circles}
      AArcs := APage.Arcs;

      {get a random circle of the circles in the active page}
      AArc := AArcs.Item[Random(AArcs.Count)];
      {get position of that circle}
      AArc.GetPosition(PosX,PosY,PosZ);
      {modify the position of that circle}
      PosX := PosX + 10000;
      PosY := PosY + 10000;
      {update the circle with the new positions and new radius}
      AArc.SetPosition(PosX,PosY,PosZ);
      AArc.Radius := 7000;

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

[+] Visual Basic
Dim ADocument As Dpscad.PCsDocument
Dim APage As Dpscad.PCsPage
Dim AArcs As Dpscad.PCsArcs
Dim AArc As Dpscad.PCsArc
Dim PosX, PosY, PosZ 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
  'all circles
  AArcs = APage.Arcs
  
  'get a random circle of the circles in the active page
  AArc = AArcs(Int((AArcs.Count + 1) * Rnd()))
  'get position of that circle
  AArc.GetPosition(PosX, PosY, PosZ)
  'modify the position of that circle
  PosX += 10000
  PosY += 10000
  'update the circle with the new positions and new radius
  AArc.SetPosition(PosX, PosY, PosZ)
  AArc.Radius = 7000
  
  'update drawing in Automation through IPCsApplication
  PCsApplication.Redraw()
End If

[+] C#
Dpscad.PCsDocument ADocument;
Dpscad.PCsPage APage;
Dpscad.PCsArcs AArcs;
Dpscad.PCsArc AArc;
Random rnd = new Random();
int PosX, PosY, PosZ;

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

  /*get a random circle of the circles in the active page*/
  AArc = AArcs[rnd.Next(AArcs.Count)];
  /*get position of that circle*/
  AArc.GetPosition(out PosX, out PosY, out PosZ);
  /*modify the position of that circle*/
  PosX += 10000;
  PosY += 10000;
  /*update the circle with the new positions and new radius*/
  AArc.SetPosition(PosX, PosY, PosZ);
  AArc.Radius = 7000;

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