Você está na página 1de 36

Initialization

Home

These are the functions:


Function

Meaning

lcInitialize

Performs LiteCAD system initialization

lcUninitialize

Performs LiteCAD system uninitialization

lcInitialize

Home

Performs LiteCAD initialization. This function should be called once at the start of your
application. Global properties can be set before lcInitialize.

BOOL lcInitialize ();


Parameters
None.

Return Value
If the function succeeds, the return value is nonzero (TRUE).

See Also
lcUninitialize

lcUninitialize
Performs LiteCAD uninitialization. This function should be called once as the last
operation performed by LiteCAD.

BOOL lcUninitialize (
BOOL bSaveConfig
);
Parameters
bSaveConfig

If TRUE, then LiteCAD will save current system configuration into the
LC_PROP_G_DIRCFG directory.

Return Value
If the function succeeds, the return value is nonzero (TRUE).

See Also
lcInitialize

Home

Access Objects Properties

Home

LiteCAD objects property can be one of the following types:


- Boolean (true or false),
- Integer (32 or 64 bit, depends on Windows bits),
- Float (64-bit double float),
- String (Unicode, 16 bit per character),
- Handle (32 or 64 bit pointer, depends on Windows bits)
There are a set of functions to read/write objects properties, depend on the type:
Function

Meaning

lcPropGetBool

Returns a property's value of boolean type

lcPropGetInt

Returns a property's value of integer type

lcPropGetFloat

Returns a property's value of floating type

lcPropGetStr

Returns a property's value of string type

lcPropGetHandle

Returns a property's value of handle type (pointer)

lcPropPutBool

Sets a property's value of boolean type

lcPropPutInt

Sets a property's value of integer type

lcPropPutFloat

Sets a property's value of floating type

lcPropPutStr

Sets a property's value of string type

lcPropPutHandle

Sets a property's value of handle type (pointer)

Each property has a symbolic name, written with template


LC_PROP_object_propname, where object - object name, and the propname is a
property name, for example:
LC_PROP_LAYER_NAME - layer name
it has type "String", therefore, in order to set layer name you have to call:
lcPropPutStr (hLayer, LC_PROP_LAYER_NAME, szName);
Some properties have more then one type, for example, you can set active layer either
by its name or by handle:
lcPropPutStr (hDrw, LC_PROP_DRW_LAYER, L"Streets" );
lcPropPutHandle (hDrw, LC_PROP_DRW_LAYER, hLayer);
Code sample:
bool bRulers;
int Size;
double X, Y;
WCHAR szFileName[256];
COLORREF Color;
// read properties
bRulers = lcPropGetBool( hLcWnd, LC_PROP_WND_RULERS );
wcscpy( szFileName, lcPropGetStr( hImage, LC_PROP_IMAGE_FILENAME ) );
Size = lcPropGetInt( 0, LC_PROP_G_GRIPSIZE );
Color = lcPropGetInt( 0, LC_PROP_G_GRIPCOLOR );
X = lcPropGetFloat( hLcWnd, LC_PROP_WND_CURSORX );

Y = lcPropGetFloat( hLcWnd, LC_PROP_WND_CURSORX );


// write properties
lcPropPutInt( hLcWnd, LC_PROP_WND_COLORBG, RGB(0,0,0) );
lcPropPutInt( hLcWnd, LC_PROP_WND_COLORCURSOR, RGB(255,255,255) );
lcPropPutBool( 0, LC_PROP_G_SAVECFG, true );
lcPropPutInt( hLcWnd, LC_PROP_WND_LWMODE, LC_LW_PIXEL );
lcPropPutFloat( hLcWnd, LC_PROP_WND_LWSCALE, 0.2 );
lcPropPutStr( 0, LC_PROP_G_DLGVAL, szFileName );

Global properties

Home

LiteCAD system variables are global properties, therefore in the lcProp... functions use
NULL for the hObject parameter.
Global properties can be set/get before calling of lcInitialize function.

Type

Ac
ces
s

Meaning

LC_PROP_G_REGCODE

string

Registration code

LC_PROP_G_VERSION

string

LiteCAD version

LC_PROP_G_MSGTITLE

string

RW

title for messages (default


"LiteCAD")

LC_PROP_G_HELPFILE

string

RW

Name of help file


("Litecad.chm" by default)

LC_PROP_G_DIRDLL

string

Directory of running
Litecad.dll module

RW

Directory of font files (*.lcf),


by default
<LC_PROP_G_DIRDLL>\Font
s

RW

Directory of language files


(*.lng), by default
<LC_PROP_G_DIRDLL>\Conf
ig

RW

Directory of drawing's
templates (*.lcd), by default
<LC_PROP_G_DIRDLL>\Tem
plates

Property

LC_PROP_G_DIRFONTS

LC_PROP_G_DIRLNG

LC_PROP_G_DIRTPL

string

string

string

LC_PROP_G_DIRCFG

string

RW

Directory of config files (the


directory must have write
permit), by default
<LC_PROP_G_DIRDLL>\Conf
ig

LC_PROP_G_SAVECFG

bool

RW

Determines whether to save


configuration or not

LC_PROP_G_ICON16

handle
string

RW
W

Handle to icon for LiteCAD


dialogs (size 16x16)
Icon filename

LC_PROP_G_ICON32

handle
string

RW
W

Handle to icon for LiteCAD


dialogs (size 32x32)
Icon filename

LC_PROP_G_RULERBMP

handle

LC_PROP_G_DLGVAL

string

RW

Dialog value for


lcDgGetValue function

LC_PROP_G_PRNUSEBMP

bool

RW

Use bitmap for printing

LC_PROP_G_PRNBMPFILE

string

RW

File to save the print bitmap

RW

Meaning of negative
PointSize parameter, if TRUE
- size in pixels, FALSE - % of
window height

LC_PROP_G_PNTPIXSIZE

bool

Handle to bitmap bitmap for


rulers corner

LC_PROP_G_GETDELENT

bool

RW

Controls if lcBlockGetEnt...
functions will retrieve
deleted entities or not

