LiteCAD API reference

一、Command Interface

Almost all functionality can be accessed via the lcWndExeCommand function. In contrast to programmatically managing entities, the command interface permits interactive editing, using the mousepointer and keyboard. These interactive commands can be assigned directly to an application’s menus, buttons and accelerator keys.
所有的命令接口

二、Named objects

LiteCAD drawing object contains both graphical and nongraphical objects. You use graphical objects, such as lines, arcs, and circles, to create your designs. At the same time, you use nongraphical information,referred to herein as named objects, to manage the design. Loosely speaking, named objects are graphical object specifications. Named objects include such items as text styles, dimension styles, layers, linetypes and so on.Named objects help you design more efficiently. For example, if you use a set of linetype properties frequently, you can save the properties as a named linetype and then apply the linetype to lines in your future drawings.
LiteCAD stores named objects by type, in different tables. LiteCAD’s API provides functions to add, delete and change properties of the named objects. You can view and revise all named objects using LiteCAD’s dialog boxes.
The following table enumerates LiteCAD’s named objects.

Type of named object
This are types of Named objects. The value is returned by LC_PROP_TABLE_TYPE property.

1.Block:Contains the block name, base point, and component objects.

1.A block is a collection of one or more LiteCAD entities combined to create a single object. The Block reference entity uses Block data to display itself.
There are 3 types of blocks:

  • Model Space
  • Paper Space
  • Usual block
    “Model Space” block is a root block for a drawing. “Paper Space” block represents printing layout and contents an image of paper sheet. “Model Space” can be only one, and created automatically when you create a drawing. It is the first block in the blocks list, therefore you can access it by calling hModelSpace = lcDrwGetFirstObject( hDrw, LC_OBJ_BLOCK );
    Usual blocks are created with the lcDrwAddBlock… functions and you can insert them into Model\Paper Space blocks as a block reference.

    The functions used to manage blocks in a drawing.

Code samples
Add many blocks from one external file:lcDrwAddBlockFromDrw

void DemoLoadBlocks (HANDLE hLcWnd)
{HANDLE hDrw, hBlock, hExtDrw, hBlkRef;WCHAR* szFileName = L"d:/drawings/edit26a.dxf";WCHAR* szBlockName[5] = {L"Aura", L"IMP", L"LED-Par", L"MAC700-P", L"TP_SEL"};HANDLE hNewBlock[5];BOOL   bLoad;int    i;double X, Y, Scale, Angle;// get drawing and block, linked with CAD windowhDrw = lcPropGetHandle( hLcWnd, LC_PROP_WND_DRW );hBlock = lcPropGetHandle( hLcWnd, LC_PROP_WND_BLOCK );// load blocks from external file (szFileName)hExtDrw = lcCreateDrawing();bLoad = lcDrwLoad( hExtDrw, szFileName, 0 );if (bLoad == TRUE){for (i=0; i<5; ++i){hNewBlock[i] = lcDrwAddBlockFromDrw( hDrw, szBlockName[i], hExtDrw, LC_BLOCK_OVERWRITEYES, 0 );}}lcDeleteDrawing( hExtDrw );// insert loaded blocksX = 0.0;Y = 0.0;Scale = 1.0;Angle = 0.0;for (i=0; i<5; ++i){hBlkRef = lcBlockAddBlockRef( hBlock, hNewBlock[i], X, Y, Scale, Angle );X = X + 500.0;}// update and displaylcBlockUpdate( hBlock, true, 0 );lcWndExeCommand( hLcWnd, LC_CMD_ZOOM_EXT, 0 );
}

Add new blocks from files, insert the blocks into a drawing and save result drawing into a file:lcDrwAddBlockFile

