How to: Create a new page


Topic:

Create a new page


Class hierarchy:

IPCsApplication IPCsDocument IPCsPages IPCsPage


Description:

To establish a connection to Automation, it's necessary to add the file "Dpscad_TLB" in your project uses-clause.
To access projects, symbols, text etc. in Automation, you need to make this call to get at variable to work from. When calling PCsApplication := coApplication.Create(); Automation will start up, if not allready started


Sourcecode:
[+] Delphi
uses DPSCAD_TLB;

var
  PCsApplication : IPCsApplication;
  ADocument : IPCsDocument;
  APage : IPCsPage;
begin
  PCsApplication := coApplication.Create();
  {active project}
  ADocument := PCsApplication.ActiveDocument;
  {create page}
  APage := ADocument.Drawing.Pages.Add(pf_Normal,'');
  {set pagefunction}
  APage.PageFunction := pf_Normal;
  {set title}
  APage.Title := 'Page Title';
  {set pagetype}
  APage.PageType := pt_Schematic;
  {set specific pagetab-name}
  Apage.PageNumber := 'Specific tabname';
  {or make pagetab-name, the current pagenumber}
  Apage.PageNumber := IntToStr(ADocument.Drawing.Pages.Count);
  {update drawing in Automation through IPCsApplication}
  PCsApplication.Redraw;
end;

[+] Visual Basic
Dim PCsApplication As Dpscad.IPCsApplication
Dim ADocument As Dpscad.PCsDocument
Dim APage As Dpscad.PCsPage
Dim PCs As IPCsApplication

Set PCs = CreateObject("PCsELautomation.Application")
'active project
ADocument = PCsApplication.ActiveDocument
'create page
APage = ADocument.Drawing.Pages.Add(Dpscad.psPageFunction.pf_Normal, "")
'set pagefunction
APage.PageFunction = Dpscad.psPageFunction.pf_Normal
'set title
APage.Title = "Page title"
'set pagetype
APage.PageType = Dpscad.psPageType.pt_Schematic
'set specifik pagetab-name
APage.PageNumber = "Specifict tabname"
'or make pagetab-name, the current pagenumber
APage.PageNumber = CStr(ADocument.Drawing.Pages.Count)
'update drawing in Automation through IPCsApplication
PCsApplication.Redraw()

[+] C#
Dpscad.IPCsApplication PCsApplication;
Dpscad.PCsDocument ADocument;
Dpscad.PCsPage APage;

Type PCs = Type.GetTypeFromProgID("PCsELautomation.Application");
PCsApplication = (Dpscad.IPCsApplication)Activator.CreateInstance(PCs);
/*active project*/
ADocument = PCsApplication.ActiveDocument;
/*create page*/
APage = ADocument.Drawing.Pages.Add(Dpscad.psPageFunction.pf_Normal, "");
/*set pagefunction*/
APage.PageFunction = Dpscad.psPageFunction.pf_Normal;
/*set title*/
APage.Title = "Page title";
/*set pagetype*/
APage.PageType = Dpscad.psPageType.pt_Schematic;
/*set specifik pagetab-name*/
APage.PageNumber = "Specifict tabname";
/*or make pagetab-name, the current pagenumber*/
APage.PageNumber = Convert.ToString(ADocument.Drawing.Pages.Count);
/*update drawing in Automation through IPCsApplication*/
PCsApplication.Redraw();