Code sample Home

Linewidth demo

void DemoLinewidth (HANDLE hLcWnd)
{
  HANDLE hDrw, hBlock, hEnt;
  double x0, x, y, y1, y2, Lw;
  double Lwidth[11] = {0.25, 0.5, 1.0, 1.5, 2.0, 2.5, 2.0, 1.5, 1.0, 0.5, 0.25};
  int    i, j;

  // get drawing and block, linked with CAD window
  hDrw = lcPropGetHandle( hLcWnd, LC_PROP_WND_DRW );
  hBlock = lcPropGetHandle( hLcWnd, LC_PROP_WND_VIEWBLOCK );
  
  // draw lines with various width
  x0 = 0.0;
  y1 = 5.0;
  y2 = -5.0;
  Lw = 0.0;
  for (i=0; i<11; ++i){
    x0 = x0 + Lw + Lw;
    Lw = Lwidth[i];
    x = x0 + (Lw / 2.0);
    hEnt = lcBlockAddLine( hBlock, x, y1, x, y2 );
    lcPropPutFloat( hEnt, LC_PROP_ENT_LWIDTH, Lw );
  }

  // draw ruler
  lcPropPutInt( hDrw, LC_PROP_DRW_COLORT, RGB(255,0,0) );
  lcPropPutInt( hDrw, LC_PROP_DRW_LWIDTH, 0 );
  lcBlockAddLine( hBlock, -1.0, 0.0, 27.0, 0.0 );
  x = -1.0;
  y1 = 0.1;
  y2 = 0.25;
  j = 0;
  for (i=0; i<=280; ++i){
    if (j == 0){
      y = y2;
      j = 10;
    }else{
      y = y1;
    }
    --j;
    lcBlockAddLine( hBlock, x, -y, x, y );
    x += 0.1;
  }

  // Set real linewidth mode
  lcPropPutInt( hDrw, LC_PROP_DRW_LWMODE, LC_LW_REAL );
  // update view
  lcBlockUpdate( hBlock, LC_TRUE, 0 );
  // zoom extents
  lcWndZoomRect( hLcWnd, 0, 0, 0, 0 );
}
This will create a drawing as shown on the picture below: