LiteCAD API reference

一、Text (single-line)

Text conveys important information in your drawing. You use text for title blocks, to label parts of the drawing, to give specifications, or to make annotations.New text entities are created with the current Text style.

1.Formatting codes for single text

The following control codes are used to add special characters in Text entity:

You can enter any character by its Unicode value, with the control code\U+xxxx, where xxxx is the hexadecimal value of the Unicode character.For example:

2.Text Alignment


Create texts with various alignment

void DemoTextAlign (HANDLE hLcWnd)
{HANDLE hDrw, hBlock, hEnt;int    EntType;COLORREF Color;double RectW = 500.0;double RectH = 50.0;double StepY = 60.0;double Htxt = 15.0;     // text heightdouble WScale = 1.0;    // text width scaledouble X, Y, dx, dy;// get drawing and block, linked with CAD windowhDrw = lcPropGetHandle( hLcWnd, LC_PROP_WND_DRW );hBlock = lcPropGetHandle( hLcWnd, LC_PROP_WND_BLOCK );// Create rectangles and insert text at center point, changing alignmentX = 0;Y = 0;lcBlockAddText2( hBlock, L"LC_TA_LEFBOT", X, Y, LC_TA_LEFBOT , Htxt, WScale, 0, 0 );lcBlockAddRect( hBlock, X, Y, RectW, RectH, 0, 0);lcBlockAddPoint( hBlock, X, Y );Y += StepY;lcBlockAddText2( hBlock, L"LC_TA_CENBOT", X, Y, LC_TA_CENBOT, Htxt, WScale, 0, 0 );lcBlockAddRect( hBlock, X, Y, RectW, RectH, 0, 0);lcBlockAddPoint( hBlock, X, Y );Y += StepY;lcBlockAddText2( hBlock, L"LC_TA_RIGBOT", X, Y, LC_TA_RIGBOT, Htxt, WScale, 0, 0 );lcBlockAddRect( hBlock, X, Y, RectW, RectH, 0, 0);lcBlockAddPoint( hBlock, X, Y );Y += StepY;lcBlockAddText2( hBlock, L"LC_TA_LEFCEN", X, Y, LC_TA_LEFCEN, Htxt, WScale, 0, 0 );lcBlockAddRect( hBlock, X, Y, RectW, RectH, 0, 0);lcBlockAddPoint( hBlock, X, Y );Y += StepY;lcBlockAddText2( hBlock, L"LC_TA_CENTER", X, Y, LC_TA_CENTER , Htxt, WScale, 0, 0 );lcBlockAddRect( hBlock, X, Y, RectW, RectH, 0, 0);lcBlockAddPoint( hBlock, X, Y );Y += StepY;lcBlockAddText2( hBlock, L"LC_TA_RIGCEN", X, Y, LC_TA_RIGCEN, Htxt, WScale, 0, 0 );lcBlockAddRect( hBlock, X, Y, RectW, RectH, 0, 0);lcBlockAddPoint( hBlock, X, Y );Y += StepY;lcBlockAddText2( hBlock, L"LC_TA_LEFTOP", X, Y, LC_TA_LEFTOP, Htxt, WScale, 0, 0 );lcBlockAddRect( hBlock, X, Y, RectW, RectH, 0, 0);lcBlockAddPoint( hBlock, X, Y );Y += StepY;lcBlockAddText2( hBlock, L"LC_TA_CENTOP", X, Y, LC_TA_CENTOP, Htxt, WScale, 0, 0 );lcBlockAddRect( hBlock, X, Y, RectW, RectH, 0, 0);lcBlockAddPoint( hBlock, X, Y );Y += StepY;lcBlockAddText2( hBlock, L"LC_TA_RIGTOP", X, Y, LC_TA_RIGTOP, Htxt, WScale, 0, 0 );lcBlockAddRect( hBlock, X, Y, RectW, RectH, 0, 0);lcBlockAddPoint( hBlock, X, Y );dx = RectW * 0.35;dy = RectH * 0.3;Y = -StepY;lcBlockAddText3( hBlock, L"LC_TA_FIT", X-dx, Y-dy, X+dx, Y-dy, LC_TA_FIT, Htxt, 0 );lcBlockAddRect( hBlock, X, Y, RectW, RectH, 0, 0);lcBlockAddPoint( hBlock, X-dx, Y-dy );lcBlockAddPoint( hBlock, X+dx, Y-dy );Y -= StepY;lcBlockAddText3( hBlock, L"LC_TA_ALIGNED", X-dx, Y-dy, X+dx, Y-dy, LC_TA_ALIGNED, WScale, 0 );lcBlockAddRect( hBlock, X, Y, RectW, RectH, 0, 0);lcBlockAddPoint( hBlock, X-dx, Y-dy );lcBlockAddPoint( hBlock, X+dx, Y-dy );// set red color for all text entitiesColor = RGB(255,0,0);hEnt = lcBlockGetFirstEnt( hBlock );while( hEnt ){EntType = lcPropGetInt( hEnt, LC_PROP_ENT_TYPE );if (EntType == LC_ENT_TEXT){lcPropPutInt( hEnt, LC_PROP_ENT_COLOR, Color );}hEnt = lcBlockGetNextEnt( hBlock, hEnt );}lcBlockUpdate( hBlock, false, 0 );// zoom extentslcWndZoomRect( hLcWnd, 0,0,0,0 );// and slightly reduce the viewlcWndZoomScale( hLcWnd, 0.8 );
}

3.Text Style

A Text Style is a named, saved collection of settings that determine the appearance of text characters, for example, the settings include things like font, stretched, compressed, oblique, mirrored etc… The primary marker of any text style is LiteCAD font (LCF) or Windows TTF font that is assigned to that text style.
The LiteCAD package contains LCFont.exe program which can create LCF font file from AutoCAD SHX/SHP or Windows TTF font.New Text entities are added to a drawing using the current text style.When you create a new drawing, it already has one text style, by default, named “Standard”.

二、Multiline Text

Adds a new Multiline Text object into a block: HANDLE lcBlockAddMText (HANDLE hBlock,LPCWSTR szText,double X,double Y,double WrapWidth,int Align,double RotAngle,double Height,double WScale);
Create multiline text with stacked characters

void DemoMText (HANDLE hLcWnd)
{double x0, y0, W, H, Ht;HANDLE hDrw, hBlock, hTStyle, hText;WCHAR* szText = L"\\A1;H\\H0.5x;\\S^2;\\H2x;O 1\\H0.6x;\\S2/3;\\H1.6667x;+4\\H0.6x;\\S0.5^;\\H1.6667x;=3.66666...";// get drawing and block, linked with CAD windowhDrw = lcPropGetHandle( hLcWnd, LC_PROP_WND_DRW );hBlock = lcPropGetHandle( hLcWnd, LC_PROP_WND_BLOCK );// set font "Arial" for the text style "Standard"hTStyle = lcPropGetHandle( hDrw, LC_PROP_DRW_TEXTSTYLE_STD );lcPropPutBool( hTStyle, LC_PROP_TSTYLE_WINFONT, true );lcPropPutStr( hTStyle, LC_PROP_TSTYLE_FONT, L"Arial" );lcPropPutBool( hTStyle, LC_PROP_TSTYLE_SOLID, true );// set active text stylelcPropPutHandle( hDrw, LC_PROP_DRW_TEXTSTYLE, hTStyle );// add multiline textx0 = 0.0;y0 = 0.0;W = 130.0;  // wrap widthHt = 10.0;  // text heighthText = lcBlockAddMText( hBlock, szText, x0, y0, W, LC_TA_CENTER, 0.0, Ht, 1.0 );// add bounding rectangleW = lcPropGetFloat( hText, LC_PROP_MTEXT_WRECT ) * 1.1;H = lcPropGetFloat( hText, LC_PROP_MTEXT_HRECT ) * 1.2;lcBlockAddRect( hBlock, x0, y0, W, H, 0.0, false );// update viewlcBlockUpdate( hBlock, true, 0 );lcWndExeCommand( hLcWnd, LC_CMD_ZOOM_EXT, 0 );
}

三、Arc Text

HANDLE lcBlockAddArcText (HANDLE hBlock,LPCWSTR szText,double X,double Y,double Radius,double StartAngle,BOOL bClockwise,double Height,double WScale,int Align);
Create arc texts

void DemoArcText (HANDLE hLcWnd)
{WCHAR* szStyleName = L"New Style";WCHAR* szText = L"THIS IS THE ARC TEXT";double X[3], Y, R, H, Gap, Angle;int    i, k, Align[3];HANDLE hDrw, hBlock, hTStyle;bool   bClockwise = true;// get drawing and block, linked with CAD windowhDrw = lcPropGetHandle( hLcWnd, LC_PROP_WND_DRW );hBlock = lcPropGetHandle( hLcWnd, LC_PROP_WND_BLOCK );// get text style with specified namehTStyle = lcDrwGetObjectByName( hDrw, LC_OBJ_TEXTSTYLE, szStyleName );if (hTStyle == NULL){// the style don't exist, create new text stylehTStyle = lcDrwAddTextStyle( hDrw, szStyleName, L"Times New Roman", true );}// set current text stylelcPropPutHandle( hDrw, LC_PROP_DRW_TEXTSTYLE, hTStyle );// add graphicsR = 10.0;X[0] = 0;X[1] = R * 3.0;X[2] = R * 6.0;Y = 0.0;H = R / 5.0;Gap = H / 4.0;Angle = 90.0 * LC_DEG_TO_RAD;Align[0] = LC_ATA_LEFT;Align[1] = LC_ATA_CENTER;Align[2] = LC_ATA_RIGHT;for (k=0; k<2; ++k){for (i=0; i<3; ++i){lcBlockAddCircle( hBlock, X[i], Y, R, false );lcBlockAddLine( hBlock, X[i], Y, X[i], Y+R );lcBlockAddArcText( hBlock, szText, X[i], Y, R+Gap, Angle, bClockwise, H, 1.0, Align[i] );}bClockwise = !bClockwise;Y -= R * 3.0;}// update viewlcBlockUpdate( hBlock, true, 0 );lcWndExeCommand( hLcWnd, LC_CMD_ZOOM_EXT, 0 );
}

