Code sample Home

Retrieve positions on a polyline by given distance from beginning.
void DemoEntDist (HANDLE hLcWnd)
{
  HANDLE hBlock, hEnt, hLine;
  int    nParts, i;
  double Len, Delta, Dist, X, Y, Angle, TickLen;
  double X1, Y1, X2, Y2;

  nParts = 10;
  TickLen = 0.5;
  // get a block, linked with CAD window
  hBlock = lcPropGetHandle( hLcWnd, LC_PROP_WND_BLOCK );
  // get selected entity
  hEnt = lcBlockGetFirstSel( hBlock );
  if (hEnt){
    // get entity length
    Len = lcPropGetFloat( hEnt, LC_PROP_ENT_LEN );
    if (Len > 0.0){
      Delta = Len / nParts;
      Dist = 0.0; 
      // add tick lines at division points
      for (i=0; i<=nParts; ++i){
        if (lcEntGetPoint( hEnt, Dist, &X, &Y, &Angle )){
          lcGetPolarPoint( X, Y, Angle+LC_DEG90, TickLen, &X1, &Y1 );
          lcGetPolarPoint( X, Y, Angle-LC_DEG90, TickLen, &X2, &Y2 );
          hLine = lcBlockAddLine( hBlock, X1, Y1, X2, Y2 );
          lcPropPutInt( hLine, LC_PROP_ENT_COLOR, RGB(255,255,0) );
          Dist += Delta;
        }
      }
      lcBlockUpdate( hBlock, true, 0 );
      lcWndRedraw( hLcWnd ); 
    }
  }
}
The result will be like on the picture below:



See Also:

Retrieve position on entity by mouse click.