How to: Create a new projet


Topic:

Create a new projet


Class hierarchy:

IPCsApplication IPCsDocuments IPCsDocument


Description:

To establich a connection to Automation its 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;
  AFilename : string;
begin
  PCsApplication := coApplication.Create();
  AFilename := 'C:\Users\martin\Documents\NewProject.PRO';
  {set the filename of the project}
  ADocument := PCsApplication.Documents.Add('',AFilename);
  {saves the project}
  ADocument.SaveAs(AFilename);
  {set title of project}
  ADocument.Drawing.Title := 'Title of the Project';
end;

[+] Visual Basic
Dim PCsApplication As Dpscad.IPCsApplication
Dim ADocument As Dpscad.PCsDocument
Dim AFilename As String
Dim PCs As IPCsApplication

Set PCs = CreateObject("PCsELautomation.Application")
AFilename = "C:\\Users\\thomas\\Documents\\NewProject.PRO"
'set the filename of the project
ADocument = PCsApplication.Documents.Add("", AFilename)
'saves the project
ADocument.SaveAs(AFilename)
'set title of project
ADocument.Drawing.Title = "Title of the project"

[+] C#
Dpscad.IPCsApplication PCsApplication;
Dpscad.PCsDocument ADocument;
string AFilename;

Type PCs = Type.GetTypeFromProgID("PCsELautomation.Application");
PCsApplication = (Dpscad.IPCsApplication)Activator.CreateInstance(PCs);

AFilename = "C:\\Users\\thomas\\Documents\\NewProject.PRO";
/*set the filename of the project*/
ADocument = PCsApplication.Documents.Add("", AFilename);
/*saves the project*/
ADocument.SaveAs(AFilename);
/*set title of project*/
ADocument.Drawing.Title = "Title of the project";