四、Raster Image

Raster images consist of a rectangular grid (or raster) of small squares or dots known as pixels. LiteCAD does not keep raster images stored inside of its file format. It only keeps a reference to the name of the image file which is inserted into the drawing.Litecad.dll internally supports only Windows BMP format, but if the Litecad.dll directory contains the FreeImage.dll file (http://freeimage.sourceforge.net), it will be used to load many various raster formats (jpeg, tiff, gif, png, etc…). Note that the FreeImage.dll file works as a plugin, and LiteCAD can work without it, therefore redistribute this file only if your LiteCAD-based application requires support for various raster image formats.

Create raster image (set pixels)

void DemoImage2 (HANDLE hLcWnd)
{int    ImgW, ImgH, PixX, PixY, R, G, B;double x0, y0, x1, y1, W, H, Htxt, Gap;HANDLE hDrw, hBlock, hImage, hImgRef;WCHAR* szImageName = L"Sample image";// get drawing and block, linked with CAD windowhDrw = lcPropGetHandle( hLcWnd, LC_PROP_WND_DRW );hBlock = lcPropGetHandle( hLcWnd, LC_PROP_WND_BLOCK );// get image by name hImage = lcDrwGetObjectByName( hDrw, LC_OBJ_IMAGE, szImageName );if (hImage == NULL){// image size, pixelsImgW = 500;ImgH = 500;// create imagehImage = lcDrwAddImage2( hDrw, szImageName, ImgW, ImgH, 24 );// set color of the image pixelsfor (PixX=0; PixX<ImgW; ++PixX){R = (255 * PixX) / ImgW;for (PixY=0; PixY<ImgH; ++PixY){G = (255 * PixY) / ImgH;B = 255 - abs(R-G);lcImageSetPixelRGB( hImage, PixX, PixY, R, G, B );}}}// add image referencex0 = 10.0;y0 = 20.0;W = 50.0;H = 50.0;Htxt = 5.0;Gap = Htxt * 0.3;lcBlockAddImageRef( hBlock, hImage, x0, y0, W, H, false );// add more graphic objectsx0 = x0 - Gap;y0 = y0 - Gap;W = W + Gap + Gap;H = H + Gap + Gap;lcBlockAddRect2( hBlock, x0, y0, W, H, 0, false );x1 = x0 + W + Gap;y1 = y0 + H + Gap;x0 = x0 - Gap;y0 = y0 - Gap;lcBlockAddText2( hBlock, L"RED", x1, y0, LC_TA_LEFTOP, Htxt, 1, 0, false );lcBlockAddText2( hBlock, L"GREEN", x0, y1, LC_TA_RIGBOT, Htxt, 1, 0, false );lcBlockAddText2( hBlock, L"BLUE", x0, y0, LC_TA_RIGTOP, Htxt, 1, 0, false );lcBlockAddText2( hBlock, L"WHITE", x1, y1, LC_TA_LEFBOT, Htxt, 1, 0, false );// displaylcBlockUpdate( hBlock, true, 0 );lcWndExeCommand( hLcWnd, LC_CMD_ZOOM_EXT, 0 );
}

五、Image reference

Adds a new image reference object into a block:HANDLE lcBlockAddImageRef (HANDLE hBlock,HANDLE hImage,double X,double Y,double Width,double Height,BOOL bBorder);
Parameters:
hBlock(Handle to a block.);hImage(Handle to the image definition.);X Y(Coordinates of image insertion. Left bottom corner of the image will be placed at this coordinate. );Width Height(Image size. In order to keep original proportions, specify only one dimension, setting zero for other.);bBorder(If TRUE, then the image will have a border lines.).

Create raster image (from a file)

void DemoImage (HANDLE hLcWnd)
{HANDLE hDrw, hBlock, hImage, hImage2, hImageRef;WCHAR* szImageFile1 = L"d:/___TMP/Image01.jpg";WCHAR* szImageFile2 = L"d:/___TMP/Image03.png";double X, Y, W, H, W2, Xc, Yc;int    Wpix, Hpix;// get drawing and block, linked with CAD windowhDrw = lcPropGetHandle( hLcWnd, LC_PROP_WND_DRW );hBlock = lcPropGetHandle( hLcWnd, LC_PROP_WND_BLOCK );// add raster image from a filehImage = lcDrwAddImage( hDrw, L"", szImageFile1 );// get image dimensions (pixels)Wpix = lcPropGetInt( hImage, LC_PROP_IMAGE_WPIX );Hpix = lcPropGetInt( hImage, LC_PROP_IMAGE_HPIX );// add one more raster imagehImage2 = lcDrwAddImage( hDrw, L"", szImageFile2 );// insert the image into a drawingX = 0.0;Y = 0.0;W = 100.0;  // width of image ref. (height will be set according the ratio of image dimensions)hImageRef = lcBlockAddImageRef( hBlock, hImage, X,Y, W,0, true );// get height of the image referenceH = lcPropGetFloat( hImageRef, LC_PROP_IMGREF_H );// add 2nd image reference above the 1stY+=H;hImageRef = lcBlockAddImageRef( hBlock, hImage, X,Y, W,0, false );// flip verticallylcPropPutBool( hImageRef, LC_PROP_IMGREF_FLIPVER, true );// and make it greyscalelcPropPutBool( hImageRef, LC_PROP_IMGREF_GREY, true );// add 3rd image reference at right of the 2ndX+=W;hImageRef = lcBlockAddImageRef( hBlock, hImage, X,Y, W,0, true );// reduce resolution 8 timeslcImgRefResize( hImageRef, Wpix/8, Hpix/8, LC_IMGRES_BICUBIC );// add 4rd image referenceY-=H;hImageRef = lcBlockAddImageRef( hBlock, hImage, X,Y, W,0, false );// get center pointXc = lcPropGetFloat( hImageRef, LC_PROP_IMGREF_XC );Yc = lcPropGetFloat( hImageRef, LC_PROP_IMGREF_YC );// scale and rotate the image ref.lcEntScale( hImageRef, Xc, Yc, 0.8 );lcEntRotate( hImageRef, Xc, Yc, 30.0 * LC_DEG_TO_RAD );// add image ref. of hImage2Y += H;W2 = W / 4.0;hImageRef = lcBlockAddImageRef( hBlock, hImage2, X-W2/2, Y-W2/2, W2,0, false );// set transparent colorlcPropPutInt( hImageRef, LC_PROP_IMGREF_TRANSP, 1 );lcPropPutInt( hImageRef, LC_PROP_IMGREF_TRCOLOR, RGB(255,255,255) );// displaylcBlockUpdate( hBlock, true, 0 );lcWndExeCommand( hLcWnd, LC_CMD_ZOOM_EXT, 0 );
}

HANDLE lcBlockAddImagePlace (HANDLE hBlock,int Id,double X, double Y,double Width, double Height,BOOL bBorder);
Parameters:
hBlock(Handle to a block.);Id(Identifier of an image. Use this number in a DrawImage event to identify what image must be drawn.);X Y(Coordinates of image insertion. Left bottom corner of the image will be placed at this coordinate. );Width Height(Image size, in drawing’s units.);bBorder(If TRUE, then the image will have a border lines.).

Draw custom raster image (rendered by application)

...// register event procedurelcEventSetProc( LC_EVENT_DRAWIMAGE, DrawImageProc, 0, 0 );
...// create image object in a drawingHANDLE hImgRef;hImgRef = lcBlockAddImagePlace( hBlock, 105, 10,20,100,50, true );lcBlockUpdate( hBlock, false, hImgRef );lcWndRedraw( m_hLcWnd );
...// This function is called on LC_EVENT_DRAWIMAGE event
//-----------------------------------------------
void CALLBACK DrawImageProc (HANDLE hEvent)
{COkDib Dib;OK_DIBDRAWPRM Prm;double W, H, PixelSize;int    idImage;HANDLE hLcWnd;if (Dib.Load( L"d:/Pictures/SomeImage.bmp" ) == false){return;}hLcWnd = lcPropGetHandle( hEvent, LC_PROP_EVENT_WND );idImage = lcPropGetInt( hEvent, LC_PROP_EVENT_INT6 );  // ID passed by lcBlockAddImagePlace()W = lcPropGetFloat( hEvent, LC_PROP_EVENT_FLOAT1 );    // image width (drawing's units)H = lcPropGetFloat( hEvent, LC_PROP_EVENT_FLOAT2 );    // image height (drawing's units)memset( &Prm, 0, sizeof(Prm) );Prm.hDC = (HDC)lcPropGetHandle( hEvent, LC_PROP_EVENT_HDC );Prm.ImgLeft   = lcPropGetInt( hEvent, LC_PROP_EVENT_INT1 );Prm.ImgBottom = lcPropGetInt( hEvent, LC_PROP_EVENT_INT2 );PixelSize = lcPropGetFloat( hLcWnd, LC_PROP_WND_PIXELSIZE );Prm.ImgWidth  = (UINT)(W/PixelSize + 0.5);  // 0 for non-scalable imagePrm.ImgHeight = (UINT)(H/PixelSize + 0.5);  // 0 for non-scalable image
//  Prm.Align = 1;          // alignment for non-scalable image, 0: center, 1: left-bottomPrm.bDevRectValid = true;   // if TRUE then a device rectangle (below parameters) are validPrm.DevLeft   = 0;Prm.DevTop    = 0;Prm.DevRight  = lcPropGetInt( hEvent, LC_PROP_EVENT_INT3 );Prm.DevBottom = lcPropGetInt( hEvent, LC_PROP_EVENT_INT4 );// the next function draws the image using WinAPI function StretchDIBitsDib.Draw( Prm );
}

六、ECW / Jpeg2000 Image

ECW (Enhanced Compression Wavelet) is a proprietary wavelet compression image format optimized for aerial and satellite imagery.The lossy compression format efficiently compresses very large images with fine alternating contrast. Map projection information can be embedded into the ECW file format to support geospatial applications.
LiteCAD uses the ERDAS ECW JP2 SDK to support this image format.There is NCSEcw.dll file from Hexagon Geospatial that come with LiteCAD package.LiteCAD can work without this file, therefore you must redistribute this file only if your LiteCAD-based application requires support for ECW or Jpeg2000 formats.

七、Hatch

Hatch is a boundary filled with a pattern of lines or with a solid color. The boundary can have inner “islands”. LiteCAD uses hatch patterns in the same format as AutoCAD. The hatches.pat file included with the LiteCAD package contains many predefined hatch patterns. You can also create your own hatch patterns.
HANDLE lcBlockAddHatch (HANDLE hBlock,LPCWSTR szFileName,LPCWSTR szPattern,double Scale,double RotAngle);
Parameters:
hBlock(Handle to a block.);szFileName(Name of the file which contains hatch patterns definitions.For example, LiteCAD package has the “hatches.pat” file.);szPattern(The meaning depends on the szFileName parameter. If the filename is specified,then szPattern is a name of hatch pattern, as written in the file.If the filename is an empty string, then szPattern is a hatch pattern definition.See the code sample below.);Scale(Scale of the pattern.);RotAngle(Rotation angle of the pattern.).

Create hatch

void DemoHatch (HANDLE hLcWnd)
{HANDLE hBlock, hEnt;bool   bSolid = false;  // if TRUE then solid fillint    Method = 0;      // method of creating a hatch entitydouble Scale = 8.0;     // scale of hatch patterndouble Angle = 45 * LC_DEG_TO_RAD;  // rotation of hatch pattern// get a block, linked with CAD windowhBlock = lcPropGetHandle( hLcWnd, LC_PROP_WND_BLOCK );// clear selection setlcBlockUnselect( hBlock );// create entities and add them into selectionhEnt = lcBlockAddCircle( hBlock, 10, 10, 5, false );lcBlockSelectEnt( hBlock, hEnt, true );hEnt = lcBlockAddCircle( hBlock, 30, 10, 5, false );lcBlockSelectEnt( hBlock, hEnt, true );hEnt = lcBlockAddRect2( hBlock, 0, 0, 40, 20, 5, false );lcBlockSelectEnt( hBlock, hEnt, true );// create Hatch entity using selected entities as an outlineif (bSolid){hEnt = lcBlockAddHatch( hBlock, L"", L"", 0.0, 0.0 );// set filling colorlcPropPutStr( hEnt, LC_PROP_ENT_FCOLOR, L"0,255,255" );}else{if (Method == 0){// hatch pattern is defined in *.pat filelcBlockAddHatch( hBlock, L"hatches.pat", L"ANGLE", Scale, Angle );}else{// hatch pattern is defined by text stringlcBlockAddHatch( hBlock, L"", L"0, 0,0, 0,.275, .2,-.075\n90, 0,0, 0,.275, .2,-.075", Scale, Angle );}}   // clear selection set and update block extentslcBlockUnselect( hBlock );lcBlockUpdate( hBlock, false, 0 );// zoom viewlcWndZoomRect( hLcWnd, -10, -10, 50, 30 );
}


Create hatch:lcHatchBoundStart;lcHatchBoundEntity; lcHatchBoundEndLoop;lcHatchBoundEnd.

void DemoHatch2 (HANDLE hLcWnd)
{HANDLE hBlock, hHatch, hEnt;bool   bSolid = false;  // if TRUE then solid fillint    Method = 1;      // method of creating a hatch entitydouble Scale = 5.0;     // scale of hatch patterndouble Angle = 30.0 * LC_DEG_TO_RAD;  // rotation of hatch patternWCHAR* szPattern;// get a block, linked with CAD windowhBlock = lcPropGetHandle( hLcWnd, LC_PROP_WND_BLOCK );// create Hatch entity using selected entities as an outlineif (bSolid){hHatch = lcBlockAddHatch( hBlock, L"", L"", 0.0, 0.0 );// set filling colorlcPropPutStr( hHatch, LC_PROP_ENT_FCOLOR, L"0,255,255" );}else{Scale = 5.0;Angle = 30.0 * LC_DEG_TO_RAD;if (Method == 0){// hatch pattern is defined in *.pat fileszPattern = L"ANGLE";hHatch = lcBlockAddHatch( hBlock, L"hatches.pat", szPattern, Scale, Angle );}else{// hatch pattern is defined by text stringszPattern = L"0, 0,0, 0,.275, .2,-.075\n90, 0,0, 0,.275, .2,-.075";hHatch = lcBlockAddHatch( hBlock, L"", szPattern, Scale, Angle );}}// the hatch entity has not boundaries, so we have to add itlcHatchBoundStart( hHatch );// create outer boundary from lines and arcshEnt = lcBlockAddLine( hBlock, 0, 0, 15, 0 );lcHatchBoundEntity( hHatch, hEnt );hEnt = lcBlockAddArc( hBlock, 15, 5, 5, 270*LC_DEG_TO_RAD, 180*LC_DEG_TO_RAD );lcHatchBoundEntity( hHatch, hEnt );hEnt = lcBlockAddLine( hBlock, 15, 10, 0, 10 );lcHatchBoundEntity( hHatch, hEnt );hEnt = lcBlockAddArc( hBlock, 0, 5, 5, 90*LC_DEG_TO_RAD, 180*LC_DEG_TO_RAD );lcHatchBoundEntity( hHatch, hEnt );lcHatchBoundEndLoop( hHatch ); // add inner boundarieshEnt = lcBlockAddCircle( hBlock, 0, 5, 2.0, false );lcHatchBoundEntity( hHatch, hEnt );hEnt = lcBlockAddRect( hBlock, 12,5, 6, 3, 0, false );lcHatchBoundEntity( hHatch, hEnt );// finish boundaries definitionlcHatchBoundEnd( hHatch );lcBlockUpdate( hBlock, true, 0 );// zoom viewlcWndZoomRect( hLcWnd, -15, -10, 30, 20 );
}

Retrieve outlines of hatch entity
A sample drawing (“exp_hatch_2.lcd”) has a hatch entity,marked with key value 123. We have to retrieve outlines of this hatch and create polylines which are copies of that outlines, with some offset.

void DemoGetHatchOutlines (HANDLE hLcWnd)
{int    Key = 123;   // required hatch entity is marked with this key valueHANDLE hBlock, hEntHatch, hPline;int    i, j, k, n, nPaths;double x, y, dx, dy;// get a block, linked with CAD windowhBlock = lcPropGetHandle( hLcWnd, LC_PROP_WND_VIEWBLOCK );// get required hatch entityhEntHatch = lcBlockGetEntByKey( hBlock, Key );dx = 30.0;dy = 15.0;// get hatch outlinesnPaths = lcPropGetInt( hEntHatch, LC_PROP_HATCH_NLOOP );k = 0;for (i=0; i<nPaths; ++i){// create a polyline which will be a copy of the hatch outlinehPline = lcBlockAddPolyline( hBlock, 0, true, false );// get outline verticesn = lcHatchGetLoopSize( hEntHatch, i );for (j=0; j<n; ++j) {lcHatchGetPoint( hEntHatch, k, &x, &y );++k;// add vertex to the polylinelcPlineAddVer( hPline, 0, x+dx, y+dy );}lcPlineEnd( hPline );// set red color for the polylinelcPropPutInt( hPline, LC_PROP_ENT_COLOR, RGB(255,0,0) );}lcBlockUpdate( hBlock, true, 0 );// view drawing's extentslcWndZoomRect( hLcWnd, 0, 0, 0, 0 );
}


lcHatchGetEnt:Retrieves boundary entities of associative hatch.
HANDLE lcHatchGetEnt (HANDLE hEntHatch,int Mode);
Parameters:
hEntHatch(Handle to a hatch object.);Mode(0 - first entity,1 - next entity).

void DemoGetHatchEnts (HANDLE hLcWnd)
{int    Key = 123;   // required hatch entity is marked with this key valueint    NumEnts;HANDLE hBlock, hEnt, hEntHatch;BOOL   bAssoc;// get a block, linked with CAD windowhBlock = lcPropGetHandle( hLcWnd, LC_PROP_WND_VIEWBLOCK );// find required hatch by user-defined keyhEntHatch = lcBlockGetEntByKey( hBlock, Key );if (hEntHatch){// check if the hatch is associativebAssoc = lcPropGetBool( hEntHatch, LC_PROP_HATCH_ASSOC );if (bAssoc){// get number of boundary entitiesNumEnts = lcPropGetInt( hEntHatch, LC_PROP_HATCH_NENTS );// get first entity of hatch boundaryhEnt = lcHatchGetEnt( hEntHatch, 0 );  while( hEnt ){// set red color for the entitylcPropPutInt( hEnt, LC_PROP_ENT_COLOR, RGB(255,0,0) );// get next entity of hatch boundaryhEnt = lcHatchGetEnt( hEntHatch, 1 );  }lcWndRedraw( hLcWnd );}}
}

八、Dimension

1.Dimension Linear (rotated)

A linear dimension with a horizontal, vertical, or rotated dimension line.
Add linear dimension: HANDLE lcBlockAddDimLin (HANDLE hBlock,double X0,double Y0,double X1,double Y1,double Xt,double Yt,double Angle,LPCWSTR szText);
Parameters:
hBlock(Handle to a block.);X0 Y0(First definition point.);X1 Y1(Second definition point.);Xt Yt(Text and dimension line position.);Angle(Rotation angle.);szText(User-supplied dimension text.If no text is to appear, supply “.” .If only the default text is to appear, supply an empty string “”.The default text is represented as “<>” within the supplied text.).
Return Value:
Handle to created rotated dimension object or NULL if the function fails.

2.Dimension Aligned

In aligned dimensions, the dimension line is parallel to the extension line origins.

3.Dimension Angular

Angular dimensions measure the angle between two lines or three points.

4.Dimension Radial

Measures the radius of an arc or circle, and displays the dimension text with the letter R in front of it.

5.Dimension Diametric

Measures the diameter of an arc or circle, and displays the dimension text with the diameter symbol in front of it.

6.Dimension Ordinate

Ordinate dimensions measure the perpendicular distance from an origin point called the datum to a feature, such as a hole in a part. These dimensions prevent escalating errors by maintaining accurate offsets of the features from the datum.

Create dimensions

void DemoDims (HANDLE hLcWnd)
{HANDLE hBlock, hEnt;WCHAR* szColor = L"200,150,50";// get a block linked to graphics windowhBlock = lcPropGetHandle( hLcWnd, LC_PROP_WND_BLOCK );// linear dimensionslcBlockAddDimLin( hBlock, 0,0, 30,20, 15,40, 10*LC_DEG_TO_RAD, L"L=<>" );lcBlockAddDimLin( hBlock, 0,0, 30,20, 40,10, 95*LC_DEG_TO_RAD, L"" );lcBlockAddDimHor( hBlock, 100,0, 130,20, 40, L"L=<>" );lcBlockAddDimVer( hBlock, 100,0, 130,20, 140, L"" );// aligned dimensionslcBlockAddDimAli( hBlock, 0,0, 30,20, 0,50, L"" );lcBlockAddDimAli2( hBlock, 100,0, 130,20, 20, L"" );// ordinate dimensionslcBlockAddDimOrd( hBlock, 40,30, 35,50, true, L"X=<>" );lcBlockAddDimOrd( hBlock, 40,30, 60,35, false, L"Y=<>" );// additional entitieshEnt = lcBlockAddArc( hBlock, 70,50, 20, -30*LC_DEG_TO_RAD, 90*LC_DEG_TO_RAD );lcPropPutStr( hEnt, LC_PROP_ENT_COLOR, szColor );lcPropPutBool( hEnt, LC_PROP_ARC_SECTOR, true );hEnt = lcBlockAddArc( hBlock, 70,50, 28.284, -110*LC_DEG_TO_RAD, 200*LC_DEG_TO_RAD );lcPropPutStr( hEnt, LC_PROP_ENT_COLOR, szColor );hEnt = lcBlockAddCircle( hBlock, 170,50, 20, false );lcPropPutStr( hEnt, LC_PROP_ENT_COLOR, szColor );// radius  dimensionslcBlockAddDimRad( hBlock, 70,50, 90,50, 100,50, L"" );lcBlockAddDimRad2( hBlock, 170,50, 20,-30*LC_DEG_TO_RAD, 10, L"" );// diameter dimensionslcBlockAddDimDia( hBlock, 70,50, 90,70, 80,100, L"" );lcBlockAddDimDia2( hBlock, 170,50, 20,30*LC_DEG_TO_RAD, 30, L"" );// angular dimensionslcBlockAddDimAng( hBlock, 0,100, 10,100, 0,110, 20,101, 0.5, L"" );lcBlockAddDimAng( hBlock, 0,100, 10,98, 10,100, 23,99.9, -2, L"" );lcBlockAddDimAng2( hBlock, 50,100, 60,100, 50,110, 60,111, 70,100, 0.5, L"" );// update viewlcBlockUpdate( hBlock, false, 0 );lcWndExeCommand( hLcWnd, LC_CMD_ZOOM_EXT, 0 );
}


Dimension Style
A Dimension Style defines the appearance of a dimension entities. When you create a new drawing it already has the “Standard” dimension style by default. New dimension entities are added to a drawing using the current dimension style.
Type of arrows:This are types of arrowheads used in dimension style.

九、Leader

A leader object is a line with an arrowhead at one end and a multiline text object at the other.
In some cases, a short horizontal line, called a landing, connects text and feature control frames to the leader line. The landing and leader line are associated with the multiline text object, so when the landing is relocated, the content
and leader line move along with it.

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

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

    LiteCAD API reference 一.Command Interface Almost all functionality can be accessed via the lcWndExeC ...

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

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

  3. GNU sed 4.5 版参考文档全文翻译 各命令和随带20个示例详细解析(四)

    GNU sed 流编辑器 GNU sed 一个流编辑器(四) 5. 正则表达式:选择文本 5.1 sed正则表达式摘要 5.2 基础正则表达式和扩展正则表达式 5.3 基础正则表达式语法摘要 5.4 ...

  4. Spring Boot 3.0.0-M1 Reference Documentation(Spring Boot中文参考文档) 9-16

    9. 数据 Spring Boot与多个数据技术集成,包括SQL和NoSQL. 9.1. SQL数据库 Spring Framework提供扩展支持用于与SQL数据工作,从使用JdbcTemplate ...

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

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

  6. 面向开放域密集检索多视图文档表示学习,微软提出​MVR,性能SOTA!(ACL 2022)...

    关注公众号,发现CV技术之美 本文分享 ACL 2022 论文『Multi-View Document Representation Learning for Open-Domain Dense Re ...

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

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

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

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

  9. 刷新4项文档智能任务纪录,百度TextMind打造ERNIE-Layout登顶文档智能权威榜单

    来源:机器之心本文约2300字,建议阅读5分钟 文档智能国际权威榜单文档视觉问答 DocVQA 迎来了新霸主. 百度提出跨模态文档理解模型 ERNIE-Layout,首次将布局知识增强技术融入跨模态文 ...

最新文章

  1. 实验四 主存空间的分配和回收
  2. CentOS7.4下DNS服务器软件BIND安装及相关的配置(一)
  3. Go 初体验 - 令人惊叹的语法 - defer.3 - defer 函数参数计算时机
  4. java父线程子线程
  5. 三菱变频器e700参数表_三菱Q系列PLC,用CCLink控制变频器正反转和多段速
  6. 利用css布局效果图
  7. 担忧医生因AI技术而失业?杞人忧天
  8. [置顶]动态网页开发基础【笔记】
  9. nginx反向代理配置实例分享
  10. 信息学奥赛一本通(1049:晶晶赴约会)
  11. Prepo —— 图标转化器
  12. Python: 自定义类对象序列化为Json串
  13. MySQL 基础 —— 数据类型、各种变量
  14. Vue项目需求实现记录总目录(永久更新)
  15. 海南工会云会员认证_“网上工会”大普惠全面升级 全体会员共享生活大福利...
  16. JAVA实现SHA256算法
  17. 串口硬盘如何应用于并口硬盘计算机,并口硬盘和串口硬盘如何一起用
  18. android toast居中显示_Android Toast 设置到屏幕中间,自定义Toast的实现方法,及其说明...
  19. Cfree5可以JAVA_Free C++ (and C)
  20. angular中自定义webpack配置

热门文章

  1. 10份可直接套用的华为项目管理模板
  2. 搭建社群积分系统,使用这个工具足以
  3. 不要被假相迷惑-有意思的声卡驱动
  4. 网络数据帧中的(Jumbo Frame)巨帧、超长帧
  5. 发那科机器人plc电池_FANUC机器人维修保养故障简析
  6. UVA - 1103:Ancient Messages
  7. 【MATLAB】基本绘图 ( plot 函数绘制多个图形 | legend 函数标注图形 | 图形修饰 )
  8. 平台服务器的配置信息失败,安装程序配置服务器失败-安装程序配置服务器失败.参考服务器错误日志和Cwindowssqlstp.log了解更多信息...
  9. VBA 2000年之后活期存款利息计算
  10. 【Crow】一款开源C++Web框架的安装与构建