Code sample Home

Create simple entities

void DemoEntities (HANDLE hLcWnd)
{
  HANDLE hDrw, hBlock;
  double x, y, x2, y2, w, h, ang, ang0, ang2, rad, rad2;

  // get drawing and block, linked with CAD window
  hDrw = lcPropGetHandle( hLcWnd, LC_PROP_WND_DRW );
  hBlock = lcPropGetHandle( hLcWnd, LC_PROP_WND_VIEWBLOCK );
  
  // set active color
  lcPropPutInt( hDrw, LC_PROP_DRW_COLOR, RGB(255,0,0) );

  // add points
  x = 0.0;
  y = 0.0;
  lcBlockAddPoint( hBlock, x, y );
  lcBlockAddPoint( hBlock, x, y+5.0 );
  lcBlockAddPoint( hBlock, x, y+10.0 );

  // add lines
  lcPropPutInt( hDrw, LC_PROP_DRW_COLOR, RGB(0,255,0) );
  x = x + 3.0;
  x2 = x + 10.0;
  y2 = y + 2.0;
  lcBlockAddLine( hBlock, x, y, x2, y2 );
  lcBlockAddLine( hBlock, x, y+5.0, x2, y2+5.0 );
  lcBlockAddLine( hBlock, x, y+10.0, x2, y2+10.0 );

  // add rectangles
  lcPropPutInt( hDrw, LC_PROP_DRW_COLOR, RGB(0,0,255) );
  x = x2 + 7.0;
  y = 0;
  w = 10.0;
  h = 5.0;
  ang = 0.0;
  lcBlockAddRect( hBlock, x, y, w, h, ang, false );
  lcBlockAddRect2( hBlock, x, y, w, h, 1.0, false );
  ang = 30.0 * LC_DEG_TO_RAD;
  lcBlockAddRect( hBlock, x, y+10, w, h, ang, false );

  // add circles
  lcPropPutInt( hDrw, LC_PROP_DRW_COLOR, RGB(255,0,255) );
  rad = 2.0;
  x = x + w + rad;
  y = 10.0;
  lcBlockAddCircle( hBlock, x, y, rad, false );
  lcBlockAddCircle( hBlock, x, y, rad+1.0, false );
  lcBlockAddCircle( hBlock, x, y, rad+2.0, false );

  // add arcs
  lcPropPutInt( hDrw, LC_PROP_DRW_COLOR, RGB(255,255,0) );
  ang0 = 30.0 * LC_DEG_TO_RAD;
  ang = 90.0 * LC_DEG_TO_RAD;
  lcBlockAddArc( hBlock, x, y, rad+3, ang0, ang );
  lcBlockAddArc( hBlock, x, y, rad+4, ang0, -ang );

  // add ellipse
  lcPropPutInt( hDrw, LC_PROP_DRW_COLOR, RGB(0,255,255) );
  x = x + 5.0;
  y = 0.0;
  ang = 0.0;
  rad = 4.0;
  rad2 = rad * 0.5;
  lcBlockAddEllipse( hBlock, x, y, rad, rad2, ang, 0.0, 0.0 );
  ang = 45.0 * LC_DEG_TO_RAD; 
  x = x + 7.0;
  y = y + 7.0;
  lcBlockAddEllipse( hBlock, x, y, rad, rad2, ang, 0.0, 0.0 );

  // add elliptical arcs
  lcPropPutInt( hDrw, LC_PROP_DRW_COLOR, RGB(100,55,200) );
  ang0 = 30.0 * LC_DEG_TO_RAD;
  ang2 = 180.0 * LC_DEG_TO_RAD;
  rad = rad + 1.0;
  lcBlockAddEllipse( hBlock, x, y, rad, rad*0.5, ang, ang0, ang2 );
  rad = rad + 1.0;
  lcBlockAddEllipse( hBlock, x, y, rad, rad*0.5, ang, ang0, -ang2 );

  // 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:

Create polylines