Editing an SVG image for a Fritzing part using Inkscape

Introduction

This is an incomplete tutorial, a FAQ, and is IN PROGRESS.

A specification for an electronic component (part) in Fritzing comprises five files, including several image files in the SVG format.  This  is about editing an image file for the PCB, the image of a part’s lands on a printed circuit board.

The example describes an SMD part.  The example file is distributed with Fritzing, at this location on a typical Linux installation of Fritzing:

~/Fritzing/parts/svg/core/pcb/QFN-20-0.4MM_pcb.svg

I am not an expert, and this could have mistakes.

Printed circuit board layers

A PCB has layers.  From the top:

  • artwork: labels (text and guides) to help solder parts to the PCB
  • solder mask
  • top copper
  • epoxy/glass structure
  • bottom copper (optional)

A PCB can be multi-layer: having additional layers of copper and glass.  Fritzing is NOT capable of designing multi-layer PCB’s, only the layers listed above.

What PCB layers are represented in a Fritzing SVG file

The artwork and copper layers are usually represented.

The solder mask is NOT represented.  (Fritzing generates it automatically in the PCB view and when going to fab.)

The example file includes only the top copper layer, because it is an SMD package.  Some SMD parts also require the bottom SMD layer (for heat sinks connected by vias.)

Viewing Fritzing PCB layers in Inkscape

Inkscape supports layers, but Inkscape layers are not the same as PCB layers.  The example file does not have named Inkscape layers.

Instead, the PCB layers are represented as groups ( using the <g> tag.)  The groups have ID’s which name the PCB layer:

  • “copper1” meaning the top or front layer of copper
  • “silkscreen” meaning artwork

To view a PCB layer as a group, select some shape.  Inkscape will draw a bounding box that encloses the group of the selected shape.

See elsewhere for instructions on managing groups in Inkscape.

(The SVG standard does not define layers, only groups.  Inkscape implements its layers using groups.  Other SVG editors may implement layers differently.  Thus the disconnect.)

Seeing the white artwork PCB layer in Inkscape

A PCB artwork layer is traditionally white to contrast with the traditionally green solder mask layer.

Unfortunately, the default background color in Inkscape is also white, often hiding the PCB artwork layer.

To better see the artwork:

  • choose View>Display mode> outline.
  • OR set the documents background color to non-white, opaque (choose File>Document Properties…>Page>Background)

Following the Fritzing graphics standards

You should follow the graphics standards that Fritzing developers have defined for image files that define a part.

The standards define colors, fonts, dimensioning, and so forth.

You should copy an existing image, that already follows the graphic standards.

Canvas, document size, page size, and viewbox

The canvas is the available drawing area.  In Inkscape, it is practically infinite.  You can’t set the canvas dimensions.

The document size is the size of the contents, what you have drawn.  You can’t set it either, except to draw more, outside the current drawing.

The page size helps define how the contents will be paginated when printed to paper.

The viewbox defines a mapping between internal coordinates (unitless) to the document size coordinates (in some unit.)

In the example file, the document size and viewbox are:

width="0.134in" x="0in" version="1.2" y="0in" height="0.134in" viewBox="0 0 9.648 9.648"

(Seen by editing the file with a text editor.)

This means the drawing describes a part which is 0.134 inches wide, and that an internal coordinate of 9.648 corresponds to 0.134 inches.

The units don’t really matter, since all numbers are in floating point.  But, it is easier to comprehend, and edit as text, if the units are switched from inches to mm :

width="3.4mm" x="0mm" version="1.2" y="0mm" height="3.4mm" viewBox="0 0 34 34"

This is the same size (3.4mm equals 0.134 inches) but the internal coordinates now represent tenths of a millimeter.  (If you need to position shapes with more precision than tenths of a millimeter and you want to use whole numbers in your internal coordinates, define the viewbox width as 340 or even 3400.)

In the example file, there is no chosen, standard page size.  The page size is a custom page size.  The custom size has been “resized to fit the contents.”  Choose File>Document Properties…>Page to see this.

(Does a viewbox also define a peephole onto the contents?  It helps define how your drawing will initially appear when displayed on a computer screen, that may be zoomed and scrolled.  Usually the peephole covers the entire contents, so the entire contents will appear initially on a computer screen.)

Snapping to a fine grid to position shapes accurately

If you are using metric units, set a fine grid to metric units:

  • Choose File>Inkscape Preferences>Grids (or Document Preferences)
  • change the units to mm
  • change “X spacing” to 0.1 (tenths of a mm)

Also choose View>Grids.

Also choose the “Snap to Grid” icon on the right.

Set the grid fine enough and zoom in enough that you can position shapes accurately.

Editing as text instead of using Inkscape

You can edit the SVG using a text editor.  The example file is a very small, simple, SVG text.  After you edit and save it in Inkscape, it won’t be so simple.

(? will brd2svg to simplify it again when you export it?)

Assigning IDs to shapes

Shapes representing pins/pads need an ID that is referred to from a metadata file (.fzp).

Select a shape.  Click the right mouse button.  Choose “Object Properties.”

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s