LC_PROP_G_SOLIDBARC

bool

RW

If TRUE, then creates


barcode with solid filling by
default

LC_PROP_G_FILEPROGRES
S

bool

RW

Display progress box during


file load/save

LC_PROP_G_GBRBMPFILE

string

RW

Filename of bitmap for


Gerber file

LC_PROP_G_PICKADD

bool

RW

Controls whether subsequent


selections replace the current
selection set or add to

LC_PROP_G_PICKBYRECT

bool

RW

Implied windowing for


objects selection (AutoCAD
PICKAUTO)

LC_PROP_G_PICKDRAG

bool

RW

Selection Rect: Press and


Drag (same as AutoCAD
PICKDRAG system variable)

LC_PROP_G_PICKBOXSIZE

int

RW

Half-size of selecting square,


in pixels

LC_PROP_G_GRIPSIZE

int

RW

Size of grip square, in pixels

LC_PROP_G_GRIPCOLORF

int

RW

Grips filling color


(COLORREF)

LC_PROP_G_GRIPCOLORB

int

RW

Grips border color


(COLORREF)

LC_PROP_G_CAMERA_COU
NT

int

RW

Number of camera devices

LC_PROP_G_CAMERA_I

int

RW

Set camera index

LC_PROP_G_CAMERA_NA
ME

string

Name of camera by index


(LC_PROP_G_CAMERA_I)

LC_PROP_G_CAMERA_ON

bool

TRUE if camera is connected

LC_PROP_G_CAMERA_TIM
E

int

RW

Interval between camera


shots (msec)

LC_PROP_G_CAMERA_WID
TH

int

Width of camera image


(pixels)

LC_PROP_G_CAMERA_HEI
GHT

int

Height of camera image


(pixels)

LC_PROP_G_CAMERA_BIT
S

handle
int

Pointer to image bits

LC_PROP_G_CAMERA_BPR
OW

int

Bytes per row

LC_PROP_G_WF_LEFT

float

RW

Work field Xmin

LC_PROP_G_WF_BOTTOM

float

RW

Work field Ymin

LC_PROP_G_WF_WIDTH

float

RW

Work field width

LC_PROP_G_WF_HEIGHT

float

RW

Work field height

LC_PROP_G_WF_HIDE

bool

RW

Hide cliprects when not


active

Drawing database

Home

The LiteCAD drawing object is the internal database representing a drawing. The
database contains graphical objects (entities) and non-graphical (named objects). You
must create at least one instance of a drawing object in your application. You can load a
file into a drawing object or create a drawing programmatically. To view and
interactively edit a drawing, an application must link it with a LiteCAD design window.
When you are finished working with a drawing object you must delete its handle to free
system memory allocated to it.
These are the functions used to manage LiteCAD drawing object:
Function

Meaning

lcCreateDrawing

Creates empty drawing object and returns its


handle

lcDeleteDrawing

Deletes the drawing object

lcDrwNew

Clears a drawing into initial state

lcDrwLoad

Loads a drawing's data from a file

lcDrwLoadMem

Loads a drawing's data from a memory buffer

lcDrwInsert

Inserts other drawing into current drawing

lcDrwCopy

Copies a drawing

lcDrwSave

Saves a drawing's data into a file

lcDrwSaveMem

Saves a drawing's data into a memory buffer

Named objects
lcDrwAddLayer

Adds a new layer into a drawing

lcDrwAddLinetype

Adds a new linetype into a drawing

lcDrwAddLinetypeF

Adds a new linetype into a drawing

lcDrwAddTextStyle

Adds a new text style into a drawing

lcDrwAddDimStyle

Adds a new dimension style into a drawing

lcDrwAddPntStyle

Adds a new point style into a drawing

lcDrwAddImage
lcDrwAddImage2
lcDrwAddImage3

Adds a new image into a drawing

lcDrwAddBlock

Adds a new block into a drawing

lcDrwAddBlockFromDrw

Adds a block into a drawing from other drawing

lcDrwAddBlockFromFile

Adds a block into a drawing from other


drawing's file

lcDrwAddBlockFile

Adds entire drawing from a file as one block

lcDrwAddBlockPaper

Adds "Paper space" type block

lcDrwAddBlockCopy

Adds a new block into a drawing as a clone of


exist block

lcDrwDeleteObject

Deletes an object from a drawing

lcDrwCountObjects

Counts a number of named objects, by type

lcDrwSortObjects

Sort named objects by


LC_PROP_TABLE_PRIORITY

Retrieve objects
lcDrwGetFirstObject
lcDrwGetNextObject

Used to sequentially retrieve all named objects

lcDrwGetObjectByName

Retrieves an object by its name

lcDrwGetObjectByID
lcDrwGetObjectByIDH

Retrieves named object by its identifier

lcDrwGetEntByID
lcDrwGetEntByIDH

Retrieves a graphic objects by its identifier

lcDrwGetEntByKey

Retrieves a graphic object by its key value

Other
lcDrwPurge

Clears a drawing database from "deleted"


objects

lcDrwClearXData

Clears a drawing's extra data

lcDrwExplode

Explodes all entities to simpler type

lcDrwSetLimits

Defines max limits (used for view)

lcDrwUndoRecord

Saves operations in Undo buffer

lcDrwUndo

Performs Undo or Redo operation

Graphic objects are contained in blocks, therefore, in order to add graphics into a

drawing, you have to add it into specified block.


Drawing object has the following properties:
Type

Acce
ss

Meaning

LC_PROP_DRW_UID

string

Unique Identifier of a
drawing

LC_PROP_DRW_FILENAME

string

RW

Drawing's filename

LC_PROP_DRW_DESCR
LC_PROP_DRW_COMMENT

string

RW

Drawing's description

LC_PROP_DRW_READONLY

bool

RW

"ReadOnly" flag

LC_PROP_DRW_DIRTY

bool

RW

"Drawing was
modified" flag

Property

LC_PROP_DRW_IDMAX

int
string

Maximal value of
object identifier
Hexadecimal string
(up to 16 characters)

LC_PROP_DRW_SYNCZOOM

