Add a Hatch

  Examples >

Add a Hatch

Previous pageReturn to chapter overviewNext page

procedure TForm1.AddHatchClick(Sender: TObject);
var
  vDrawing: TsgCADDXFImage; //a class for reading DXF format
  vHatch: TsgCADCurvePolygon;
  vBoundaryList: Tsg2DBoundaryList;
  vPoly: Tsg2DPolyline;
begin
  // Adding hatch - a green triangle in the top of the drawing
  vDrawing := TsgCADDXFImage.Create;
  vDrawing.LoadFromFile('Entities.dxf');
  vHatch := TsgCADCurvePolygon.Create;
  vDrawing.CurrentLayout.AddEntity(vHatch);
  vHatch.SetColor(clGreen);
  vBoundaryList := vHatch.AddBoundaryList(7);
  vPoly := Tsg2DPolyline.Create;
  vBoundaryList.Add(vPoly);
  vPoly.Closed := True;
  vPoly.AddVertex(MakeF2DPoint(100, 100));
  vPoly.AddVertex(MakeF2DPoint(100, 150));
  vPoly.AddVertex(MakeF2DPoint(200, 125));
  vDrawing.Converter.Loads(vHatch);
  vDrawing.GetExtents;
  Image1.Canvas.StretchDraw(Rect(0, 0,
    Round(vDrawing.Width * Image1.Height / vDrawing.Height), Image1.Height), vDrawing);
end;

Go to CAD VCL Enterprise