Code sample Home

Create hatch
void DemoHatch (HANDLE hLcWnd)
{
  HANDLE hBlock, hEnt;
  bool   bSolid = false;  // if TRUE then solid fill
  int    Method = 0;      // method of creating a hatch entity
  double Scale = 8.0;     // scale of hatch pattern
  double Angle = 45 * LC_DEG_TO_RAD;  // rotation of hatch pattern

  // get a block, linked with CAD window
  hBlock = lcPropGetHandle( hLcWnd, LC_PROP_WND_BLOCK );
  // clear selection set
  lcBlockUnselect( hBlock );
  // create entities and add them into selection
  hEnt = lcBlockAddCircle( hBlock, 10, 10, 5, false );
  lcBlockSelectEnt( hBlock, hEnt, true );
  hEnt = lcBlockAddCircle( hBlock, 30, 10, 5, false );
  lcBlockSelectEnt( hBlock, hEnt, true );
  hEnt = lcBlockAddRect2( hBlock, 0, 0, 40, 20, 5, false );
  lcBlockSelectEnt( hBlock, hEnt, true );
  // create Hatch entity using selected entities as an outline
  if (bSolid){
    hEnt = lcBlockAddHatch( hBlock, L"", L"", 0.0, 0.0 );
    // set filling color
    lcPropPutStr( hEnt, LC_PROP_ENT_FCOLOR, L"0,255,255" );
  }else{
    if (Method == 0){
      // hatch pattern is defined in *.pat file
      lcBlockAddHatch( hBlock, L"hatches.pat", L"ANGLE", Scale, Angle );
    }else{
      // hatch pattern is defined by text string
      lcBlockAddHatch( hBlock, L"", L"0, 0,0, 0,.275, .2,-.075\n90, 0,0, 0,.275, .2,-.075", Scale, Angle );
    }
  }	
  // clear selection set and update block extents
  lcBlockUnselect( hBlock );
  lcBlockUpdate( hBlock, false, 0 );
  // zoom view
  lcWndZoomRect( hLcWnd, -10, -10, 50, 30 );
}
This will create a drawing as shown on the picture below:



See Also:

Create a hatch 2
Create shape entity
Create shape entity with hatch filling