bool

RW

"Synchronize Layouts
Zoom" flag

TRUE if any entity


uses alpha blend
(semi-transparent
filling)

LC_PROP_DRW_HASALPHABLE
ND

bool

Background, foreground and cursor colors

LC_PROP_DRW_COLORBACKM

int

RW

Model Space window


background color
(COLORREF)

LC_PROP_DRW_COLORBACKP

int

RW

Paper Space window


background color
(COLORREF)

LC_PROP_DRW_COLORFOREM

int

RW

Model Space
foreground color
(COLORREF)

LC_PROP_DRW_COLORFOREP

int

RW

Paper Space
foreground color
(COLORREF)

LC_PROP_DRW_COLORCURSOR
M

int

RW

Model Space cursor


color (COLORREF)

LC_PROP_DRW_COLORCURSOR
P

int

RW

Paper Space cursor


color (COLORREF)

LC_PROP_DRW_COLORPAPER

int

RW

Paper Space sheet


color (COLORREF)

Active objects and parameters, used on creating new entities


LC_PROP_DRW_LAYER

handle
string

RW

Handle to active layer


Name of active layer

LC_PROP_DRW_LINETYPE

handle
string

RW

Handle to active
linetype
Name of active
linetype

LC_PROP_DRW_LTSCALE

float

RW

Current linetype scale

LC_PROP_DRW_TEXTSTYLE

handle
string

RW

Handle to active text


style
Name of active text
style

LC_PROP_DRW_PNTSTYLE

handle
string

RW

Handle to active point


style
Name of active point
style

LC_PROP_DRW_DIMSTYLE

handle
string

RW

Handle to active
dimension style
Name of active
dimension style

LC_PROP_DRW_BLOCK

handle
string

RW

Handle to active block


Name of active block

LC_PROP_DRW_FILLING

handle
string

RW

Handle to active filling


Name of active filling

LC_PROP_DRW_BARTYPE

int

RW

Active barcode type

LC_PROP_DRW_LWMODE

int

RW

"Display linewidth"
flag

LC_PROP_DRW_LWIDTH

int

RW

Current linewidth
mode (LC_LW_THIN,
LC_LW_REAL,
LC_LW_PIXEL)

LC_PROP_DRW_LWDEFAULT

int

RW

Default linewidth (for


linewidth==LC_LWID
TH_DEFAULT)

int

RW

Linewidth screen
scale, mm / pixel
(used to display
linewidth
LC_LW_PIXEL mode)

LC_PROP_DRW_COLOR

string

RW

Active color

LC_PROP_DRW_COLORBYLAYE
R

bool

RW

Color "ByLayer"

LC_PROP_DRW_COLORBYBLOC
K

bool

RW

Color "ByBlock"

LC_PROP_DRW_COLORI

int
bool

RW
R

Color Index (1..255)


TRUE if the color is
index

LC_PROP_DRW_COLORT

int
bool

RW
R

True Color
(COLORREF)
TRUE if the color is
RGB

LC_PROP_DRW_FCOLOR

string

RW

Active filling color

LC_PROP_DRW_FCOLORBYLAY
ER

bool

RW

Filling color "ByLayer"

LC_PROP_DRW_FCOLORBYBLO
CK

bool

RW

Filling color "ByBlock"

LC_PROP_DRW_FCOLORI

int
bool

RW
R

Color Index (1..255)


TRUE if the color is
index

LC_PROP_DRW_FCOLORT

int
bool

RW
R

True Color
(COLORREF)
TRUE if the color is
RGB

LC_PROP_DRW_SELPENMODE

int

RW

LC_SELPEN_COLOR or
LC_SELPEN_BYENT

LC_PROP_DRW_SELCOLOR

int

RW

LC_PROP_DRW_LWSCALE

Active outline color

Active fill color

Selection

Color of selected
entities (for
LC_SELPEN_COLOR

mode)

LC_PROP_DRW_SELCOLOR2

int

RW

Back color of selected


entities (for
LC_SELPEN_COLOR
mode)

LC_PROP_DRW_SELBYLAYER

bool

RW

Select entities only on


active layer

LC_PROP_DRW_SELINPGON

bool

RW

Select polygons by
click on inner area

LC_PROP_DRW_SELINPGONF

bool

RW

LC_PROP_DRW_SELI
NPGON works only for
filled polygons

LC_PROP_DRW_SELINIMG

bool

RW

Select images by click


on inner area

LC_PROP_DRW_LOCKSEL

bool

RW

"Enable selection on
locked layers" flag

bool

RW

Enable/disable grips

Grips
LC_PROP_DRW_ENABLEGRIPS

LC_PROP_DRW_GRIPSLIMIT

int

RW

Max number of
selected entities to
display grips

LC_PROP_DRW_GRIPCOLORF

int

RW

Color of grip filling

LC_PROP_DRW_GRIPCOLORB

int

RW

Color of grip border

bool

RW

Enable exploding of
arcs, circles, ellipses

Explode options
LC_PROP_DRW_EXPLODEARC

LC_PROP_DRW_EXPPLINELA

bool

RW

Explode bulge
polylines: TRUE-to
lines and arcs, FALSEto lines

LC_PROP_DRW_EXPSIMPLINE

bool

RW

Enable exploding
simple polylines (to
lines)

LC_PROP_DRW_EXPTEXTSPLIN
E

bool

RW

If TRUE - explode
TrueType text to
splines, FALSE - to

polylines

Default named objects


LC_PROP_DRW_BLOCK_MODEL

handle

Handle to "Model
Space" block

LC_PROP_DRW_LAYER_0

handle

Handle to layer "0"

LC_PROP_DRW_LINETYPE_CON
T

handle

Handle to linetype
"Continuous"

LC_PROP_DRW_LINETYPE_BYL
AY

handle

Handle to linetype
"ByLayer"

LC_PROP_DRW_LINETYPE_BYB
LK

handle

Handle to linetype
"ByBlock"

LC_PROP_DRW_TEXTSTYLE_ST
D

handle

Handle to text style


"Standard"

