Calculate Texts

  Examples >

Calculate Texts

Previous pageReturn to chapter overviewNext page

procedure TForm1.CalculateTextsClick(Sender: TObject);
var
  vDrawing: TsgCADImage;
  I, vCount: Integer;
  vPicture: TPicture;
begin
  vPicture := TPicture.Create;
  if OpenPictureDialog1.Execute then
    vPicture.LoadFromFile(OpenPictureDialog1.FileName)
  else
    Exit;
  if not (vPicture.Graphic is TsgCADImage) then // check that this is a CAD drawing
    Exit;
  vDrawing := TsgCADImage(vPicture.Graphic);
  vCount := 0;
  for I := 0 to vDrawing.Converter.Counts[csEntities] - 1 do
    if vDrawing.Entities[I] is TsgDXFText then
      Inc(vCount);
  ShowMessage(Format('There are %d text entities in the drawing', [vCount]));
  Image1.Canvas.StretchDraw(Rect(0, 0,
    Round(vDrawing.Width * Image1.Height / vDrawing.Height), Image1.Height), vDrawing);
  vDrawing.Free;
end;

Go to CAD VCL Enterprise