Code sample Home

Create hatch
void DemoHatch2 (HANDLE hLcWnd)
{
  HANDLE hBlock, hHatch, hEnt;
  bool   bSolid = false;  // if TRUE then solid fill
  int    Method = 1;      // method of creating a hatch entity
  double Scale = 5.0;     // scale of hatch pattern
  double Angle = 30.0 * LC_DEG_TO_RAD;  // rotation of hatch pattern
  WCHAR* szPattern;

  // get a block, linked with CAD window
  hBlock = lcPropGetHandle( hLcWnd, LC_PROP_WND_BLOCK );
  // create Hatch entity using selected entities as an outline
  if (bSolid){
    hHatch = lcBlockAddHatch( hBlock, L"", L"", 0.0, 0.0 );
    // set filling color
    lcPropPutStr( hHatch, LC_PROP_ENT_FCOLOR, L"0,255,255" );
  }else{
    Scale = 5.0;
    Angle = 30.0 * LC_DEG_TO_RAD;
    if (Method == 0){
      // hatch pattern is defined in *.pat file
      szPattern = L"ANGLE";
      hHatch = lcBlockAddHatch( hBlock, L"hatches.pat", szPattern, Scale, Angle );
    }else{
      // hatch pattern is defined by text string
      szPattern = L"0, 0,0, 0,.275, .2,-.075\n90, 0,0, 0,.275, .2,-.075";
      hHatch = lcBlockAddHatch( hBlock, L"", szPattern, Scale, Angle );
    }
  }

  // the hatch entity has not boundaries, so we have to add it
  lcHatchBoundStart( hHatch );
  // create outer boundary from lines and arcs
  hEnt = lcBlockAddLine( hBlock, 0, 0, 15, 0 );
  lcHatchBoundEntity( hHatch, hEnt );
  hEnt = lcBlockAddArc( hBlock, 15, 5, 5, 270*LC_DEG_TO_RAD, 180*LC_DEG_TO_RAD );
  lcHatchBoundEntity( hHatch, hEnt );
  hEnt = lcBlockAddLine( hBlock, 15, 10, 0, 10 );
  lcHatchBoundEntity( hHatch, hEnt );
  hEnt = lcBlockAddArc( hBlock, 0, 5, 5, 90*LC_DEG_TO_RAD, 180*LC_DEG_TO_RAD );
  lcHatchBoundEntity( hHatch, hEnt );
  lcHatchBoundEndLoop( hHatch ); 
  // add inner boundaries
  hEnt = lcBlockAddCircle( hBlock, 0, 5, 2.0, false );
  lcHatchBoundEntity( hHatch, hEnt );
  hEnt = lcBlockAddRect( hBlock, 12,5, 6, 3, 0, false );
  lcHatchBoundEntity( hHatch, hEnt );
  // finish boundaries definition
  lcHatchBoundEnd( hHatch );

  lcBlockUpdate( hBlock, true, 0 );
  // zoom view
  lcWndZoomRect( hLcWnd, -15, -10, 30, 20 );
}
This will create a drawing as shown on the picture below:



See Also:

Create a hatch 1
Create shape entity
Create shape entity with hatch filling