Code sample Home

Retrieve positions on a polyline by given distance from beginning.
void DemoPlineDist (HANDLE hLcWnd)
  HANDLE hBlock, hEnt, hLine;
  int EntType, 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 type
    EntType = lcPropGetInt( hEnt, LC_PROP_ENT_TYPE );
    if (EntType == LC_ENT_POLYLINE){
      // get polyline length
      Len = lcPropGetFloat( hEnt, LC_PROP_PLINE_LEN );
      Delta = Len / nParts;
      Dist = Delta;
      // add tick lines at division points
      for (i=1; i<nParts; ++i){
        if (lcPlineGetPoint( 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 a polyline by mouse click.