Creating custom board shapes
After strugging with this task, I created a procedure for our company. I decided to share it with you and hopefully save you some trouble. My configuration was working in Mac OSX El Capitan 10.11.2. I prepared the files with InkScape 0.91. Some of the content here may be OS and software specific. Hope it can help the community.
Prepare the document
- Start Inkscape
- Select File/Save as... to save document with the name of your choice using the file type "Inkscape.svg" in the lower right hand corner pull down menu
- Select the "Page" tab under File/Document properties... and select the default units. It is preferable to use "px" because this is the native unit.
- If you board is going to be larger than the default size (sheet of paper), in the same tab under Custom size select the outer dimension of the board you want to create. Choose the dimensions of the enclosing rectangle.
- If you want to work with grids, select the "Grids" tab under File/Document properties... Select "Rectangular grid" under Creation and press "New". Choose the units, "Spacing X" and "Spacing X". In general inches, 0.1 and 0.1 are often used. Deselect "Snap to visible grid lines only" if dealing with an irregular board size and shape.
NOTE: In Mac OSX, under XQuartz/Preferences... deselect "Update Pasteboard when CLIPBOARD changes" or else copied objects will be converted to images in Inkscape.
Prepare the layers
The file layers and the XML structure are two different concepts. Although the layers are not required per se, the use of sublayer make for a tidy file. The XML structure requirements are as follows: the board, top and bottom silkscreens "svg:g" objects need to be nested under a unique "svg:g" object, itself being nested under the main "svg:svg" object. The id of this "svg:g" object can be anything. The names of the board, top and bottom silkscreens "svg:g" objects need to be set according to the instructions below.
- View the layers and sublayer by selecting Layer/Layers...
- Board sublayer. First select the top layer (usually Layer 1) and press on the "+" sign in the Layers window. Choose "Add sublayer to current" in the drop down menu. Rename this sublayer as "Board sublayer", by double-clicking of the automatically generated name.
IMPORTANT. The id of the board "svg:g" sublayer you just created has to be change to "board".
- Top Silkscreen sublayer. First select the top layer (usually Layer 1) and press on the "+" sign in the Layers window. Choose "Add sublayer to current" in the drop down menu. Rename this sublayer as "Top Silkscreen sublayer", by double-clicking of the automatically generated name.
IMPORTANT. The id of the top silkscreen "svg:g" sublayer you just created has to be change to "silkscreen".
- Bottom Silkscreen sublayer. First select the top layer (usually Layer 1) and press on the "+" sign in the Layers window. Choose "Add sublayer to current" in the drop down menu. Rename this sublayer as "Bottom Silkscreen sublayer", by double-clicking of the automatically generated name.
IMPORTANT. The id of the bottom silkscreen "svg:g" sublayer you just created has to be change to "silkscreen0".
Creating the board shape
- Select the 'Board sublayer' in the Layers window
- Choose the geometrical figure of your choice, e.g. Stars and Polygon tool, Circle, Rectangle or any other.
- Draw the figure.
- Select the "Select" tool and select the object.
- Select Object/Fill and Stroke to see what are the fill and stroke parameters. Under the Fill tab, set the Fill color RGBA to 33804080. Under the Stroke paint tab, select "no paint".
- You can set the object position and dimensions precisely by using the position and dimensions fields in the tool bar above the canvas. Set the units to your preference. You can click on the lock to constrain proportions.
- Note that in the XML editor under Edit/XML Editor..., the center (cx,cy) and radius (r) of geometrical figures are expressed in pixels.
Creating composite shapes
It is possible to merge multiple shapes by using the union operation by using the Path/Union operator.
- Draw and position multiple objects of interest on the same layer or sublayer using the previous procedure
- Select all objects that are to be merged
- Select Path/Union. The object has been converted to a path. The path can be inspected in the "d" item in the XML window under Edit/XML Editor...
Creating cutouts (holes) in a board
It is possible to create holes in PCB by subtracting a shape to another by using the Path/Difference operator.
- Draw and position two objects of interest on the same layer or sublayer using the previous procedure. The object on top creates a hole in the bottom object.
- Select the objects that are to operated
- Select Path/Difference. The subtracted object is converted to a path. In fact the subtraction occurs by the addition of a second path in the "d" item in the XML. Each path are bound by the "M" and "z" commands.
Draw the silkscreens
In these steps, we create silkscreen objects as outline copies of the board shape.
- Select and copy the board shape object you just created. The simplest way to do this is to use the XML window. Select the board shape object and press on the "Duplicate node" icon. Using the other XML tools, press promote, down and demote buttons. This has transferred the copied object to the top silkscreen sublayer. You can also use copy from the board sublayer, select the top silkscreen sublayer and paste.
- Select the fill tab under Object/Fill and Stroke and disable the Fill
- Select the Stroke paint tab enable Flat color and set RGBA to ffffffff (this maybe hard to see, but if the silkscreen layer has a tiny white border)
- Select the Stroke style tab
- Set width to Inch and set it to 1 mill (0.001 Inch) or 1 px or similar value
- You can repeat these steps to generate the bottom silkscreen object. If you copy the top silkscreen object, you won't have to change its Fill and Stroke attributes.
- Select the "Page" tab under File/Document properties... and click on "Resize page to content...". Press on the "Resize page to drawing or selection".
NOTE. In some cases, Inkscape generates upper cap "closepath" command "Z". According to the official documentation, there should be no difference between lower and upper cap "closepath" commands. I believe Fritzing expects to see lower cap "closepath" command "z" and not upper cap "closepath" command "Z". Therefore the second path which represents the cutout is ignored by Fritzing. In fact Fritzing does not completely ignore a cutout with capital "Z" as it produces an image that seems to have the hole in it, but during the importation of the svg file it does say that it does not see any cutout and indeed the Gerber files produced don't have the cutout. When this happens, one has to manually edit the svg file produced by Inkscape using a text editor to replace the "Z" for "z" in the board object, prior to importing in Fritzing.
Importing the custom board shape in Fritzing
- Start Fritzing
- Select the "PCB view" tab
- Select the PCB. In the inspector window press on "Load image file"
- Select the svg file you created
- Et voilà