Git Product home page Git Product logo

pcbdraw-lib's Introduction

PcbDraw-Lib

Model library for PcbDraw - tool for creating awesome looking PCB drawings.

Usage

Clone the repository to your computer and specify one of the directories as a library when using PcbDraw. Currently there following libraries:

  • KiCAD-base - module library in a standard style for components from KiCAD standard libraries.
  • Eagle-export - module library in a standard style for components on imported Eagle boards. This library is held separately as the import of Eagle boards to KiCAD looses library information and component names do not follow KiCAD conventions.

Important note for PcbDraw version > 0.6

PcbDraw v0.6 is the last version, that uses the old library format, where 1mm = 1 user unit. We no longer require this and you can use arbitrary units. The library have been migrated, however, if you use custom libraries, you might have to migrate them. You can do so by invoking migrate_footprint.py from the directory scripts on every footprint. I am sorry about this breaking change, but it will make creating the libraries less confusing for the future!

Creating Modules

Module is an SVG file containing a single component drawing. There are some rules below, but if you are interested in seeing a quick guide, jump to the section "Module drawing walkthrough"

The file has to follow these rules:

  • the SVG image of the component should have size and viewbox attributes set
  • the units in the SVG should be chosen such that they correspond to the physical size
  • it contains one element with id=origin having attributes x and y. Its coordinates serve as a module origin.
  • origin should be a red rectangle of size 1x1.
  • modules should not be too simplified (for example it is not OK for LED to be just a color circle).
  • module is named exactly the same as the corresponding KiCAD footprint. The extension is changed to .svg.
  • for each module there is a corresponding drawing with suffix '.back.svg' (for 'pinheader.svg' there is a 'pinheader.back.svg'). This drawing contains view of the module from the other side of the board.
  • each component should be placed on a tight canvas. The canvas size determines the highlighted area in component highlight.

Modules are placed in directories corresponding to KiCAD footprint libraries. If multiple footprints are represented using one module, the module should not be duplicated but symlinked.

Directory scripts contains script for automatic generation of modules - e.g. pin headers, DIP packages, QFN packages, etc...

Side note: reasoning behind explicitly specifying origin. Even SVG format supports units and origin can be placed at SVG (0,0) point, it not that easy in practice. Most of the editors do weird things with coordinate system. Inkscape, for example, reverses Y-axis and translates the origin by the initial size of document. When you change the size of the document, the coordinates are not modified. Therefor, I find placing origin component as the simplest solution which should be compatible with any editor.

Module drawing walkthrough

When you want to draw a component that is absent in the library, the easiest is to use pcbdraw libtemplate footprint. This command takes a *.kicad_mod file and outputs a SVG template for drawing. Let's say we would like to draw a resistor. Therefore, we locate the corresponding *.kicad_mod file and invoke it like this:

pcbdraw libtemplate footprint --front \
  /usr/share/kicad/modules/Resistor_SMD.pretty/R_1206_3216Metric.kicad_mod \
  KiCAD-base/Resistor_SMD.pretty/R_1206_3216Metric.svg

This will generate the following R_1206_3216Metric.svg file:

Template1

As you can see, it is roughly the KiCAD footprint. There is a red square. This square represent the footprint origin. Keep it in the file and don't move it!

With this set up, we can draw the footprint to be nice:

Template2

Once we are done, we can remove the "KiCAD footprint" layer:

layers

Then we can shrink the document to size (under File -> Document Properties):

shrinking

And Voilà! You just created a first, nicely-looking footprint:

Template3

Note that you can use the same procedure with the switch --back for the back side of the component.

Contributing

Please, help to increase usability of PcbDraw by adding more modules to the library. Feel free to submit a pull request with new modules.

pcbdraw-lib's People

Contributors

electro707 avatar nobodywasishere avatar nt7s avatar set-soft avatar testudor avatar yaqwsx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

pcbdraw-lib's Issues

Template gererated 180° off

When trying to generate the template of the footprint AMASS_XT60-M_1x02_P7.20mm_Vertical, the component seems to be rotated by 180° while the document border seems to be correct

Command run

./scripts/create_template.py footprint /usr/share/kicad/footprints/Connector_AMASS.pretty/AMASS_XT60-M_1x02_P7.20mm_Vertical.kicad_mod custom_footprint/Connector_AMASS/AMASS_XT60-M_1x02_P7.20mm_Vertical.svg

Result expected : having the component fully in the document of Inkscpae

ImportError: cannot import name 'pcbdraw' from 'pcbdraw'

Hello (again),

I'm trying to execute scripts/create_template.py

$ scripts/create_template.py 
Traceback (most recent call last):
  File "scripts/create_template.py", line 3, in <module>
    from pcbdraw import pcbdraw
ImportError: cannot import name 'pcbdraw' from 'pcbdraw' (/home/david/.local/lib/python3.8/site-packages/pcbdraw/__init__.py)

I'm probably not using it as I should. Could you please give me a hint on how to use it? Thank you!

$ pcbdraw --version
pcbdraw, version 0.9.0+44.g481dcdd

