Code sample Home

Create a text entity filled with lines
//-----------------------------------------------
void DemoFilledText (HANDLE hLcWnd)
{
  HANDLE hDrw, hBlock, hEnt, hFill, hTStyle;
  WCHAR* szNameFill = L"Hatch 1";
  WCHAR* szNameStyle = L"Style 1";
  double X, Y, H, Gap;

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

  // check if the text style with specific name already exist
  hTStyle = lcDrwGetObjectByName( hDrw, LC_OBJ_TEXTSTYLE, szNameStyle );
  if (hTStyle == 0){
    // don't exist, add it
    hTStyle = lcDrwAddTextStyle( hDrw, szNameStyle, L"Arial", true );
    if (hTStyle != 0){
      // disable solid fill
      lcPropPutBool( hTStyle, LC_PROP_TSTYLE_SOLID, false );
      // make this style active
      lcPropPutHandle( hDrw, LC_PROP_DRW_TEXTSTYLE, hTStyle );
    }
  }
  
  // check if the filling style with specific name already exist
  hFill = lcDrwGetObjectByName( hDrw, LC_OBJ_LINFILL, szNameFill );
  if (hFill == 0){
    // don't exist, add it
    hFill = lcDrwAddFilling( hDrw, szNameFill );
    // define lines
    Gap = 0.03;
    lcFillSetLine( hFill, 0, 0.25, 45.0*LC_DEG_TO_RAD, Gap );
    lcFillSetLine( hFill, 1, 0.25, -45.0*LC_DEG_TO_RAD, Gap );
  }

  X = 10.0;
  Y = 20.0;
  H = 5.0;
  hEnt = lcBlockAddText2( hBlock, L"ABC", X, Y, LC_TA_LEFBOT, H, 1.0, 0.0, 0.0 );
  if (hEnt != 0){
    // set filling by lines
    lcPropPutHandle( hEnt, LC_PROP_ENT_LINFILL, hFill );
  }
  
  // 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:



See Also:

  Create polygons filled with lines
  Create a shape filled with lines