Add a Line

  Examples >

Add a Line

Previous pageReturn to chapter overviewNext page

procedure TForm1.AddLineClick(Sender: TObject);
var
  vDrawing: TsgCADImage;
  vLine: TsgDXFLine;
begin
  vDrawing := TsgCADDXFImage.Create;
  vDrawing.LoadFromFile('Entities.dxf');
  // adding a vertical blue line
  vLine := TsgDXFLine.Create;
  // The point has 3 floating values: x, y, z
  vLine.Point := MakeFPoint(50, 0, 0);
  vLine.Point1 := MakeFPoint(50, 70, 10);
  vLine.LineWeight := 1; // 1 mm
  vLine.Color := clBlue;
  //adding the line to the drawing database:
  vDrawing.Converter.Loads(vLine);
  //adding the line to the current layout for display:
  vDrawing.CurrentLayout.AddEntity(vLine);
  vDrawing.GetExtents; // recalculating the extents of the drawing
  Image1.Canvas.StretchDraw(Rect(0, 0,
    Round(vDrawing.Width * Image1.Height / vDrawing.Height), Image1.Height), vDrawing);
  vDrawing.Free;
end;

Go to CAD VCL Enterprise