← Back to team overview

kicad-developers team mailing list archive

patch for IDFv3 component library support

 

Hi folks,

 I have pushed a patch to my github patches project
 (git clone https://github.com/cbernardo/kicad-patches.git)

 The patch name is export_idf3_libs.patch and was created against Rev 4632.
 The patch adds IDFv3 component library support; the addition of this feature
 provides users with the IDF support required for interaction with mechanical
 designers.

 The IDF specification provides for more features but MCAD packages vary in the
 implementation of those features and at this stage it makes no sense to add
 such features to the KiCad exporter, so we may consider this patch as
 completing IDF support.

 The exporter has been tested with components placed on both sides of the board
 and with various component rotations to ensure that the result is as expected.
 The IDF files created (*.emn, *.emp) were imported into SolidWorks without any
 problems at all.

What's missing:

 I need to create documentation for how to create the IDF files used to
 represent components. Initially the files will have to be hand crafted as I
 have done for my initial tests. Later I will create a tool to import
 footprints from DXF and I plan to create tools for parametric generation of
 some footprints.

How to create *.idf files for input:

 The structure of the component outline (footprint) is specified in the IDFv3
 documentation (idf_v30_spec.pdf available on the web) but I will give a brief
 description here.

0. The IDF file contents must be 7-bit ASCII encoded; UTF-8 may produce
   unspecified behavior.

1. The *.idf file may begin with a number of comment lines; these comment lines
   must have a '#' as the first character in the line. When the IDF board
   description is exported,  the comment lines are copied in order to preserve
   any comments supplied by the user; useful comments would include information
   such as references to documents used in creating the files.

2. After the comments is the section declaration; this may be one of
   '.ELECTRICAL' or '.MECHANICAL'; the case does not matter (per IDFv3 spec.).

3. Immediately after the section declaration is RECORD 2 (the section
   declaration is RECORD 1).  This consists of 4 fields separated by one or
   more spaces. Strings which have spaces in them must be quoted. The fields
   are:

a. Geometry name: this field may convey package type, orientation, or
whatever special ways people bend the pins of a device. For example,
it may be "SOT-23" or "TO-92 with strangely bent legs". Personally I
would recommend using it for the package name only, so "SOT-23" and
"TO-92"; further information can be stuffed into the "Part Number"
instead. This is my preference because SolidWorks names the imported
mechanical part according to the Geometry name. Other MCAD packages
may use a different criterion such as the Part Number.

b. Part Number: this is obviously intended as the manufacturer part number
such as BS107. Personally I would use it as an added description to the
Geometry Name; for example I would put something like "NORMAL" or
"0.1-inch pin spacing, straight"

c. Units: must be one of MM or THOU (case does not matter)

d. Height: a float indicating the height of the extruded footprint

4. After RECORD 2 comes RECORD 3 which lists the points in the outline;
the X, Y coordinate of the last point must match the X, Y coordinate of
the first point except where the outline is a simple circle. The outline is
very simple; there may not be any cutouts and there must be only one outline.
RECORD 3 consists of 4 fields:

a. Loop Index: 0 = points are specified in CCW order
   1 = points are specified in CW order.

b. X coordinate

c. Y coordinate

d. Included angle

    If the included angle is 0,  then a line is drawn from [X(n-1), Y(n-1)]
    to [X(n),  Y(n)].  If the included angle is positive/negative,  then an
    arc is drawn CCW/CW from [X(n-1), Y(n-1)] to [X(n), Y(n)]. If the angle
    is 360 (-360 is not allowed) then a circle is drawn with the center at
    [X(n-1), Y(n-1)] and [X(n), Y(n)] is a point on the circle. A circle is
    a closed outline so if a circle is specified it must be the only outline.

5. After all RECORD 3 entries have been specified,  the section must be
terminated with '.END_ELECTRICAL' or '.END_MECHANICAL' as appropriate.


Example IDF component files:


FILE 1: a simple circular outline

# simple tube which can represent a vertical tubular capacitor
.ELECTRICAL
"TUBE" "5mm dia, 5mm height" MM 5
0 0 0 0
0 2.5 0 360
.END_ELECTRICAL

FILE 2: an outline resembling an inverted 'T':

# test target for verifying rotations of components on back of board.
# 2 thru-holes are to be 1.0mm diameter and 5mm apart along X axis
# 1 thru-hole is to be 1.0mm diameter and 8mm along the Y axis
.ELECTRICAL
UPSIDEDOWN "CAPITAL T" MM 4.2
0 -0.5 8 0
0 -0.5 0.5 0
0 -2.5 0.5 0
0 -2.5 -0.5 180
0 2.5 -0.5 0
0 2.5 0.5 180
0 0.5 0.5 0
0 0.5 8 0
0 -0.5 8 180
.END_ELECTRICAL

Feel free to zip and email me any models you export; I can check the results
in SolidWorks and post back a mechanical model if you wish.

- Cirilo



Follow ups