The following example demonstrates how to count all text entities in the drawing. Requires the "DXF" and the "DXFConv" units added to the "uses" section.
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