How to insert a subdrawing using OLE/COM

rated by 0 users
This post has 1 Reply | 1 Follower

Top 10 Contributor
Posts 100
Supporter
Lasse Posted: 04-12-2011 15:58

A customer wanted to "make his own simple project generator".
The following Pascal code creates a new project, inserts a drawing template and inserts three subdrawings.

 

var
  A : IPCsApplication;
  SubDrawing : IPCsSubDrawing;
  Page : IPCsPage;
  Doc : IPCsDocument;
const
  oo_AutoPlace = 4;
  PathDK = 'C:\PCSELCAD\STANDARD\DATASKABELON\';
  PathUK = 'C:\PCSELCAD\STANDARD\DATATEMPLATE\';
begin
  A := CreateOleObject('PCsELautomation.Application') as IPCsApplication;
  A.Documents.Add('','');

  (A as IApp).InsertProject(0, PathDK + 'PCSL1L2L3NA3.PRO', '', 0);
  Doc := A.ActiveDocument;
  Page := Doc.Drawing.Pages[0];
  SubDrawing := Doc.Drawing.LoadSubDrawing(PathDK + 'PCSMOTOR2_VAR.PRO');
  Page.PlaceSubDrawing(SubDrawing, 0, 0,0,0, nil, oo_AutoPlace);
  Page.PlaceSubDrawing(SubDrawing, 0, 0,0,0, nil, oo_AutoPlace);
  SubDrawing := Doc.Drawing.LoadSubDrawing(PathDK + 'PCSMOTOR1_VAR.PRO');
  Page.PlaceSubDrawing(SubDrawing, 0, 0,0,0, nil, oo_AutoPlace);
end;

Top 10 Contributor
Posts 100
Supporter

Please note that this is a COM/OLE sample, and not a PC|SCHEMATIC Automation script that can be used from within PC|SCHEMATIC Automation.

Page 1 of 1 (2 items) | RSS