Code sample Home

Align entities
void DemoEntAlign (HANDLE hLcWnd)
{
  HANDLE hBlock, hEnt;
  int    Align, EntType;
  double X, Y;

  // get a block, linked with CAD window
  hBlock = lcPropGetHandle( hLcWnd, LC_PROP_WND_VIEWBLOCK );

  X = 50.0;
  Y = 30.0;
  Align = LC_EA_TOP;
//  Align = LC_EA_RIGHT;
//  Align = LC_EA_CENTER;
  hEnt = lcBlockGetFirstEnt( hBlock );
  while( hEnt ){
    EntType = lcPropGetInt( hEnt, LC_PROP_ENT_TYPE );
    if (EntType == LC_ENT_CIRCLE){
      lcEntAlign( hEnt, Align, X, Y );
    }
    hEnt = lcBlockGetNextEnt( hBlock, hEnt );
  }
  lcBlockUpdate( hBlock, true, 0 );
  lcWndRedraw( hLcWnd ); 
}
This code will change a drawing as shown on the pictures below:

Original drawing ("EntAlign.lcd")



After executing the code with Align = LC_EA_TOP;



After executing the code with Align = LC_EA_RIGHT;



After executing the code with Align = LC_EA_CENTER;