LC_PROP_DRW_PNTSTYLE_STD

handle

Handle to point style


"Standard"

LC_PROP_DRW_DIMSTYLE_STD

handle

Handle to dimension
style "Standard"

LC_PROP_DRW_FILL_NONE

handle

Handle to filling type


"None"

LC_PROP_DRW_FILL_SOLID

handle

Handle to filling type


"Solid"

LC_PROP_DRW_RESOLARC

int

RW

Default resolution for


arc/circle/ellipse/bul
ge

LC_PROP_DRW_RESOLSPLINE

int

RW

Default resolution for


splines

LC_PROP_DRW_RESOLTEXT

int

RW

Default resolution for


TTF text

float

RW

Default resolution

View limits
LC_PROP_DRW_LIM_MIXPIXSI
ZE

Minimal pixel size


(drawing units).
Denines Zoom-In

limit. By default 0.001

LC_PROP_DRW_LIM_MAXLEF

float

RW

Xmin of limits
rectangle (see also
lcDrwSetLimits)

LC_PROP_DRW_LIM_MAXBOT

float

RW

Ymin of limits
rectangle

LC_PROP_DRW_LIM_MAXRIG

float

RW

Xmax of limits
rectangle

LC_PROP_DRW_LIM_MAXTOP

float

RW

Ymax of limits
rectangle

LC_PROP_DRW_LIM_MAXON

bool

RW

Enable maximal view


limits (for Zoom-Out)

int

RW

User integer variables

float

RW

User float variables

string

RW

User text variables

LC_PROP_DRW_XDATASIZE

int

RW

Size of extra data


(bytes)

LC_PROP_DRW_XDATA

handle

RW

Pointer to extra data

User specific data


LC_PROP_DRW_INT0
...
LC_PROP_DRW_INT9
LC_PROP_DRW_FLOAT0
...
LC_PROP_DRW_FLOAT9
LC_PROP_DRW_STR0
...
LC_PROP_DRW_STR9

Named objects

Home

LiteCAD drawing files contain 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.
Named object

Description

Block

Contains the block name, base point, and component


objects.

Layer

Organizes graphical data in the same way that transparent


acetate overlays on a drawing do; the layer stores the
properties that you set for it, such as color and linetype

Linetype

Stores information that controls how a line or curve is


displayed... for example, whether the line is continuous or
dashed.

Text style

Stores settings that control the appearance of text


characters... for example, stretched, compressed, oblique,
mirrored, or set in a vertical column.

Point style

Stores settings that control the appearance of point


objects.

Dimension
style

Stores dimension settings that control the appearance of


dimension annotation.

Raster image

Stores raster image settings that control the appearance


of image reference objects.

Filling

Stores settings that control the appearance of inside area


of closed entities.

Each named object has the following properties:


Access

Meaning

LC_PROP_TABLE_ID

int
string

Unique Identifier
Hexadecimal string (up
to 16 characters)

LC_PROP_TABLE_NAME

string

RW

Table Name

LC_PROP_TABLE_DESCR

string

RW

Table description

LC_PROP_TABLE_TYPE

int

Type of named object

Property

Type

LC_PROP_TABLE_DELETED

bool

"Deleted" flag

LC_PROP_TABLE_DRW

handle

Handle to owner
drawing

LC_PROP_TABLE_PRIORITY

int

RW

Priority value, used for


sorting
(lcDrwSortObjects)

LC_PROP_TABLE_NREFS

int

A number of references
to the object

LC_PROP_TABLE_XDATASIZE

int

RW

Size of extra data


(bytes)

LC_PROP_TABLE_XDATA

handle

RW

Pointer to extra data

LC_PROP_TABLE_XSTR

string

RW

User text variable (uses


XDATA buffer)

LC_PROP_TABLE_INT0
...

int

RW

User integer variables

float

RW

User float variables

User specific data

LC_PROP_TABLE_INT4
LC_PROP_TABLE_FLOAT0
...
LC_PROP_TABLE_FLOAT4

See also
Retrieve objects

Entities (graphic objects)

Home

Entities are visible graphical objects (lines, circles, raster images, and so on) that make
up a drawing. Graphical objects have typical properties such as Identifier, Layer,
Linetype, Color, etc. They also have specific properties, depending on their object type,
such as, Center, Radius, and Area.

LiteCAD supports the following types of entities:


Type

LC_PROP_ENT_TYPE value

Point

LC_ENT_POINT

Construction Line

LC_ENT_XLINE

Line

LC_ENT_LINE

Polyline

LC_ENT_POLYLINE

Rectangle

LC_ENT_RECT

Circle

LC_ENT_CIRCLE

Arc

LC_ENT_ARC

Ellipse

LC_ENT_ELLIPSE

Text

LC_ENT_TEXT

Arc Text

LC_ENT_ARCTEXT

Multiline Text

LC_ENT_MTEXT

Block reference

LC_ENT_BLOCKREF

Raster image reference

LC_ENT_IMAGEREF

ECW / Jpeg2000 Image

LC_ENT_ECW

Hatch

LC_ENT_HATCH

Dimension Rotated

LC_ENT_DIMROT

Dimension Aligned

LC_ENT_DIMALI

Dimension Ordinate

LC_ENT_DIMORD

Dimension Radial

LC_ENT_DIMRAD

Dimension Diametric

LC_ENT_DIMDIA

Dimension Angular

LC_ENT_DIMANG

Leader

LC_ENT_LEADER

Viewport

LC_ENT_VIEWPORT

Barcode

LC_ENT_BARCODE

Camera view

LC_ENT_CAMERA

Entities are contained in blocks, therefore, in order to add graphics into a drawing, you
have to add it into specified block.
Each entity has the following properties:
Type

Access

Meaning

LC_PROP_ENT_TYPE

int

Type of graphic
object (see above)

LC_PROP_ENT_ID

int
string

Unique Identifier
Hexadecimal string
(up to 16
characters)

LC_PROP_ENT_KEY

int

RW

User value

LC_PROP_ENT_BLOCK

handle
string

Handle to owner
Block
Name of owner
Block

