Read texts

  Getting Started >

Read texts

Previous pageReturn to chapter overviewNext page

uses DXF, DXFConv,

 

...

 

type

  TForm1 = class(TForm)

    Image1: TImage;

 

...

 

implementation

 

procedure TForm1.ReadTextsClick(Sender: TObject);
var
  vDrawing: TsgCADDXFImage; // a class for reading DXF format
  I, J: Integer;
  // "DXF" in the name of the Line class is used for compatibility
  // use this class for lines in all CAD formats
  vText: TsgDXFText;
  vMText: TsgDXFMText;
  S: string;
begin
  vDrawing := TsgCADDXFImage.Create; //TsgDXFImage is a class for DXF file reading

                                     //Please use a correspond class to read a drawing of other format.

                                     //For example TsgDWGImage for DWG format, TsgCGMImage for CGM, etc.
  vDrawing.LoadFromFile('Entities.dxf');
  Image1.Picture.Graphic := nil;
  Image1.Canvas.StretchDraw(Rect(0, 0,
    Round(vDrawing.Width * Image1.Height / vDrawing.Height), Image1.Height), vDrawing);
// searching entities in the current layout of the drawing
  for I := 0 to vDrawing.CurrentLayout.Count - 1 do
  begin
    if vDrawing.CurrentLayout.Entities[I] is TsgDXFText then
    begin
      vText := TsgDXFText(vDrawing.CurrentLayout.Entities[I]);
      ShowMessage('Text: ' + #13 + vText.Text);
    end;
    if vDrawing.CurrentLayout.Entities[I]is TsgDXFMText then
    begin
      vMText := TsgDXFMText(vDrawing.CurrentLayout.Entities[I]);
      for J := 0 to vMText.Block.Count - 1 do
        S := S + TsgDXFText(vMText.Block.Entities[J]).Text + #13;
      ShowMessage('MText: ' + #13 + S);
    end;
  end;
  vDrawing.Free;
end;

Go to CAD VCL Enterprise