void DemoBlockFromFile (HANDLE hLcWnd)
{HANDLE hDrw, hBlock, hBlock1, hBlock2, hBlock3, hBlock4;WCHAR* szFile00 = L"d:/_tmp/drawing.dxf";WCHAR* szFile1 = L"d:/_tmp/block1.dxf";WCHAR* szFile2 = L"d:/_tmp/block2.dxf";WCHAR* szFile3 = L"d:/_tmp/block3.dxf";WCHAR* szFile4 = L"d:/_tmp/block4.dxf";WCHAR* szOutFile = L"d:/_tmp/Result.dxf";double X, Y, Scale, Angle;// get the drawing object linked with CAD windowhDrw = lcPropGetHandle( hLcWnd, LC_PROP_WND_DRW );// load a filelcDrwLoad( hDrw, szFile00, 0 );// get Model blockhBlock = lcPropGetHandle( hDrw, LC_PROP_DRW_BLOCK_MODEL );// link the Model block with CAD windowlcWndSetBlock( hLcWnd, hBlock );// create new block from file "block1.dxf"hBlock1 = lcDrwAddBlockFile( hDrw, L"Block1", szFile1, LC_BLOCK_OVERWRITEYES, 0 );// create new block from file "block2.dxf"hBlock2 = lcDrwAddBlockFile( hDrw, L"Block2", szFile2, LC_BLOCK_OVERWRITEYES, 0 );// create new block from file "block2.dxf"hBlock3 = lcDrwAddBlockFile( hDrw, L"Block3", szFile3, LC_BLOCK_OVERWRITEYES, 0 );// create new block from file "block2.dxf"hBlock4 = lcDrwAddBlockFile( hDrw, L"Block4", szFile4, LC_BLOCK_OVERWRITEYES, 0 );if (hBlock1 && hBlock2 && hBlock3 && hBlock4){// insert hBlock1X = Y = 0.0;Scale = 1.0;Angle = 0.0;lcBlockAddBlockRef( hBlock, hBlock1, X,Y, Scale, Angle );// insert hBlock2X = 160.0;Y = -120.0;Scale = 0.5;lcBlockAddBlockRef( hBlock, hBlock2, X,Y, Scale, Angle );// insert hBlock3X = 30.0;Y = 150.0;Scale = 1.0;lcBlockAddBlockRef( hBlock, hBlock3, X,Y, Scale, Angle );// insert hBlock4X = 30.0;Y = -120.0;lcBlockAddBlockRef( hBlock, hBlock4, X,Y, Scale, Angle );// save the drawing in a filelcDrwSave( hDrw, szOutFile, true, 0 );// update and displaylcBlockUpdate( hBlock, true, 0 );lcWndExeCommand( hLcWnd, LC_CMD_ZOOM_EXT, 0 );}
}

Order of layers and entities by layers:lcDrwSortObjects
Drawing “layer_order_ents.lcd” contains 4 layers,
named “0”, “Red”, “Green”, “Blue”
Each layer has 3 filled rectangles.
Each call of this function resorts the layers and resorts the entities depend on layers order.

void DemoSortLayers (HANDLE hLcWnd)
{static int iOrder = 0;  // static variable, will be incremented on each call of this functionint Variant[24][4]={    // all variants for sorting of 4 layers{1,2,3,4}, {1,2,4,3}, {1,3,4,2}, {1,3,2,4}, {1,4,2,3}, {1,4,3,2},{2,1,3,4}, {2,1,4,3}, {2,3,1,4}, {2,3,4,1}, {2,4,1,3}, {2,4,3,1},{3,1,2,4}, {3,1,4,2}, {3,2,1,4}, {3,2,4,1}, {3,4,1,2}, {3,4,2,1},{4,1,2,3}, {4,1,3,2}, {4,2,3,1}, {4,2,1,3}, {4,3,2,1}, {4,3,1,2}};HANDLE hDrw, hBlock, hLayer[4];int i;// get drawing and block, linked with CAD windowhDrw = lcPropGetHandle( hLcWnd, LC_PROP_WND_DRW );hBlock = lcPropGetHandle( hLcWnd, LC_PROP_WND_VIEWBLOCK );// get layers handleshLayer[0] = lcDrwGetObjectByName( hDrw, LC_OBJ_LAYER, L"0" );hLayer[1] = lcDrwGetObjectByName( hDrw, LC_OBJ_LAYER, L"Red" );hLayer[2] = lcDrwGetObjectByName( hDrw, LC_OBJ_LAYER, L"Green" );hLayer[3] = lcDrwGetObjectByName( hDrw, LC_OBJ_LAYER, L"Blue" );for (i=0; i<4; ++i){if (hLayer[i] == 0){// error, layer with specified name is not foundreturn;}}// set layer priorityfor (i=0; i<4; ++i){lcPropPutInt( hLayer[i], LC_PROP_TABLE_PRIORITY, Variant[iOrder][i] );}// sort layer by prioritylcDrwSortObjects( hDrw, LC_OBJ_LAYER );// sort entities in a block according the layers orderlcBlockSortEnts( hBlock, true, 0 );lcWndRedraw( hLcWnd );// set order for next call of this function++iOrder;if (iOrder == 24){iOrder = 0;}
}

