Library Files (MKD File Format) Changed in Version 2024.0

www.CAD6.com

A file containing a library starts with the section =LIBRARY=, followed by several sections containing standard attributes and block definitions.

 

Each section starts and ends with a unique keyword. A keyword is a word delimited by the character = (Ansi 61). The word itself may be up to 31 characters long and may neither contain the character = (Ansi 61) nor a line feed. Each keyword is followed immediately by a semicolon. All sections are terminated by the keyword =END=.

 

Not every of the sections listed below has to exist in a library file. If it does exist, it should follow the order of the sections below (although this order is not definite). Section marked with a * have to exist in any library file at the given position!

 

The file header consists of a special character sequence, which has to have exactly the form described below. The character sequence has to start at the first byte of the file, as this character sequence is checked by directly reading the first 22 bytes of the file and comparing them with the expected identification! As a result, this identification may not be enclosed in quotes, and it must be handled case sensitive!

 

If the file contains UTF-8 characters, this header should be preceded by the standard 3 byte UTF-8 BOM of 0xef 0xbb 0xbf.

 

 

Library Sections

Section =LIBRARY= (Library Information)*

See MKI_FILE_HEADER

 

Section =PROFILE= (User Settings) New in Version 2014.0

See Section =PROFILE=

 

Section =ATTRIB= (Standard Attributes)

See Section =ATTRIB=

 

Section =LINE= (Line Types) New order in Version 2013.0

See MKI_LINEDEF

 

Section =SYSTEM= (Coordinate Systems)

See MKI_SYSTEMDEF

 

Section =PEN= (Pens)

See MKI_PENDEF

 

Section =LAYER= (Layers)

See MKI_LAYERDEF

 

Section =BLOCK= (Block Definitions)

See Section =BLOCK=

 

Section =EXIT= (End of File)*

See Section =EXIT=

 

The smallest valid MKD library file has the following form:

 

 

MKD Syntax

Malz++Kassner MKD 6240;

=LIBRARY=;

LibraryTitle;

=END=;

=EXIT=;

;

=END=;

 

Comment

Standard Libraries

Standard libraries are used to manage frequently used parts and groups, especially if they shall be used in several drawings.

 

A standard library may contain up to MKI_BLOCKS_PER_DRAWING (1,000,000) block definitions having a unique name. The blocks stored in a library will be presented to the user in a hierarchical dialog box, always alphabetically sorted. So the order of the blocks in the library is not relevant.

 

Block definitions inside libraries may contain instances of either the same library or of other libraries. If an instance shall refer to a block inside the same library, the instance's LibraryName value must be set to MKI_BLOCK_ID ("*").

 

As a result, libraries cannot contain instances of internal blocks, i.e. of blocks defined in drawing files. When trying to create an external block including an internal block's instance, a warning will appear. In this case, the internal blocks will either have to be resolved or must be transferred into the library.

 

If a block contains instances, this leads to an nested structure. Be sure not to create loops where block A contains an instance of block B and block B contains a reference of block A. To avoid a deadlock due to such loops and to avoid a stack overflow during recursion the maximum nesting depth is limited to 25 levels.

 

Blocks for Hatching

Blocks to be used for hatching have to fulfill some requirements. The most important is the existence of a surrounding frame:

 

Surrounding Frame

In a hatching block, the values BlockRect.x1, BlockRect.y1, BlockRect.x2 and BlockRect.y2 have to be set in a way that they lie at the lower left and the upper right corner of the block's surrounding frame. The difference BlockRect.x2 - BlockRect.x1 defines the hatching's width, i.e. the amount the drawing position is moved horizontally after the output of each block. The difference BlockRect.y2 - BlockRect.y1 defines the hatching's height, i.e. the amount the drawing position is moved vertically after the output of each row of blocks.

 

Insertion Point

The insertion point (i.e. the internal origin of the block) should lie on or inside the surrounding frame.

 

 

Font Libraries

Font libraries are used to manage font characters, i.e. to build complete Ansi fonts. A font library should contain 224 blocks representing the characters 32 to 255 of the Ansi character set. The name of these blocks has to start with a character number, coded as a 3-digit decimal number with leading zeros, followed by either a space and additional information or immediately by the name's termination character.

 

A possible block name for the block representing the character "Capital A" could be "065 A", where 065 is the character index in the Ansi character set and " A" is additional information for the library's creator. The order of the blocks in the font library is not relevant.

 

Blocks in a font library have to fulfill some requirements. The most important is the size and placement of a character inside the block:

 

Character Height

The character height in the library has to be exactly 20 mm. All other font sizes will be generated from that 20 mm character by scaling.

 

Insertion Point

The insertion point (i.e. the internal origin of the block) has to be at the character's left edge on the baseline. If a character shall overlap the previous character (e.g. the capital W), the insertion point has to be set accordingly.

 

Surrounding Frame

In a character block, the values BlockRect.x1, BlockRect.y1, BlockRect.x2 and BlockRect.y2 have to be set in a way that they lie at the lower left and the upper right corner of the character's surrounding frame. The difference BlockRect.x2 - BlockRect.x1 defines the character's width, i.e. the amount the drawing position is moved along the baseline after the output of this character. Usually, BlockRect.x1 should be set to 0.0.

 

 

If a font does not include the full Ansi character set (even though it is strongly recommended to implement the full set), it should contain at least the following characters:

032..126

Standard character corresponding to ASCII / Ansi.

160

The character Ansi 160 is similar to the space ' ' (Ansi 32), but will not be broken if a word-break is performed.

173

The character Ansi 173 is similar to the minus sign or hyphen '-' (Ansi 45), but will not be broken if a word-break is performed.

176

The character ° is used to mark an angle value.

177

The character ± is frequently used in tolerances.

216

The character Ø is used to mark a diameter value.

 

Attributes inside font libraries will be ignored! All properties of character blocks will be reset during load time, i.e. their properties will not be maintained! The same applies to any layer, pen, or line type definition in the font library.

 

CAD6interface 2024.2 - Copyright 2024 Malz++Kassner® GmbH