uses DPSCAD_TLB;
var
MyPoint : TPCsPoint3D;
ALibtype : IPCsLibType;
ADatafield : IPCsDatafield;
ADataFields : IPCsDatafields;
ASymbol : IPCsSymbol;
i, t : integer;
APage : IPCspage;
AStr : string;
begin
{write datafield value}
{adding a symbol to the LibType}
ALibtype := PCsApplication.ActiveDocument.Drawing.LibTypes.Add('SymbolFileName.sym');
{MyPoint is the offset, from the symbols position. So this means that the
datafield will be placed 10000 up, and 10000 right, from the symbols position}
MyPoint.X := 10000;
MyPoint.Y := 10000;
MyPoint.Z := 0;
{add a datafield to the libtype}
ADatafield := ALibtype.Datafields.Add(MyPoint,'');
{process the datafield}
with ADatafield do
begin
{setting the pretext}
Pretext := 'My Pretext';
{ProjectData (none-predefined) see list here}
SetDataNo(10 {FirstProjData},PCsApplication.ActiveDocument.DataLink);
FieldName := 'Customer Name'; {to get a list of valid valued, see this code}
end;
{getting current page}
APage := PCsApplication.ActiveDocument.ActivePage;
{create a symbol, from LibType}
ASymbol := APage.Symbols.Add(ALibtype);
{setting symbolname}
ASymbol.FullName := 'MyNewSymbol';
{setting position}
ASymbol.SetPosition(100000, 100000,0);
{repaint project}
PCsApplication.Redraw;
{read a datafield value}
{get active page}
APage := PCsApplication.ActiveDocument.ActivePage;
if APage.Symbols.Count > 0 then
for i := 0 to APage.Symbols.Count - 1 do {for each symbol}
if APage.Symbols.Item[i].Datafields.Count > 0 then {symbols has datafields}
begin
AStr := '';
{get the symbols datafields}
ADataFields := APage.Symbols.Item[i].Datafields;
for t := 0 to ADataFields.Count - 1 do
if ADatafields.Item[t].FieldName <> '' then
begin
{none predefined value}
AStr := AStr + ADatafields.Item[t].FieldName + ' = ' + ADatafields.Item[t].DisplayText + #13+#10
end;
else
begin
{predefined value}
{the number of the field will be shown, not the fieldname. See the list here to convert}
AStr := AStr + IntToStr(ADatafields.Item[t].DataNo) + ' = ' + ADatafields.Item[t].DisplayText + #13+#10;
end;
ShowMessage('SymbolName: ' + APage.Symbols.Item[i].FullName + #13#10 + AStr);
end;
end;
var
MyPoint : TPCsPoint3D;
ALibtype : IPCsLibType;
ADatafield : IPCsDatafield;
ADataFields : IPCsDatafields;
ASymbol : IPCsSymbol;
i, t : integer;
APage : IPCspage;
AStr : string;
begin
{write datafield value}
{adding a symbol to the LibType}
ALibtype := PCsApplication.ActiveDocument.Drawing.LibTypes.Add('SymbolFileName.sym');
{MyPoint is the offset, from the symbols position. So this means that the
datafield will be placed 10000 up, and 10000 right, from the symbols position}
MyPoint.X := 10000;
MyPoint.Y := 10000;
MyPoint.Z := 0;
{add a datafield to the libtype}
ADatafield := ALibtype.Datafields.Add(MyPoint,'');
{process the datafield}
with ADatafield do
begin
{setting the pretext}
Pretext := 'My Pretext';
{ProjectData (none-predefined) see list here}
SetDataNo(10 {FirstProjData},PCsApplication.ActiveDocument.DataLink);
FieldName := 'Customer Name'; {to get a list of valid valued, see this code}
end;
{getting current page}
APage := PCsApplication.ActiveDocument.ActivePage;
{create a symbol, from LibType}
ASymbol := APage.Symbols.Add(ALibtype);
{setting symbolname}
ASymbol.FullName := 'MyNewSymbol';
{setting position}
ASymbol.SetPosition(100000, 100000,0);
{repaint project}
PCsApplication.Redraw;
{read a datafield value}
{get active page}
APage := PCsApplication.ActiveDocument.ActivePage;
if APage.Symbols.Count > 0 then
for i := 0 to APage.Symbols.Count - 1 do {for each symbol}
if APage.Symbols.Item[i].Datafields.Count > 0 then {symbols has datafields}
begin
AStr := '';
{get the symbols datafields}
ADataFields := APage.Symbols.Item[i].Datafields;
for t := 0 to ADataFields.Count - 1 do
if ADatafields.Item[t].FieldName <> '' then
begin
{none predefined value}
AStr := AStr + ADatafields.Item[t].FieldName + ' = ' + ADatafields.Item[t].DisplayText + #13+#10
end;
else
begin
{predefined value}
{the number of the field will be shown, not the fieldname. See the list here to convert}
AStr := AStr + IntToStr(ADatafields.Item[t].DataNo) + ' = ' + ADatafields.Item[t].DisplayText + #13+#10;
end;
ShowMessage('SymbolName: ' + APage.Symbols.Item[i].FullName + #13#10 + AStr);
end;
end;