I’ve a need to construct a PCB that is rounded with an elliptical shape to fit in an existing space (mocked up as a footprint here it’s the blue line):
Google shows me lots of examples for creating it by hand editing the text files after starting with a custom footprint created from a shape in Inkscape or Gimp, however they aren’t written for the current KiCad file format, at least those that I’ve found.
I’m hoping the reason I can’t find a more current tutorial is because it’s now standard functionality, and therefore too easy to be worth a write-up
Can you point me to the 2015 workflow? Thanks,
Geoff
KiCad does not have an internal representation for ellipses; to get that shape you would need to create a DXF file with that shape drawn, then import the DXF file to the Edge.Cuts layer. To create the DXF file you can use “LibreCAD” or Dassault’s DraftSight. KiCad should represent the ellipse as numerous straight segments. If KiCad doesn’t import the shape correctly for whatever reason you can file a bug report; in the meantime it would also be necessary for you to write a small script which generates the line segment approximation if kicad doesn’t import the shape.
I forgot to say that it’s also possible to represent an ellipse using multiple circular arc segments and this would be a much more efficient representation than line segments, but you would need to write a script to generate the outline in that case. In the case of your ellipse for example, I suspect 10 circular arc segments could represent an ellipse with Major/Minor axes of 100 and 50 mm with an accuracy of <0.01mm.
Thanks for your replies guys. I’ve tried from another angle now based on your suggestions[quote=“MarcoHess, post:4, topic:974”]
I recently had success with generating a board outline in FreeCAD, exporting it to DXF and importing it into KiCad.
[/quote]So I also knew Inkscape can export dxf so I took the bitmap above, imported it into inkscape, had it trace the image as a curve and then exported.
When the DXF is imported into pcbnew nothing happens though, or at potentially it’s scaled too small to be visible. I’m using Inkscape 0.91 stable and KiCad BZR5694 (2015-06-01) FWIW. Using the online viewer at autodesk.com it shows as two concentric narrow ellipses rather than the one solid it shows as in Inkscape so there’s potentially the source of the issue.
I’ll try your other suggestion for creating the dxf and see if I have any greater success,
Geoff
Firstly I saved the Inkscape file as an SVG and used an online conversion tool to create the dxf. The ellipse result wasn’t as smooth but it imported okay into KiCad, though it lost scale so was too small.
Since the output of that online conversion tool (cloudconvert.com) had got me that far, I also saw it could convert pdf to dxf. This time I exported the image directly from Gimp as a pdf, and in Adobe viewer confirmed the dimensions are correct, however once converted to the dxf and imported into KiCad once again resulted in a PCB edge shape that is too small.
I think part of the problem with some dxf files is that elliptical shapes are exported as many open single line segments and not as polylines. This is probably the cause of KiCad not being able to find the board edge in those imports.
Is there a particular version of dxf that KiCad expects? Even exporting a simple square shape from Inkscape in dxf does not import in KiCad however these files show up okay (the ellipse too) if I use an online dxf viewer. Inkscape says it’s AutoCAD DXF R14. There are some posts I’ve read that because it’s supposed to be for a desktop cutting plotter it’s exported mirrored, however for a symetrical shape like this that shouldn’t be a material issue.
I looked at libreCAD and freeCAD but I’m hoping I can avoid that learning curve.
Also these results were after updating KiCad to 2015-06-12 BZR5735, though there’s no bug listed there I can see talking about imported scale being wrong (likely a factor introduced by the conversion tool I’m expecting) nor issues with DXF files of particular versions…
There’s no particular version of DXF expected; if the scale is too small that is an issue with the exporter and not with DXF.
I tried using an ellipse in DXF but unfortunately that does not seem to be supported by KiCad. You can always ask for the ellipse feature to be supported. I also tried spline curves but they were ignored.
I suspect the best solution at this point is to write a small program to generate lines which you can simply cut and paste into the KiCad pcb file. You can start out by creating an empty board file then putting 2 line segments onto the Edge.Cuts layer and saving the board. Then look at the file with a text editor to see how you need to format each line segment that you generate. On the software side, you can generate an ellipse with the formulae:
x = Rmax * cos( a )
y = Rmin * sin( a )
Now you need to determine an appropriate increment in the angle to ensure that the error in the approximation meets your criteria. Let’s say the error ‘e = 0.02mm’ and the major radius Rmax = 50mm. The increment dA in the angle must be 2 * acos( 1 - e/R ). The number of segments is then 2pi / dA; odds are you’ll have a non-integral number and you will need to choose the next higher even number of segments, let’s call it N, then use dA = 2pi / N for generating N segments for your ellipse.
The first time through there were several where the end vertices didn’t align, which meant the PCB outline wasn’t enclosed, but now I tracked down the culprits this is now sorted. With sufficient patience (and/or red wine) this manual process could be used for any complex shape, though after doing it I’m truly thankful most enclosures are squarish with radiused corners.
[quote=“cbernardo, post:10, topic:974”]
I tried using an ellipse in DXF but unfortunately that does not seem to be supported by KiCad. You can always ask for the ellipse feature to be supported. I also tried spline curves but they were ignored.
[/quote]There are discussions there about supporting importing complex dxf features, but they are quite old and don’t appear to have any recent active development. For the moment I think that’s a bit of a dead end for complex PCB shapes.
So my workflow was to create a footprint on the silkscreen layer to scale, place it in pcbnew, then to go OpenGL mode and place heaps of <1mm line segments on the Edge.Cuts layer. Then back to default view and delete the footprint. Then outside KiCad deleting the footprint’s .kicad_mod file to clean up.
I’m very much looking forward to seeing how this board turns out. Thanks everyone.
Hi,
as Marco Hess pointed out in kicad developers mailing list, if DXF R12 is used e.g. through LibreCAD, ellipse are converted to line segments and then kicad will load it correctly.
if the ellipse will be not completely closed it is easy to add a small segment to the pcb edge and the board will render fine also in 3d-viewer…
thanks Marco!
PS Marco has patched also the “missing closing ellipse”