Code sample Home

Retrieve vertices of entity's hatch lines (barcode)
void DemoBarcHatchAndGetLines (HANDLE hLcWnd)
{
  HANDLE hDrw, hBlock, hFill, hEnt, hEntPline;
  WCHAR* szNameFill = L"Hatch 1";
  WCHAR* szBcText = L"123";
  double X, Y, X2, Y2, W, OffsetX, OffsetY;
  int    nPlines, nVers, i, j, Step;

  // get drawing and block, linked with CAD window
  hDrw = lcPropGetHandle( hLcWnd, LC_PROP_WND_DRW );
  hBlock = lcPropGetHandle( hLcWnd, LC_PROP_WND_VIEWBLOCK );

  // check if the filling style with specific name already exist
  hFill = lcDrwGetObjectByName( hDrw, LC_OBJ_LINFILL, szNameFill );
  if (hFill == 0){
    // don't exist, add it
    hFill = lcDrwAddFilling( hDrw, szNameFill );
    lcFillSetLine( hFill, 0, 0.05, 45.0*LC_DEG_TO_RAD, 0.02 );
  }

  // disable solid barcodes
  lcPropPutBool( hDrw, LC_PROP_DRW_BARCSOLID, false );
  // set active color for barcode
  lcPropPutStr( hDrw, LC_PROP_DRW_COLOR, L"ByLayer" );

  // Create QR-code filled with lines
  X = 10;  // center of QR-code
  Y = 10;
  W = 8;   // width and height of QR-code
  hEnt = lcBlockAddBarcode( hBlock, LC_BARTYPE_QR, X, Y, W, 0, szBcText );
  lcPropPutInt( hEnt, LC_PROP_BARC_ECLEVEL, LC_BARC_QRECL_M );
  lcPropPutFloat( hEnt, LC_PROP_BARC_OFFSET, 0.025 );
  lcPropPutHandle( hEnt, LC_PROP_ENT_LINFILL, hFill );
  lcEntUpdate( hEnt );

  // set active color for new entities
  lcPropPutStr( hDrw, LC_PROP_DRW_COLOR, L"255,0,0" );

  // extract barcode outlines and hatch lines
  OffsetX = 8.5;
  OffsetY = 0.0;
  for (Step=0; Step<2; ++Step){
    if (Step == 0){
      // hatch lines
      nPlines = lcExpEntity( hEnt, -1, LC_EXP_HATCH, false );
      for (i=0; i<nPlines; ++i){
        nVers = lcExpGetPline( 0.0 );
        if (nVers == 2){
          lcExpGetVertex( &X, &Y );
          X = X + OffsetX;
          Y = Y + OffsetY;
          lcExpGetVertex( &X2, &Y2 );
          X2 = X2 + OffsetX;
          Y2 = Y2 + OffsetY;
          lcBlockAddLine( hBlock, X, Y, X2, Y2 );
        }
      }
    }else{
      // outlines
      OffsetY = -OffsetX;
      OffsetX = 0;
      nPlines = lcExpEntity( hEnt, -1, LC_EXP_OUTLINE, false );
      for (i=0; i<nPlines; ++i){
        hEntPline = lcBlockAddPolyline( hBlock, 0, false, false );
        nVers = lcExpGetPline( 0.0 );
        for (j=0; j<nVers; ++j){
          lcExpGetVertex( &X, &Y );
          X = X + OffsetX;
          Y = Y + OffsetY;
          lcPlineAddVer( hEntPline, 0, X, Y );
        }
        lcPlineEnd( hEntPline );
      }
    }
  }

  // update block
  lcBlockUpdate( hBlock, true, 0 );
  // zoom extents
  lcWndZoomRect( hLcWnd, 0,0,0,0 );  
}
This will create a drawing as shown on the picture below:



Zoom on central part:




See Also:

Retrieve vertices of entity's outlines (circle)
Retrieve vertices of entity's outlines (text)
Retrieve outlines of hatch entity