Code sample Home

Create new block from selected entities of current block
void DemoSelToBlock (HANDLE hLcWnd)
  HANDLE hBlock;
  int    nSelEnts;
  double X, Y;
  BOOL   bOverwrite = true;   
  WCHAR* szName = L"New Block";

  // get a block, linked with CAD window
  hBlock = lcPropGetHandle( hLcWnd, LC_PROP_WND_BLOCK );
  // get a number of selected objects in the block
  nSelEnts = lcPropGetInt( hBlock, LC_PROP_BLOCK_NSELENTS );
  if (nSelEnts > 0){
    // get center point of selected entities
    X = lcPropGetFloat( hBlock, LC_PROP_BLOCK_SELXCEN );
    Y = lcPropGetFloat( hBlock, LC_PROP_BLOCK_SELYCEN );
    // create new block and insert it into the current block (hBlock)
    lcBlockSelBlock( hBlock, szName, X, Y, LC_BLK_ENT_CONVERT, bOverwrite );
    lcWndRedraw( hLcWnd );
See Also:

Create a block and insert it into a drawing
Create new block from all entities of "Model Space" block