Code sample Home

Retrieve vertices of entity's outlines (of a circle)
void DemoExpEnt (HANDLE hLcWnd)
{
  HANDLE hBlock, hEnt;
  double X, Y, R, dX;
  int    i, nPlines, nVers, iVer;

  // get a block, linked with CAD window
  hBlock = lcPropGetHandle( hLcWnd, LC_PROP_WND_BLOCK );
  // add a circle entity
  X = 50.0;
  Y = 50.0;
  R = 10.0;
  hEnt = lcBlockAddCircle( hBlock, X,Y, R, false );
  // get vertices of the circle's polyline
  lcPropPutInt( hEnt, LC_PROP_CIRC_RESOL, 16 );
  nPlines = lcExpEntity( hEnt, -1, LC_EXP_OUTLINE, false );
  if (nPlines > 0){
    dX = (R + R) * 1.1;  // offset for new points
    for (i=0; i<nPlines; ++i){
      nVers = lcExpGetPline( 0.0 );
      for (iVer=0; iVer<nVers; ++iVer){
        lcExpGetVertex( &X, &Y );
        // add a point to indicate the vertex
        X = X + dX;
        lcBlockAddPoint2( hBlock, X, Y, LC_POINT_PIXEL|LC_POINT_CIRCLE, -0.5 );
      }
    }
  }
  // set other resolution
  lcPropPutInt( hEnt, LC_PROP_CIRC_RESOL, 32 );
  // get vertices of the circle's polyline
  nPlines = lcExpEntity( hEnt, -1, LC_EXP_OUTLINE, false );
  if (nPlines > 0){
    dX *= 2.0;  // offset for new points
    for (i=0; i<nPlines; ++i){
      nVers = lcExpGetPline( 0.0 );
      for (iVer=0; iVer<nVers; ++iVer){
        lcExpGetVertex( &X, &Y );
        // add a point to indicate the vertex
        X = X + dX;
        lcBlockAddPoint2( hBlock, X, Y, LC_POINT_PIXEL|LC_POINT_CIRCLE, -0.5 );
      }
    }
  }
  // set adaptive resolution for the circle
  lcPropPutInt( hEnt, LC_PROP_CIRC_RESOL, -1 );
  // display
  lcBlockUpdate( hBlock, true, 0 );
  lcWndExeCommand( hLcWnd, LC_CMD_ZOOM_EXT, 0 );
}
This will create a drawing as shown on the picture below:



See Also:

Retrieve vertices of entity's outlines (text)
Retrieve vertices of entity's hatch lines (barcode)