and PcbDraw-Lib is probably up-to-date too:

$ git log -1
commit d582bc725fe987e35f291bc06e318cf6d3b263d2 (HEAD -> master, origin/master, origin/HEAD)
Author: Electro707 <[email protected]>
Date:   Sat Mar 26 01:52:13 2022 -0400

module 'pcbnew' has no attribute 'PCB_IO'

Hello,

i'm trying to convert a footprint with the convert script but i have this error.
Using Kicad 6.0 on Ubuntu. Can you help me please?

./scripts/create_template.py footprint --front ../Libs/myfoot.kicad_mod ../Libs/myfoot.svg Traceback (most recent call last): File "./scripts/create_template.py", line 210, in <module> cli() File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1128, in __call__ return self.main(*args, **kwargs) File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1053, in main rv = self.invoke(ctx) File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1659, in invoke return _process_result(sub_ctx.command.invoke(sub_ctx)) File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 1395, in invoke return ctx.invoke(self.callback, **ctx.params) File "/usr/local/lib/python3.8/dist-packages/click/core.py", line 754, in invoke return __callback(*args, **kwargs) File "./scripts/create_template.py", line 127, in run_footprint board = buildFootprintBoard(footprint) File "./scripts/create_template.py", line 22, in buildFootprintBoard footprint = loadFootprint(footprintPath) File "./scripts/create_template.py", line 15, in loadFootprint return pcbnew.PCB_IO().FootprintLoad(lib, foot) AttributeError: module 'pcbnew' has no attribute 'PCB_IO'

Distribute the libraries

Hi, I am packaging pcbdraw for Arch Linux and was wondering if maybe the libraries could be packaged too. We could distribute the libraries and have pcbdraw include them by default.

A simple makefile that puts the libraries in /usr/share/pcbdraw would work (just make sure you respect prefix and DESTDIR). This could also be packaged via setuptools, I think.

Then pcbdraw would just look for the files there and include them 😁.

Global Lookup Table

Kind of related to yaqwsx/PcbDraw#66, and the change will ultimately need to be done in pcbdraw, but I am creating this Issue here as it relates to this repository.

Instead of symlinking footprint names, wouldn't it be better to implement some kind of lookup table per footprint library that pcbdraw will read and link component. Symlinks eventually become quite cluttered, especially with footprint renames and supporting older versions of KiCAD's footprint library:
image

Documentation for the creation of new component

I love this project, I am currently doing manual documentation of boards and this greatly simplifies the process.

The PcbDraw script works amazingly! But when creating new components I get a lot of problems:

  • What is the SVG default unit? In the documentation you says "one default unit corresponds to 1 mm in reality.", but in the SVGs of the library I opened, none of the red rectangles measure 1x1.
  • The red rectangle representing the origin, where should the origin be located? That is, which of its corners or center represents the coordinate 0,0 {X, Y}?
  • The size of the canvas of the SVG file, does it fulfill some function and has to have a specific size, or on the contrary can be depending on the content? In all built-in SVGs of the library, the canvas is much larger than the component.
  • Is there any color-coding convention to use? I mean standard colors to represent the body of an IC, the metal of a pin, etc.
  • Do the new components that we create have to be placed following some specific path? As can be the same path as the kicad module (library_name/module_name).

I use Inkscape as a native tool for editing SVG files.

Submissions for components outside of standard KiCad libs

Excellent project, thank you very much for it!

I'm more than happy to start submitting PRs for components that I create, but I have a question on how you would like to handle components that aren't in the standard libs. A fair bit of the footprints that I use are in my own custom internal library, but I'm sure they could be useful for others. Since the directory name in this lib has to match the KiCad footprint library directory name, it wouldn't be appropriate for me to submit my custom components under the folder where they usually live.

Any thoughts on how you would like to handle this?

Where to place the library?

Hello! First of all, thank you very much for all your helpful plugins for KiCAD, they are all very useful. I'm able to generate an svg of my PCB without any issues however it's empty. Where do I have to place the library so pcbdraw can fetch the footprints?

Edit: I found the library using pip show pcbdraw

Library name different from kicad name

The encapsulation libraries in kicad are made up of the word Package and then the series of the encapsulation joined by an underscore.

in this case the Package_TO_SOT_SMD library was written TO_SOT_SMD_Package this makes pcbdraw not detect the component.

rename the folder and it worked for me

create template doesn't work

sorry to write at all times. make the change you indicated and I already have my PCB with the capacitors and resistors, however I try to create a new template to create a new model and I get this error
image

I want to make all the components of this PCB, I hope you can help me.

image

Solve the units confusion

In the past, Inkscape used non-standard DPI. Therefore, the convention of 1 user unit = 1 mm was established for the compatibility with other drawing software. Inkscape changed this setting in 0.92, therefore it is compatible with all the drawing software out there. Therefore, it makes sense to migrate the library to use standard SVG units.

What is required:

  • adapt PcbDraw
  • convert the current library
  • communicate the change to the users since it will be a breaking change (provide the migration tools?)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.