LC_PROP_ENT_DRW

handle

Handle to owner
Drawing

LC_PROP_ENT_LAYER

handle
string

RW

Handle to Layer
Name of Layer

LC_PROP_ENT_LINETYPE

handle
string

RW

Handle to Linetype
Name of Linetype

LC_PROP_ENT_LTSCALE

float

RW

Linetype scale

LC_PROP_ENT_LWIDTH

int

RW

Linewidth

int
string

RW

Priority value, used


for sorting
(lcBlockSortEnts)
Integer or string
(hexadecimal, up to
16 characters)

string
int

RW
RW

Color name
RGB value
(COLORREF)

Property

LC_PROP_ENT_PRIORITY

Outline Color

LC_PROP_ENT_COLOR

LC_PROP_ENT_COLORI

int
bool

RW
R

Color Index (1..255)


TRUE if the color is
index

LC_PROP_ENT_COLORT

int
bool

RW
R

True Color
(COLORREF)
TRUE if the color is
RGB

LC_PROP_ENT_COLORBYLAYER

bool

RW

Color "ByLayer"

LC_PROP_ENT_COLORBYBLOCK

bool

RW

Color "ByBlock"

LC_PROP_ENT_FILLING

handle
string

RW
RW

Handle to filling type


Name of filling type

LC_PROP_ENT_FILLED

bool

"Entity has filling"


flag

LC_PROP_ENT_SOLIDFILL

bool

RW

"Entity has solid


filling" flag

LC_PROP_ENT_FCOLOR

string
int

RW
RW

Filling Color name


RGB value
(COLORREF)

LC_PROP_ENT_FCOLORI

int
bool

RW
R

Filling color Index


(1..255)
TRUE if the color is
index

Entity filling (for closed entities)

LC_PROP_ENT_FCOLORT

int
bool

RW
R

Filling True Color


(COLORREF)
TRUE if the color is
RGB

LC_PROP_ENT_FCOLORBYLAYER

bool

RW

Filling Color
"ByLayer"

LC_PROP_ENT_FCOLORBYBLOCK

bool

RW

Filling Color
"ByBlock"

LC_PROP_ENT_FALPHA

int

RW

Alpha value
(1..255), for semitransparent filling

bool

"ReadOnly" flag
(depends on a layer)

Flags
LC_PROP_ENT_LOCKED

LC_PROP_ENT_VISIBLE

bool

"Visible" flag
(depends on a layer)

LC_PROP_ENT_HIDDEN

bool

RW

"Hidden" flag

LC_PROP_ENT_DELETED

bool

RW

"Deleted" flag

LC_PROP_ENT_IMMORTAL

bool

RW

"Can not be deleted"


flag

LC_PROP_ENT_SELECTED

bool

"Selected" flag

LC_PROP_ENT_XMIN

float

X min

LC_PROP_ENT_YMIN

float

Y min

LC_PROP_ENT_XMAX

float

X max

LC_PROP_ENT_YMAX

float

Y max

LC_PROP_ENT_XCEN

float

Center X

LC_PROP_ENT_YCEN

float

Center Y

LC_PROP_ENT_Z

float

RW

Z-coordinate

LC_PROP_ENT_XDATASIZE

int

RW

Size of extra data


(bytes)

LC_PROP_ENT_XDATA

handle

RW

Pointer to extra data

LC_PROP_ENT_XSTR

string

RW

Text variable (uses


XDATA buffer)

Geometric extents

Custom Data

Each entity has more properties, specific to the entity's type.


Graphic objects functions
Function

Meaning

lcEntErase

Erases / Unerases object

lcEntMove

Moves object

lcEntScale

Scales object

lcEntRotate

Rotates object

lcEntMirror

Mirrors object

lcEntExplode

Explodes object

lcEntOffset

Offsets object

lcEntToTop
lcEntToBottom
lcEntToAbove
lcEntToUnder

Changes object's draw order

lcEntGetGrip

Retrieves coordinates of object's control point

lcEntPutGrip

Sets new coordinates for object's control point

lcEntUpdate

Updates entoty

lcEntCopyBase

Copies base properties from other entity

lcIntersection

Searches intersection points of 2 graphic objects

See also
Retrieve objects

Retrieve objects

Home

LiteCAD drawing contains a named objects as a layer, linetype, text style, etc. and a
graphics objects, as a line, polyline, arc, text, etc.
There are several functions intended to find required object.
Retrieve named objects

Function

Meaning

lcDrwGetFirstObject
lcDrwGetNextObject

Used to sequentially retrieve all objects

lcDrwGetObjectByName

Retrieves an object by its name

lcDrwGetObjectByID
lcDrwGetObjectByIDH

Retrieves a named object by its identifier

Retrieve graphic objects


Function

Meaning

lcDrwGetEntByID
lcDrwGetEntByIDH

Retrieves an entity by its identifier

lcDrwGetEntByKey

Retrieves a graphic object by its key value

lcWndGetEntByID
lcWndGetEntByIDH

Retrieves an entity by its identifier

lcWndGetEntByKey

Retrieves a graphic object by its key value

lcBlockGetFirstEnt
lcBlockGetNextEnt
lcBlockGetLastEnt
lcBlockGetPrevEnt

Used to sequentially retrieve all entities from a


block

lcBlockGetEntByID
lcBlockGetEntByIDH

Retrieves an entity by its identifier

lcBlockGetEntByKey

Retrieves an entity by its key value

lcBlockGetFirstSel
lcBlockGetNextSel

Used to sequentially retrieve all selected entities


from a block

Locate by position
lcWndGetEntByPoint

Retrieves one entity by window point

lcWndGetEntByPoint2

Gets one entity at specified position

lcWndGetEntsByRect

Gets an array of entities by specified rectangle

lcWndGetEntity

Returns a handle to entity in the array

Graphics window

Home

The LiteCAD graphics window is used to display and edit graphics data contained in the
drawing object. Put it as a child-window it on the desired window/form of your
application, by call the function lcCreateWindow, and link it with a drawing by the
function lcWndSetBlock.
These are the LiteCAD window functions:

