uses DPSCAD_TLB;
var
aLibType : IPCsLibType;
aBitmap : TBitmap;
filename : string;
Results: OleVariant;
begin
aLibType := PCsApplication.ActiveDocument.ActivePage.Symbols[0].Libtype;
filename := 'C:\PCSELCAD\SYMBOL\60617_2015\05-03-08.SYM';
if (aLibType as IPCsBase).CustomCommand('GetAsBitmap', VarArrayOf([fileName, 64, false, false]), Results) then // * 4 parametre
begin;
aBitMap := VariantToBitmap(Results);
aBitMap.SaveToFile('C:\Users\MyUser\Desktop\SymbolPic.bmp');
aBitMap.Free;
end;
end;
// Parameters:
// 1. parm (STRING) : The full filename of the symbol
// 2. parm (INTEGER) : The height and width of the bitmap
// 3. parm (BOOLEAN) : Show connections/pinnames
// 4. parm (BOOLEAN) : Show Ref-point
Helper function needed to convert VariantToBitmap:
function VariantToBitmap(const v : olevariant) : TBitmap;
var
p : pointer;
MemStream : TMemoryStream;
begin
MemStream := TMemoryStream.Create;
result := TBitMap.Create;
MemStream.Position := 0;
MemStream.Size := VarArrayHighBound (v, 1) - VarArrayLowBound(v, 1) + 1;
p := VarArrayLock (v);
MemStream.Write (p^, MemStream.Size);
VarArrayUnlock (v);
MemStream.Position := 0;
result.LoadfromStream(MemStream);
MemStream.Free;
end;
var
aLibType : IPCsLibType;
aBitmap : TBitmap;
filename : string;
Results: OleVariant;
begin
aLibType := PCsApplication.ActiveDocument.ActivePage.Symbols[0].Libtype;
filename := 'C:\PCSELCAD\SYMBOL\60617_2015\05-03-08.SYM';
if (aLibType as IPCsBase).CustomCommand('GetAsBitmap', VarArrayOf([fileName, 64, false, false]), Results) then // * 4 parametre
begin;
aBitMap := VariantToBitmap(Results);
aBitMap.SaveToFile('C:\Users\MyUser\Desktop\SymbolPic.bmp');
aBitMap.Free;
end;
end;
// Parameters:
// 1. parm (STRING) : The full filename of the symbol
// 2. parm (INTEGER) : The height and width of the bitmap
// 3. parm (BOOLEAN) : Show connections/pinnames
// 4. parm (BOOLEAN) : Show Ref-point
Helper function needed to convert VariantToBitmap:
function VariantToBitmap(const v : olevariant) : TBitmap;
var
p : pointer;
MemStream : TMemoryStream;
begin
MemStream := TMemoryStream.Create;
result := TBitMap.Create;
MemStream.Position := 0;
MemStream.Size := VarArrayHighBound (v, 1) - VarArrayLowBound(v, 1) + 1;
p := VarArrayLock (v);
MemStream.Write (p^, MemStream.Size);
VarArrayUnlock (v);
MemStream.Position := 0;
result.LoadfromStream(MemStream);
MemStream.Free;
end;