Code sample Home

Create arc texts

void DemoArcText (HANDLE hLcWnd)
{
  WCHAR* szStyleName = L"New Style";
  WCHAR* szText = L"THIS IS THE ARC TEXT";
  double X[3], Y, R, H, Gap, Angle;
  int    i, k, Align[3];
  HANDLE hDrw, hBlock, hTStyle;
  bool   bClockwise = true;

  // get drawing and block, linked with CAD window
  hDrw = lcPropGetHandle( hLcWnd, LC_PROP_WND_DRW );
  hBlock = lcPropGetHandle( hLcWnd, LC_PROP_WND_BLOCK );
  // get text style with specified name
  hTStyle = lcDrwGetObjectByName( hDrw, LC_OBJ_TEXTSTYLE, szStyleName );
  if (hTStyle == NULL){
    // the style don't exist, create new text style
    hTStyle = lcDrwAddTextStyle( hDrw, szStyleName, L"Times New Roman", true );
  }
  // set current text style
  lcPropPutHandle( hDrw, LC_PROP_DRW_TEXTSTYLE, hTStyle );
  // add graphics
  R = 10.0;
  X[0] = 0;
  X[1] = R * 3.0;
  X[2] = R * 6.0;
  Y = 0.0;
  H = R / 5.0;
  Gap = H / 4.0;
  Angle = 90.0 * LC_DEG_TO_RAD;
  Align[0] = LC_ATA_LEFT;
  Align[1] = LC_ATA_CENTER;
  Align[2] = LC_ATA_RIGHT;
  for (k=0; k<2; ++k){
    for (i=0; i<3; ++i){
      lcBlockAddCircle( hBlock, X[i], Y, R, false );
      lcBlockAddLine( hBlock, X[i], Y, X[i], Y+R );
      lcBlockAddArcText( hBlock, szText, X[i], Y, R+Gap, Angle, bClockwise, H, 1.0, Align[i] );
    }
    bClockwise = !bClockwise;
    Y -= R * 3.0;
  }
  // update view
  lcBlockUpdate( hBlock, true, 0 );
  lcWndExeCommand( hLcWnd, LC_CMD_ZOOM_EXT, 0 );
}
This will create a drawing as shown on the picture below:




Used functions:

lcDrwGetObjectByName
lcDrwAddTextStyle
lcBlockAddCircle
lcBlockAddLine
lcBlockAddArcText
lcBlockUpdate
lcWndExeCommand
lcPropGetHandle
lcPropPutHandle