Function

Meaning

lcCreateWindow

Creates the window

lcDeleteWindow

Deletes the window

lcWndResize

Changes the size and position of the window

lcWndRedraw

Redraws content of the window

lcWndSetFocus

Sets the keyboard focus to the window

lcWndSetExtents

Sets drawing's extents for the window

lcWndZoomRect

Defines a part of a drawing, visible in the window

lcWndZoomScale

Changes visible scale of a drawing in the window


(Zoom In / Zoom Out)

lcWndZoomMove

Offsets visible part of a drawing (Pan view)

lcWndGetCursorCoord

Returns cursor coordinates

lcWndExeCommand

Executes interactive command

lcWndOnClose

Stops active processes before a window to be


closed

lcWndSetBlock

Links graphics window with a block

lcWndSetProps

Links graphics window with a properties window

lcWndGetEntByPoint

Gets one entity at specified position

lcWndGetEntByPoint2

Gets one entity at specified position

lcWndGetEntsByRect

Gets an array of entities by specified rectangle

lcWndGetEntity

Returns a handle to entity in the array

lcWndGetEntByID
lcWndGetEntByIDH

Retrieves an entity by its identifier

lcWndGetEntByKey

Retrieves a graphic object by its key value

lcCoordDrwToWnd

Converts a drawing coordinates into a window


coordinates

lcCoordWndToDrw

Converts a window coordinates into a drawing


coordinates

Paint mode functions


The window object has the following properties:
Type

Acces
s

Meaning

LC_PROP_WND_ID

int

RW

Window Identifier

LC_PROP_WND_WIDTH

int

Window width, pixels

LC_PROP_WND_HEIGHT

int

Window width, pixels

LC_PROP_WND_HWND

handl
e

WinAPI handler
(HWND) of a window

LC_PROP_WND_BLOCK
LC_PROP_WND_VIEWBLOCK

handl
e

Handle to a block
linked with a window

LC_PROP_WND_DRW

handl
e

Handle to a drawing
currently displayed in
a window

Property

LC_PROP_WND_RULERS

bool

RW

Visibility of window
rulers (The window
must be created with
LC_WS_RULERS style
flag)

LC_PROP_WND_HASFOCUS

bool

TRUE, if a window
have input focus

LC_PROP_WND_PIXELSIZE

float

Current scale of the


drawing in the
window, units per
pixel

LC_PROP_WND_SELECT

bool

RW

Mode "Select
objects"

LC_PROP_WND_SELBYRECT

bool

RW

Implied windowing
for objects selection

LC_PROP_WND_BREAKPOINTS

bool

RW

Display breakpoints

LC_PROP_WND_BREAKPTNUMS

bool

RW

Display breakpoint
number

LC_PROP_WND_ALPHABLEND

bool

RW

Enable alpha blend


(transparent filling)

LC_PROP_WND_STDBLKFRAME

bool

RW

Draw red frame


around a window if

standard block is
active
LC_PROP_WND_DTIME

int

Redraw time,
milliseconds

LC_PROP_WND_DRAWPAPER

bool

RW

Draw paper sheet for


"Paper space" blocks

LC_PROP_WND_FROZEN

bool

RW

"Frozen" mode

LC_PROP_WND_COMMAND
LC_PROP_WND_CMD

int
handl
e
bool

Id of active command
Handle to active
command
TRUE if has active
command

RW

TRUE - only one


entity added by a
command, FALSE several entities

RW

Object snap mode


(LC_OSNAP_NODE
and others)
On/Off

LC_PROP_WND_CMDENT1

bool

LC_PROP_WND_OSNAP

int
bool

Cursor type and position

LC_PROP_WND_CURSORARROW
LC_PROP_WND_CURSORSYS

bool
int
handl
e

RW
W
RW

Enable arrow cursor


Set cursor by id
(LC_CURSOR_ARRO
W,
LC_CURSOR_CROSS,
etc.)
Get cursor handle /
Set cursor by handle
(HCURSOR)

LC_PROP_WND_CURSORCROSS

bool

RW

Enable crosshair
cursor

LC_PROP_WND_CURSORSIZE

int

RW

Size of crosshair
cursor, % of screen,
if negative - size in
pixels

LC_PROP_WND_PICKBOXSIZE

float

Half-size of selecting
square (drawing's
units)

LC_PROP_WND_CURX

int
float

Cursor position X,
pixels
Cursor position X,

drawing's units

LC_PROP_WND_CURY

int
float

Cursor position Y,
pixels
Cursor position Y,
drawing's units

LC_PROP_WND_CURLEF

float

Left side coordinate


of selecting square
(drawing units)

Bottom side
coordinate of
selecting square
(drawing units)

LC_PROP_WND_CURBOT

float

LC_PROP_WND_CURRIG

float

Right side coordinate


of selecting square
(drawing units)

LC_PROP_WND_CURTOP

float

Top side coordinate


of selecting square
(drawing units)

LC_PROP_WND_COORDS

bool

RW

Display cursor
coordinates at leftbottom corner

LC_PROP_WND_XMIN

float

Xmin of currently
visible drawing's
area

LC_PROP_WND_YMIN

float

Ymin of currently
visible drawing's
area

Drawing view coordinates

LC_PROP_WND_XMAX

float

Xmax of currently
visible drawing's
area

LC_PROP_WND_YMAX

float

Ymax of currently
visible drawing's
area

LC_PROP_WND_XCEN

float

Center X of currently
visible drawing's
area

LC_PROP_WND_YCEN

float

Center Y of currently
visible drawing's
area

LC_PROP_WND_DX

float

Width of currently
visible drawing's
area

LC_PROP_WND_DY

float

Height X of currently
visible drawing's
area

LC_PROP_WND_GRIDSNAP

bool

RW

Enable cursor snap to


grid nodes

LC_PROP_WND_GRIDSHOW

bool

RW

Display coordinate
grid

LC_PROP_WND_GRIDDX

float

RW

Distance between
vertical grid lines

LC_PROP_WND_GRIDDY

float

RW

