Code sample Home

Retrieve vertices of entity's outlines (of a text)
void DemoExpEnt2 (HANDLE hLcWnd)
{
  HANDLE hDrw, hBlock, hTStyle, hEnt;
  double X, Y, H;
  int    i, nPlines, nVers, iVer;
  WCHAR* szText = L&ABC&;
  WCHAR* szFont = L&Arial&;
  WCHAR  szBuf[128];

  // get drawing and block, linked with CAD window
  hDrw = lcPropGetHandle( hLcWnd, LC_PROP_WND_DRW );
  hBlock = lcPropGetHandle( hLcWnd, LC_PROP_WND_BLOCK );

  // get active text style
  hTStyle = lcPropGetHandle( hDrw, LC_PROP_DRW_TEXTSTYLE );
  // get font of the text style
  wcscpy( szBuf, lcPropGetStr( hTStyle, LC_PROP_TSTYLE_FONT ));
  if (wcscmp( szBuf, szFont ) != 0){
    // set specified font for the text style
    lcPropPutStr( hTStyle, LC_PROP_TSTYLE_FONT, szFont );
    lcPropPutBool( hTStyle, LC_PROP_TSTYLE_SOLID, true );
  }

  // add a text entity
  X = 10.0;
  Y = 10.0;
  H = 10.0;
  hEnt = lcBlockAddText2( hBlock, szText, X,Y, LC_TA_LEFBOT, H, 1.0, 0.0, 0.0 );
  lcPropPutInt( hEnt, LC_PROP_ENT_COLOR, RGB(150,255,255) );
  lcPropPutInt( hEnt, LC_PROP_TEXT_RESOL, 3 );
  // set colors for new entities (points)
  lcPropPutInt( hDrw, LC_PROP_DRW_COLORT, RGB(255,0,0) );
  lcPropPutInt( hDrw, LC_PROP_DRW_FCOLORT, RGB(255,0,0) );
  // get vertices of the text's polylines
  nPlines = lcExpEntity( hEnt, LC_EXP_OUTLINE, false );
  if (nPlines > 0){
    for (i=0; i<nPlines; ++i){
      nVers = lcExpGetPline( 0.0 );
      for (iVer=0; iVer<nVers; ++iVer){
        lcExpGetVertex( &X, &Y );
        // add a point to indicate the vertex
        lcBlockAddPoint2( hBlock, X, Y, LC_POINT_CIRCLE|LC_POINT_FILLED, -0.5 );
      }
    }
  }
  // display
  lcBlockUpdate( hBlock, true, 0 );
  lcWndExeCommand( hLcWnd, LC_CMD_ZOOM_EXT, 0 );
}
This will create a drawing as shown on the picture below:



Used functions:

lcExpEntity
lcExpGetPline
lcExpGetVertex

lcBlockAddText2
lcBlockAddPoint2
lcBlockUpdate
lcWndExeCommand

lcPropGetHandle
lcPropGetStr
lcPropPutInt
lcPropPutStr
lcPropPutBool