Using Scripts


Using scripts

The scripting environment is accessed through the tools-menu, if the module: 'Scripts' is installed. Scripts can be written in either Pascal or Basic. Automation comes with a number of scripts that serve as examples, and add functionality. In scripts, there is no need to create a connection to Automation. The connection already exists through the 'PCsApplication' object. So if you use the Delphi-code-examples to write scripts, you can omit the call of CheckConnection().

Here is a simple example of a pascal-script adding a text to a page:

Code:
var
  ADocument : IPCsDocument;
  APage : IPCsPage;
  AText : IPCsText;
  Point3D : TPCsPoint3d;
begin
  {active project}
  ADocument := PCsApplication.ActiveDocument;
  {active page}
  APage := ADocument.ActivePage;

  {set position for text}
  Point3D.X := 30000;
  Point3D.Y := 80000;
  Point3D.Z := 0;

  {create text}
  AText := APage.Texts.Add(Point3D, 'This is the Text');

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