Distance between
horizontal grid lines

LC_PROP_WND_GRIDX0

float

RW

Grid origin point Y

LC_PROP_WND_GRIDY0

float

RW

Grid origin point X

LC_PROP_WND_GRIDBOLDX

int

RW

X step for grid bold


lines

LC_PROP_WND_GRIDBOLDY

int

RW

Y step for grid bold


lines

LC_PROP_WND_GRIDCOLOR

int

RW

Color of grid line

LC_PROP_WND_GRIDDOTTED

bool

RW

Grid line is dotted

LC_PROP_WND_GRIDCOLOR2

int

RW

Color of grid bold line

LC_PROP_WND_GRIDDOTTED2

bool

RW

Grid bold line is


dotted

LC_PROP_WND_PANSTEP

int

RW

Pan: minimal step,


pixels

LC_PROP_WND_PANLW

bool

RW

Pan: don't display


linewidths

LC_PROP_WND_PANIMAGE

bool

RW

Pan: don't draw


raster images

Coordinate grid

Pan optimization

LC_PROP_WND_PANFILL

bool

RW

Pan: don't fill


polygons

LC_PROP_WND_PANPIXSZ

bool

RW

Pan: reduce
resolution

LC_PROP_WND_MEASCOLORPN
T

int

RW

Measurement point
color (COLORREF)

LC_PROP_WND_MEASCOLORLIN
E

int

RW

Measurement line
color (COLORREF)

LC_PROP_WND_MEASLINESIZE

int

RW

Measurement line
size

LC_PROP_WND_MEASFONTSIZE

int

RW

Measurement font
size

LC_PROP_WND_MEASFILLAREA

int

RW

Fill area polygons


with hatch

LC_PROP_WND_COLORINFBG

int

RW

Info box: background


color

LC_PROP_WND_COLORINFBOR
D

int

RW

Info box: border


color

LC_PROP_WND_COLORINFTEXT

int

RW

Info box: text color

Measurements

Colors

If a drawing is not linked with a window, the following properties are available:
Property

LC_PROP_WND_LWMODE

Type

int

Access

Meaning

RW

Line width mode


(LC_LW_THIN,
LC_LW_REAL,
LC_LW_PIXEL)

LC_PROP_WND_LWSCALE

float

RW

Screen scale for line


width, mm/pixel (for
LC_LW_PIXEL mode)

LC_PROP_WND_COLORBG

int

RW

Window background
color

LC_PROP_WND_COLORCURSOR

int

RW

Cursor color

LC_PROP_WND_COLORFORE

Object properties window

int

RW

Foreground color

Home

The properties window is used to display and edit properties of various LiteCAD objects.
In Litecad.exe program this window is placed at left side of the design window. When
you select an entity, its properties appear in the window, so you can modify it (see the
picture below).

In your application you can put it on desired place. In order to link the properties
window with a drawing, you have to call the lcWndSetProps function.
These are the functions of the properties window:
Function

Meaning

lcCreateProps

Creates the properties window

lcDeleteProps

Deletes the properties window

lcPropsResize

Changes the size and position of the properties window

lcPropsUpdate

Updates the properties window

Status Bar

Home

The status bar is used to display cursor coordinates and other infoemation. In
Litecad.exe program status bar is placed at bottom side of a design window (see the
picture below).

These are functions for Status Bar object:


Function

Meaning

lcCreateStatbar

Creates status bar object

lcDeleteStatbar

Deletes status bar object

lcStatbarResize

Sets size and position

lcStatbarCell

Defines text fields

lcStatbarText

Sets text contents

lcStatbarRedraw

Redraws status bar

Code sample:
from \LC_Samples\LaserDraw\ project
HANDLE
g_hStatBar;
// status bar
//----------------------------------------------int APIENTRY _tWinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR
lpCmdLine, int nCmdShow)
{
...
// Create StatusBar
g_hStatBar = lcCreateStatbar(
lcStatbarCell( g_hStatBar, 1,
lcStatbarCell( g_hStatBar, 2,
lcStatbarCell( g_hStatBar, 3,
lcStatbarCell( g_hStatBar, 4,
...

g_hwMain );
0 );
100 );
200 );
350 );

}
//----------------------------------------------void OnAppResize (WPARAM SizeType, int Wmain, int Hmain)
{
int x, y, w, h, Hsbar;
// Default height of the status bar
Hsbar = lcPropGetInt( 0, LC_PROP_G_SBARHEIGHT );
...
// StatusBar position

x = 0;
y = Hmain - Hsbar + 1;
w = Wmain;
h = Hsbar;
lcStatbarResize( g_hStatBar, x, y, w, h );
}
//----------------------------------------------void OnMouseMove (HANDLE hEvent)
{
...
// Display data in status bar
// X
okDblToStr( X, szNum, 2 );
swprintf( szBuf, L"X: %s", szNum );
lcStatbarText( g_hStatBar, 1, szBuf );
// Y
okDblToStr( Y, szNum, 2 );
swprintf( szBuf, L"Y: %s", szNum );
lcStatbarText( g_hStatBar, 2, szBuf );
// redraw the status bar
lcStatbarRedraw( g_hStatBar );
}

Events

Home

Event processing permits you to control user actions while the user is running your
application. LiteCAD features several types of events that can be used to instantiate

additional procedural code. For each of these events you create an "event procedure" in
your application. It has the following syntax:

void __stdcall EventProc (


HANDLE hEvent
);
You have to define only those event procedures that you intend to use. Whenever the
user performs any specified action, LiteCAD calls your previously defined corresponding
procedure. Some events are manifested by setting a return value, in those cases,
LiteCAD's behavior is dependant upon the return value.
These are service functions used to control events:
Function

Event

lcEventSetProc

Defines an application-defined event procedure for


specific event

lcEventReturnCode

Defines return code of event procedure

lcEventsEnable

Enables or disables events generation

LiteCAD has the following types of events (defined by LC_PROP_EVENT_TYPE property):


Event type

Meaning

LC_EVENT_MOUSEMOVE

Window cursor position has been changed

LC_EVENT_LBDOWN

