How can I convert a DXF or DWG to .kicad_wks?

Hi,

I have an existing drawing template with a title block that I’d like to use. I know it’s not going to be possible to use it directly as a KiCad drawing sheet template since it won’t know what the fields are etc., but if I could get the lines and ideally the text imported that will save me a lot of work.

I have DXF, DWG and PDF format files I can work from. I successfully imported the DXF into pcbnew and saved it out to see what I got and it looks like it would be possible to write a program to convert the lines and text from that pcbnew file to a barebones kicad_wks file that I can add fields to.

Before I do that, is there an easier way?

Thanks!

Without knowing what your current/existing template/title-block looks like, An option to consider:

(and, most likely quicker and cleaner than doing half-baked tweaks…)

Start fresh and duplicate what you want in the Worksheet editor
• Can delete everything from the default that it opens with
• Draw Lines, Rectangle/Box for Legend
• Draw Lines for perimeter
• Add the Text (including pasting existing/copied text)

Tweak as you like to get what you want. Save it and select it for the Worksheet in both PCB and Schematic (same worksheet file is used)

A 1-Minute video demo… Shows deleting everything then drawing the items. But, you may want to keep the Border and some text items…

The drawing sheet editor is a bit of a stepchild in the KiCad Program suite and does not get much attention. As far as I know it only has the ability to import a bitmap (png, jpg, etc.) graphic (probably meant for logo’s and such), but not for vector drawings. So you probably can export your title block as a bitmap with an external program, then import it in the drawing sheet editor, trace lines over it, and then delete it again.

I would really like it if it could import at least SVG.

Import to where? The diagram is not covered by the drawing of the case or PCB even altium uses a separate application… And as practice shows, drawing drawings is more convenient in a special program

Thanks for the suggestions everybody, I went ahead and wrote a program to convert the file in the end. Some corporate title blocks can be really intricate and this one had a logo made of graphic lines so this was certainly easier than recreating it. I’ll try to put the code up somewhere for future generations soon.

1 Like

Colin:
Have you found a place to put your code anywhere yet, as I could really use this code. I have been struggling with the same problem as you have. My Corporate title block is much more complex that the simple one used in Kicad. These are standards put in place by the DOD, and other government agencies in the US.

Thanks,
Fred

Hi Fred,

I have pushed it to github since you asked.

See the readme here: wks_converter/README.md at main · crnorris/wks_converter · GitHub

And I’ve published a Windows binary here: Release 0.1 · crnorris/wks_converter · GitHub

It’s C# so you should be able to have this working on other platforms but I don’t have any to test on right now. Let me know if you have any trouble with it.

Edit: looks like I hard-coded the page size to 594x420mm (A2) so that might be an issue for you, if so I’ll make it an argument.

Colin:
Thanks for the code, unfortunately I use a Mac (12.6.6) so I am not sure what to do with this code as I never used C# before. I do have Visual Studio which I use for Arduino projects. I also have Xcode installed however I don’t think Xcode does C# as it is a MicroSoft project.
I mostly use ANSI paper sizes (A, B, C, D, E) because I live in the US and these are the standard drawing sizes used in the US. I have Templates for B, C, D, and E sizes.

Thanks for your help
Fred

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.