Skip to main content

Read line data procedure

uses DXF, DXFConv, sgConsts;

...

implementation

procedure TForm1.ReadLineDataClick(Sender: TObject);
var
vDrawing: TsgCADDXFImage; // reading class for DXF format

I: Integer;
// "DXF" in the name of Line class is for compatibility
// use this class for lines in all CAD formats
vLine: TsgDXFLine;
begin
//TsgDXFImage - 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 := TsgCADDXFImage.Create;
vDrawing.LoadFromFile('Entities.dxf');
// searching entities on the current layout of the drawing
for I := 0 to vDrawing.CurrentLayout.Count - 1 do
begin
if vDrawing.CurrentLayout.Entities[I].EntType = ceLine then
begin
vLine := TsgDXFLine(vDrawing.CurrentLayout.Entities[I]);
ShowMessage('Line is found. Handle = ' + IntToStr(vLine.Handle) +
'; X: ' + FloatToStr(vLine.Point.X) + '; Y: ' + FloatToStr(vLine.Point.Y) +
'; X1: ' + FloatToStr(vLine.Point1.X) + '; Y1: ' + FloatToStr(vLine.Point1.Y));
break;
end;
end;
vDrawing.Free;
end;