Left mouse button has been pressed

LC_EVENT_LBUP

Left mouse button has been released

LC_EVENT_LBDBLCLK

Left mouse button double click

LC_EVENT_RBDOWN

Right mouse button has been pressed

LC_EVENT_RBUP

Right mouse button has been released

LC_EVENT_KEYDOWN

Keyboard key has been pressed

LC_EVENT_PAINT

LiteCAD window is being redrawn

LC_EVENT_VIEWBLOCK

Window has changed active block

LC_EVENT_WNDVIEW

View position has been changed in LiteCAD


window

LC_EVENT_SNAP

Allows a mouse to stick to specific points

LC_EVENT_ADDSTR

LiteCAD initializes GUI strings

LC_EVENT_FILE

Drawing has been loaded from a file or saved to


a file

LC_EVENT_EXTENTS

Drawing's extents has been changed

LC_EVENT_ADDENTITY

Graphic entity has been added

LC_EVENT_PICKENT

User clicks on entity

LC_EVENT_SELECT

Selection set has been changed

LC_EVENT_ENTPROP

Entity's property value has been changed

LC_EVENT_DRWPROP

Drawing's property value has been changed

LC_EVENT_ADDCMD

LiteCAD initializes commands. Use this event to


add custom commands.

LC_EVENT_CCMD

Custom command interface

Some events are manifested by setting a return value, in those cases, LiteCAD's
behavior is dependant upon the return value.
The function lcEventReturnCode is used to set event return code.
Inside the event procedure, you can access the following event properties by using the
hEvent parameter:
Type

Access

Meaning

LC_PROP_EVENT_TYPE

int

Event type
(LC_EVENT_MOUSEMOVE
and other)

LC_PROP_EVENT_APPPRM1

int

Application-defined
parameter 1

LC_PROP_EVENT_APPPRM2

handle

Application-defined
parameter 2

LC_PROP_EVENT_WND

handle

LiteCAD design window

LC_PROP_EVENT_DRW

handle

Drawing

LC_PROP_EVENT_BLOCK

handle

Block

LC_PROP_EVENT_ENTITY

handle

Entity

LC_PROP_EVENT_HDC

handle

Device context

LC_PROP_EVENT_HCMD

handle

Object defined in a
custom command

Property

LC_PROP_EVENT_INT1
LC_PROP_EVENT_INT2
LC_PROP_EVENT_INT3
LC_PROP_EVENT_INT4
LC_PROP_EVENT_INT5

int

RW

Integer value.
The meaning depends on
event type.

LC_PROP_EVENT_FLOAT1
LC_PROP_EVENT_FLOAT2
LC_PROP_EVENT_FLOAT3
LC_PROP_EVENT_FLOAT4
LC_PROP_EVENT_FLOAT5
LC_PROP_EVENT_FLOAT6

float

RW

Float value.
The meaning depends on
event type.

LC_PROP_EVENT_STR1
LC_PROP_EVENT_STR2

string

string value.
The meaning depends on
event type.

Code sample:
// LiteCAD event procedure
//----------------------------------------------void CALLBACK EventProc (HANDLE hEvent)
{
int EventType;
LcApplication* pApp = (LcApplication*)lcPropGetHandle( hEvent,
LC_PROP_EVENT_APPPRM2 );
if (pApp){
EventType = lcPropGetInt( hEvent, LC_PROP_EVENT_TYPE );
switch( EventType ){
case LC_EVENT_MOUSEMOVE: pApp->OnMouseMove( hEvent ); break;
case LC_EVENT_KEYDOWN:
pApp->OnKeyDown( hEvent ); break;
...
}
}
}
//----------------------------------------------bool LcApplication::Init (HINSTANCE hInst, LPCWSTR szAppDir)
{
BOOL bInit;
...
lcEventSetProc( LC_EVENT_MOUSEMOVE, EventProc, 0, (HANDLE)this );
lcEventSetProc( LC_EVENT_KEYDOWN, EventProc, 0, (HANDLE)this );
...
bInit = lcInitialize();
...
}
//----------------------------------------------void LcApplication::OnMouseMove (HANDLE hEvent)
{
WCHAR szBuf[256], szNum[16];
double X, Y;
HANDLE hLcWnd = lcPropGetHandle( hEvent, LC_PROP_EVENT_WND );

X = lcPropGetFloat( hLcWnd, LC_PROP_WND_CURX );


Y = lcPropGetFloat( hLcWnd, LC_PROP_WND_CURY );
// X
okDblToStr( X, szNum );
swprintf( szBuf, L"X: %s",
lcStatbarText( m_hStatBar,
// Y
okDblToStr( Y, szNum );
swprintf( szBuf, L"Y: %s",
lcStatbarText( m_hStatBar,

szNum );
1, szBuf );

szNum );
2, szBuf );

lcStatbarRedraw( m_hStatBar );
}
//----------------------------------------------void LcApplication::OnKeyDown (HANDLE hEvent)
{
UINT VirtKey, Flags;
BOOL bShift, bCtrl;
double X, Y;
HANDLE hLcWnd, hLcDrw, hBlock;
VirtKey = lcPropGetInt( hEvent, LC_PROP_EVENT_INT1 );
Flags
= lcPropGetInt( hEvent, LC_PROP_EVENT_INT2 );
bShift = lcPropGetInt( hEvent, LC_PROP_EVENT_INT3 );
bCtrl
= lcPropGetInt( hEvent, LC_PROP_EVENT_INT4 );
X = lcPropGetFloat( hEvent, LC_PROP_EVENT_FLOAT1 );
Y = lcPropGetFloat( hEvent, LC_PROP_EVENT_FLOAT2 );
hLcWnd = lcPropGetHandle( hEvent, LC_PROP_EVENT_WND );
hLcDrw = lcPropGetHandle( hEvent, LC_PROP_EVENT_DRW );
hBlock = lcPropGetHandle( hEvent, LC_PROP_EVENT_BLOCK );
if (OnKeyDown( VirtKey, Flags )){
lcEventReturnCode( 1 );
}
...
}