Convert vector drawing file into raster image file:lcBlockRasterize
“Silent” mode, without displaying the drawing in a window.
The filename extention defines the file format.

int _tmain (int argc, _TCHAR* argv[])
{HANDLE hDrw, hBlock;BOOL   bRet;int    ImgWidth;double Xmin, Ymin, Xmax, Ymax, W, Gap;double Lef, Bot, Rig, Top;WCHAR* szFileName   = L"c:/Projects/_drawings/Lenovo.dxf";WCHAR* szRasterFile = L"c:/Projects/_drawings/Lenovo.png";lcInitialize( 0, 0, 0 );lcPropPutStr( 0, LC_PROP_G_REGCODE, L"your code" );hDrw = lcCreateDrawing();bRet = lcDrwLoad( hDrw, szFileName, 0 );if (bRet){// Set back color of Model space to WhitelcPropPutInt( hDrw, LC_PROP_DRW_COLORBACKM, RGB(255,255,255) );// Set fore color of Model space to BlacklcPropPutInt( hDrw, LC_PROP_DRW_COLORFOREM, RGB(0,0,0) );// get Model blockhBlock = lcPropGetHandle( hDrw, LC_PROP_DRW_BLOCK_MODEL );// get extentsXmin = lcPropGetFloat( hBlock, LC_PROP_BLOCK_XMIN );Ymin = lcPropGetFloat( hBlock, LC_PROP_BLOCK_YMIN );Xmax = lcPropGetFloat( hBlock, LC_PROP_BLOCK_XMAX );Ymax = lcPropGetFloat( hBlock, LC_PROP_BLOCK_YMAX );W = Xmax - Xmin;if (W > 0.0){// increase output rectGap = W / 30.0;  // blank spaceLef = Xmin - Gap;Bot = Ymin - Gap;Rig = Xmax + Gap;Top = Ymax + Gap;// make raster image and save it in a fileImgWidth = 1500;  // image width, pixelsbRet = lcBlockRasterize( hBlock, szRasterFile, Lef, Bot, Rig, Top, ImgWidth, 0 );}}lcUninitialize( false ); // if true - save configreturn 0;
}

Save window view into raster image in a memory buffer:lcBlockRasterizeMem

void DemoRasterToMem (HANDLE hLcWnd)
{double Xmin, Ymin, Xmax, Ymax;int    ImgW, ImgH;int    nBytes, sz, InfoSize, PalSize, ImgSize;HANDLE hBlock;BYTE*  pMem;BITMAPFILEHEADER bfh;BITMAPINFOHEADER* pbih;BYTE*  pImgBits;// get currently visible blockhBlock = lcPropGetHandle( hLcWnd, LC_PROP_WND_VIEWBLOCK );// get size of CAD window, pixels ImgW = lcPropGetInt( hLcWnd, LC_PROP_WND_WIDTH );ImgH = lcPropGetInt( hLcWnd, LC_PROP_WND_HEIGHT );// get extents of currently visible drawing's areaXmin = lcPropGetFloat( hLcWnd, LC_PROP_WND_XMIN );Ymin = lcPropGetFloat( hLcWnd, LC_PROP_WND_YMIN );Xmax = lcPropGetFloat( hLcWnd, LC_PROP_WND_XMAX );Ymax = lcPropGetFloat( hLcWnd, LC_PROP_WND_YMAX );// get required size for the memory buffernBytes = lcBlockRasterizeMem( hBlock, NULL, Xmin, Ymin, Xmax, Ymax, ImgW,ImgH );// allocate memory bufferpMem = new BYTE[nBytes];// write the block's image into the buffernBytes = lcBlockRasterizeMem( hBlock, pMem, Xmin, Ymin, Xmax, Ymax, ImgW,ImgH );// just for testing, let's save the memory buffer as an image file// in order to see the image contentsFILE* df = _wfopen( L"d:\\View.bmp", L"wb" );if (df){pbih = (BITMAPINFOHEADER*)pMem;ImgSize = pbih->biSizeImage;switch( pbih->biBitCount ){case 1: PalSize = 2 * 4;break;case 4: PalSize = 16 * 4;break;case 8: PalSize = 256 * 4;break;default:PalSize = 0;}InfoSize = 40 + PalSize;// write BMP file headersz = sizeof(bfh);memset( &bfh, 0, sz );bfh.bfType = 0x4D42;   // BM// file sizebfh.bfSize = 14 + nBytes;// offset to bitmap bitsbfh.bfOffBits = 14 + InfoSize;   // sizeof(BITMAPFILEHEADER) + sizeof(BITMAPINFOHEADER) + Palettefwrite( &bfh, sz, 1, df );// write bitmap info headerfwrite( pbih, InfoSize, 1, df );// write image bitspImgBits = pMem + InfoSize;fwrite( pImgBits, ImgSize, 1, df );fclose( df );}// free the memory bufferdelete[] pMem;
}

Print drawing’s extents at paper’s center:lcPrintBlock

void DemoPrint (HANDLE hLcWnd)
{HANDLE hBlock;double X, Y, W, H, Scale, scw, sch;double PapW, PapH, PapLef, PapTop, Gap, w2, h2;// set printer paper parametersPapW = 210.0;  // paper widthPapH = 297.0;  // paper heightGap = 10.0;    // border gap// get a block, linked with CAD windowhBlock = lcPropGetHandle( hLcWnd, LC_PROP_WND_BLOCK );// get block's extentsX = lcPropGetFloat( hBlock, LC_PROP_BLOCK_XMIN );Y = lcPropGetFloat( hBlock, LC_PROP_BLOCK_YMIN );W = lcPropGetFloat( hBlock, LC_PROP_BLOCK_DX );H = lcPropGetFloat( hBlock, LC_PROP_BLOCK_DY );// size of work area on a paperw2 = PapW - Gap - Gap;h2 = PapH - Gap - Gap;// calculate print scale, <printer mm> / <drawing units>scw = w2 / W;sch = h2 / H;if (scw < sch){Scale = scw;// set origin of print area on a paperPapLef = Gap;PapTop = (PapH / 2.0) - (H / 2.0 * Scale);}else{Scale = sch;// set origin of print area on a paperPapTop = Gap;PapLef = (PapW / 2.0) - (W / 2.0 * Scale);}// print lcPrintBlock( hBlock, X, Y, W, H, Scale, PapLef, PapTop, 0 );
}

2.Block reference

Inserts a named Block that has been defined in the current drawing. When you insert a block, you are inserting a block reference. The information is not simply copied from the block definition to the drawing area. Instead, a link is established between the block reference and the block definition. Therefore, if the block definition is changed, all references are updated automatically.Inserting a block into another block will create nested blocks.

Adds a new block reference object into a block.
HANDLE lcBlockAddBlockRef (HANDLE hBlock, HANDLE hRefBlock,double X,double Y,double Scale,double Angle);
Parameters:
hBlock(Handle to a block.);hRefBlock(Handle to the referenced block.);X Y(Coordinates of a block insertion point. The block’s base point will be placed at this coordinates.);Scale(Scale of a block when inserted. );Angle(Rotation angle of a block when inserted. )
Return Value:
Handle to created block reference object or NULL if the function fails.

3.Block Attributes

Whenever you insert a block that has a variable attribute, LiteCAD assign default value for the attributes. Later user can change the attribute value with the “Edit Block Attribute” dialog or “Properties” window.
Attributes also can be “invisible”. An invisible attribute is not displayed or plotted; however, the attribute information is stored in the drawing file and can be written to an extraction file
for use in a database program.
To create an attribute, you first create an attribute definition, which describes the characteristics of the attribute. The characteristics include the tag (which is a name that identifies the attribute), the prompt displayed when you insert the block, value information, text formatting, location, and any optional modes (Invisible, Constant, and Preset).
After creating the attribute definition, you select it as one of the objects when you define the block. Then, after you insert the block, you can edit the attibutes values with the “Edit Block
Attribute” dialog or “Properties” window.
To create an attribute definition programmatically use the following function (Adds an attribute definition into a block):
HANDLE lcBlockAddAttDef (HANDLE hBlock,int Mode,LPCWSTR szTag,LPCWSTR szPrompt,LPCWSTR szDefVal,double X,double Y,int Align,double Height,double WScale,double RotAngle,double Oblique);
Parameters:
hBlock(Handle to a block.);Mode(Mode.);szTag(Tag.);szPrompt(Prompt.);szDefVal(Default value.);X Y(Coordinates of the attribute insertion point.);Align(Align.);Height(Height.);WScale(WScale.);RotAngle(Rotation angle.);Oblique(Oblique.).
Return Value:
Handle to created Attribute object or NULL if the function fails.

There are the functions to access an attributes inside a block insertion entity:
Code sample1

//Retrieve block attribute value by Tag
void DemoBlockAtt1 (HANDLE hLcWnd)
{HANDLE hBlock, hEnt, hAtt;int    EntType;BOOL   bHasAtt;WCHAR* szTag = L"INFO";WCHAR  szValue[512];// clear text buffermemset( szValue, 0, sizeof(szValue) );// get a block, linked with CAD windowhBlock = lcPropGetHandle( hLcWnd, LC_PROP_WND_VIEWBLOCK );// enumerate block's entitieshEnt = lcBlockGetFirstEnt( hBlock );while( hEnt ){EntType = lcPropGetInt( hEnt, LC_PROP_ENT_TYPE );if (EntType == LC_ENT_BLOCKREF){bHasAtt = lcPropGetBool( hEnt, LC_PROP_BLKREF_ATTRIBS );if (bHasAtt){// get attribute by taghAtt = lcBlkRefGetAtt( hEnt, szTag );if (hAtt != 0){// get attribute valuewcsncpy( szValue, lcPropGetStr( hAtt, LC_PROP_ATT_VALUE ), 510 );}}}hEnt = lcBlockGetNextEnt( hBlock, hEnt );}
}

Code sample2

//Retrieve all attributes of all block's references
void DemoBlockAtt2 (HANDLE hLcWnd)
{HANDLE hBlock, hBlock2, hEnt, hAtt;int    EntType, NumAtts;BOOL   bHasAtt;WCHAR  szBlkName[128], szTag[64], szValue[512];// clear text buffersmemset( szBlkName, 0, sizeof(szBlkName) );memset( szTag, 0, sizeof(szTag) );memset( szValue, 0, sizeof(szValue) );// get a block, linked with CAD windowhBlock = lcPropGetHandle( hLcWnd, LC_PROP_WND_VIEWBLOCK );// enumerate block's entitieshEnt = lcBlockGetFirstEnt( hBlock );while( hEnt ){EntType = lcPropGetInt( hEnt, LC_PROP_ENT_TYPE );if (EntType == LC_ENT_BLOCKREF){bHasAtt = lcPropGetBool( hEnt, LC_PROP_BLKREF_ATTRIBS );if (bHasAtt){// get block namehBlock2 = lcPropGetHandle( hEnt, LC_PROP_BLKREF_BLOCK );wcsncpy( szBlkName, lcPropGetStr( hBlock2, LC_PROP_BLOCK_NAME ), 127 );// get block attributes for current BlockRefNumAtts = 0;  // counter of attributeshAtt = lcBlkRefGetFirstAtt( hEnt );while( hAtt != 0){++NumAtts;wcsncpy( szTag, lcPropGetStr( hAtt, LC_PROP_ATT_TAG ), 63 );wcsncpy( szValue, lcPropGetStr( hAtt, LC_PROP_ATT_VALUE ), 511 );// get next attributehAtt = lcBlkRefGetNextAtt( hEnt, hAtt );}}}hEnt = lcBlockGetNextEnt( hBlock, hEnt );}
}

Code sample3:lcBlockGetBlkRefByTag

//Rotate all block's references which match specified attribute
void DemoBlockAtt3 (HANDLE hLcWnd)
{HANDLE hBlock, hEnt;double Ang;WCHAR* szTag = L"QTY";WCHAR* szValue = L"7";// get a block, linked with CAD windowhBlock = lcPropGetHandle( hLcWnd, LC_PROP_WND_VIEWBLOCK );// unselect all entitieslcBlockUnselect( hBlock );// select all block references with specified attribute valuehEnt = lcBlockGetBlkRefByTag( hBlock, szTag, szValue, true );if (hEnt){// rotate selected BlockRefs around insertion pointhEnt = lcBlockGetFirstSel( hBlock );while( hEnt != 0 ){Ang = lcPropGetFloat( hEnt, LC_PROP_BLKREF_ANGLE );Ang += 5.0*LC_DEG_TO_RAD;lcPropPutFloat( hEnt, LC_PROP_BLKREF_ANGLE, Ang );hEnt = lcBlockGetNextSel( hBlock );}// unselect all entitieslcBlockUnselect( hBlock );// update viewlcWndRedraw( hLcWnd ); }
}

4.LC_CMD_INSERT

LC_CMD_INSERT is a value for Command parameter of the
lcWndExeCommand function.It starts interactive tool to add Block reference objects into a drawing.

//Using command LC_CMD_INSERT without dialog
void DemoCmdInsert (HANDLE hLcWnd)
{HANDLE hDrw, hBlock, hBlkRef;WCHAR* szBlockName = L"Block 007";double X, Y;// get the drawing linked with CAD windowhDrw = lcPropGetHandle( hLcWnd, LC_PROP_WND_DRW );// specify the block to be insertedhBlock = lcDrwGetObjectByName( hDrw, LC_OBJ_BLOCK, szBlockName );if (hBlock != 0){lcPropPutHandle( 0, LC_PROP_BLKREF_BLOCK, hBlock );// specify position on-screenlcPropPutBool( 0, LC_PROP_BLKREF_ONS_XY, true );// set fixed scalelcPropPutBool( 0, LC_PROP_BLKREF_ONS_SCALE, false );lcPropPutFloat( 0, LC_PROP_BLKREF_SCALE, 0.5 );// set fixed rotation anglelcPropPutBool( 0, LC_PROP_BLKREF_ONS_ANGLE, false );lcPropPutFloat( 0, LC_PROP_BLKREF_ANGLE, 45*LC_DEG_TO_RAD );// run the command to insert a block without a dialoglcWndExeCommand( hLcWnd, LC_CMD_INSERT, LC_INSERT_NODLG );// get handle to the block reference that was created by the commandhBlkRef = lcPropGetHandle( 0, LC_PROP_BLKREF_RETURN );if (hBlkRef != 0){// get coordinates of insertion pointX = lcPropGetFloat( hBlkRef, LC_PROP_BLKREF_X );Y = lcPropGetFloat( hBlkRef, LC_PROP_BLKREF_Y );}// reset default mode to LC_INSERT_DLGlcWndExeCommand( hLcWnd, LC_CMD_INSERT, LC_INSERT_RESET );}
}

5.Create new block from all entities of “Model Space” block

void DemoDrwToBlock (HANDLE hLcWnd)
{HANDLE hDrw, hBlock, hNewBlock, hEnt;double Xmin, Ymin, Xmax, Ymax, X, Y;WCHAR* szFileName = L"c:/tmp/1F2P.dxf";// get drawing object, linked with CAD windowhDrw = lcPropGetHandle( hLcWnd, LC_PROP_WND_DRW );// load a filelcDrwLoad( hDrw, szFileName, hLcWnd );// get Model Space blockhBlock = lcPropGetHandle( hDrw, LC_PROP_DRW_BLOCK_MODEL );// calculate centerXmin = lcPropGetFloat( hBlock, LC_PROP_BLOCK_XMIN );Ymin = lcPropGetFloat( hBlock, LC_PROP_BLOCK_YMIN );Xmax = lcPropGetFloat( hBlock, LC_PROP_BLOCK_XMAX );Ymax = lcPropGetFloat( hBlock, LC_PROP_BLOCK_YMAX );X = (Xmin + Xmax) / 2.0;Y = (Ymin + Ymax) / 2.0;// create new block with basepoint X,YhNewBlock = lcDrwAddBlock( hDrw, L"New Block", X, Y );if (hNewBlock){// move all entities from Model block into hNewBlockhEnt = lcBlockGetFirstEnt( hBlock );while( hEnt ){// add the entity's copy into destination blocklcBlockAddClone( hNewBlock, hEnt );// remove the entity from source blocklcEntErase( hEnt, true );// get next entity of the destination blockhEnt = lcBlockGetNextEnt( hBlock, hEnt );}lcBlockUpdate( hNewBlock, true, 0 );// add the reference of new blocklcBlockAddBlockRef( hBlock, hNewBlock, X, Y, 1.0, 0.0 );// update and displaylcBlockUpdate( hBlock, true, 0 );lcWndExeCommand( hLcWnd, LC_CMD_ZOOM_EXT, 0 );}
}

Method 2

void DemoDrwToBlock2 (HANDLE hLcWnd)
{HANDLE hDrw, hBlock;double X, Y;WCHAR* szFileName = L"c:/!OK/Projects/_drawings/_Litecad3/1/1F2P.dxf";WCHAR* szName = L"New Block";// get drawing object, linked with CAD windowhDrw = lcPropGetHandle( hLcWnd, LC_PROP_WND_DRW );// load a filelcDrwLoad( hDrw, szFileName, hLcWnd );// get current blockhBlock = lcPropGetHandle( hLcWnd, LC_PROP_WND_BLOCK );// select all entities on current blocklcBlockSelectEnt( hBlock, 0, true );// get center point of selected entitiesX = 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, true );lcWndRedraw( hLcWnd );
}

LiteCAD参考文档的学习二(命令接口,命名对象之块、块的引用、块的属性、命令接口块的插入、块的复制)相关推荐

  1. LiteCAD参考文档的学习四(单文本、多文本、弧形文本、光栅图像、图像引用、ECW/Jpeg2000 Image图像、填充图案、尺寸、引线)

    LiteCAD API reference 一.Text (single-line) Text conveys important information in your drawing. You u ...

  2. LiteCAD参考文档的学习七(图像窗口、放大窗口、鸟瞰图、对象属性窗口、极轴跟踪、跳线、事件、用户自定义命令、其它功能)

    LiteCAD API reference 一.Graphics window The LiteCAD graphics window is used to display and edit grap ...

  3. JavaScript内置对象(内置对象、查文档(MDN)、Math对象、日期对象、数组对象、字符串对象)

    目录 JavaScript内置对象 内置对象 查文档 MDN Math对象 Math概述 案例一:封装自己的对象 随机数方法 random() 案例一:猜数字游戏 日期对象 Date 概述 Date( ...

  4. mysql语法大全w3school_(二)mysql:在w3schools文档上学习sql语法(使用数据库创建一张表)...

    1.选中要使用的数据库(选中上篇创建的test数据库) 现有的数据库 mysql>use test; 则选中test数据库: 2.创建一张表 2.1column代表每一列的名称,datatype ...

  5. 【毕业设计】60-基于ZigBee无线智能消防\烟雾报警逃生系统设计(原理图工程、源代码、低重复率参考文档、实物图)

    [毕业设计]60-基于ZigBee无线智能消防\烟雾报警逃生系统设计(原理图工程.源代码.低重复率参考文档.实物图) 文章目录 [毕业设计]60-基于ZigBee无线智能消防\烟雾报警逃生系统设计(原 ...

  6. Hibernate中文参考文档(JFIS)

    HIBERNATE - 符合Java习惯的关系数据库持久化      下一页 HIBERNATE - 符合Java习惯的关系数据库持久化 Hibernate参考文档 3.0.4 目录 前言 1. 翻译 ...

  7. [参考文档] [翻译]Oracle 12c R2优化器白皮书

    [参考文档] [翻译]Oracle 12c R2优化器白皮书 原文链接: http://www.oracle.com/technetwor ... edb-12c-1963236.pdf 第一版翻译链 ...

  8. Spring Data JPA - 参考文档 地址

    前些天发现了一个巨牛的人工智能学习网站,通俗易懂,风趣幽默,忍不住分享一下给大家.点击跳转到教程. Spring Data JPA - 参考文档 文档地址

  9. 太赞了:《Spring Framework 4.x 参考文档》最新中文版开放下载!

    前言 <Spring Framework Reference Documentation>是Spring官方出的文档,但是是英文版导致很多国内的程序员阅读起来有一定的难度. 好在,有国内的 ...

最新文章

  1. Visual Studio 2010构建Web浏“.NET研究”览器应用程序
  2. 将vim打造成IDE编程环境
  3. java中单例的几种写法
  4. 这4部有生之年必看的“教材级”纪录片,免费领取!
  5. Apache Camel 2.16发布–十大亮点
  6. covariance matrix r语言_时间序列分析|ARIMAX模型分步骤详解和R中实践
  7. c语言输出单链表最大值与最小值,数据结构(C语言版)---顺序表与链表的比较...
  8. Integer中1000==1000为false而100==100为true
  9. UnityShader11:纹理属性
  10. 将Windows的IE11降级为原先的IE版本
  11. c语言编程 模拟掷骰子,用C语言编写一个模拟掷骰子游戏
  12. python实现 猴子摘香蕉
  13. 推荐几个很实用的网址
  14. (.Net常识)(int),Int32.Parse,Conver.ToInt32三者在什么情况下使用以及其区别。
  15. OCR目标识别(车辆VIN码识别效果)
  16. Oracle-存储过程语法
  17. 眼动在旅游研究中有哪些运用?
  18. android手表密码忘了咋办,忘记解锁密码?教你如何重置Android手机的解锁密码
  19. scrapy--Beautyleg
  20. 吉林大学珠海学院计算机网络专插本考试考哪些内容,【考试大纲】2020吉林大学珠海学院(美术设计)专插本考题考试全面解析(分享)...

热门文章

  1. [攻略][Python]给array类型的数据添加方括号、去掉方括号
  2. 怎样的婚恋网站,才能符合单身的交友信息呢。
  3. java腾讯滤镜接口_腾讯内容开放平台
  4. repo: command not found
  5. 原生H5实现观音抽签祈福效果
  6. h5的开源播放器组件
  7. PC端“交易猫”网站爬虫项目
  8. 做好cpc广告的五部攻略 你就能日出百单
  9. vue实现点击变色再次点击变回来
  10. 微信搜索刷关键词推广方法