PartKeepr to Altium Designer/KiCAD/ any ECAD integration

368 views
Skip to first unread message

Jura

unread,
Nov 22, 2020, 5:10:46 AM11/22/20
to PartKeepr Users
Hello everybody !

This is going to be a slightly longer post/question but please bare with me, because I think that it will be worth it.

My problem/idea background:
I am an electrical engineer (designer of electronic products) in a (very) small company.
My company uses Altium Designer as the tool for electronic design.
I have been running PartKeepr on my local machine (Windows SBS 2003) for years (I forgot how long exactly) and it worked great.
This year I switched to Debian 9. It took me some time and effort to migrate the database and the all files (I am not experienced with Linux) but I was able to do it.
During the process I had to learn some basic SQL and Linux. I use MariaDB SQL database and Apache.

A few weeks ago I started investing if it would be possible to "see" my PartKeepr parts in Altium Designer. This would help be A LOT to reduce the number of errors regarding component name, parameters, footprints, etc.

My idea was to add new parameters to each part in PartKeepr like "Lib Ref", "Lib Path", "Footpring Ref" and "Footpring Path".
Besides component name and description this is the basic data that Altium needs in order to "build" a component.

Altium would use this data to create a component library.
Then I could place on my PartKeepr components on my schematic and PCB documents.
If this would work then theoretically I could add additional parameters like "Max Voltage", etc. and see these parameters as well in Altium Designer.

As it turns out Altium Designer can connect to a database (mostly) without a problem.
However the format of the data tables that Altium expects differs from the PartKeepr table format that are stored in the SQL database.

Altium expects to see one table which has to look like this :

So to do this I had to write a small SQL script that will "merge" (SQL folk would say join) the "Part" and the "PartParameter" tables.
This script also creates a new table called "AltiumTemp" (the above screenshot is the screenshot of the AltiumTemp table).

When this is done Altium can see all the components from my PartKeepr database.

And now (finally) the question :-) :

In order for my AltiumTemp table to be in sync with the Part and PartParameter tables I have to execute my script manually which, in my opinion, sucks.

It would be much more elegant if my script would execute each time there is a change in Part and/or in PartParameter tables.

My idea was to do this by using triggers (a feature of MySQL) but because of the way that my script is (has to be) written using trigger is not technically possible.
I have converted my script into a stored procedure so the "only" thing that I need to do, in order to sync AltiumTest table, is to execute a stored procedure.

So my idea is to add code to PartKeepr that will execute this stored procedure each time the user clicks the "Save" button in the part dialog.


The problem is I don't know how to do this :-) .
Can anyone please point we in the right direction how to do it ?
Where do I have to add code (which file, php or some other) in order to get this functionality ?

After I implement this solution I plan to upload a video to Youtube with the instructions.

Also, I am aware that integration of PartKeepr with , for example, KiCad is much more interesting than with Altium Desinger (which costs an arm and a foot).
But if this can be done with Altium I am sure that, with some minor tweaks, it would be possible to it with any other ECAD platform that supports connections to SQL databases.

Thanks !

Jura






Jura

unread,
Nov 22, 2020, 5:15:14 AM11/22/20
to PartKeepr Users
I just noticed that the screenshots are missing:

Altium expects to see one table which has to look like this :

AltiumTable.png


AltiumTable created from my script (merge of part and Partparameter tables):

AltiumTemp table.png


Part save dialog:

PartKeepr part.png

Sorry !

Jura


clupu...@googlemail.com

unread,
Nov 23, 2020, 7:36:57 AM11/23/20
to PartKeepr Users
Hello,

as far as I understand things correctly, you might want to have a look at


Christian

Jurica Grcic

unread,
Nov 23, 2020, 12:16:43 PM11/23/20
to clupu...@googlemail.com, PartKeepr Users
Dear Christian,

Thanks for the reply !
I have been browsing through the source code for the last few days and I have been suspecting that this file is a good candidate.

However, I have no experience with the Symphony Framework/Composer/Doctrine so I am not sure how to write my code.
In

I see that I can send a SQL query by invoking the " $this->entityManager->createQuery()" function.
But if I understand correctly (or maybe not) entityManager is not available in the PartPutAction.php?

Any pointers on how to access the entityManager (or any other object that will enable sending SQL queries) inside the PartPutAction class ?

Jura

--
You received this message because you are subscribed to the Google Groups "PartKeepr Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to partkeepr-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/partkeepr-users/bfd80475-34fa-4603-99e6-e4d019c8529an%40googlegroups.com.

clupu...@googlemail.com

unread,
Nov 25, 2020, 3:55:49 AM11/25/20
to PartKeepr Users
Hello Jura,

I give you a hack on how to call a method upon invocation. This is definitively **no good design** and should not be considered a permanent solution if PK continues working/developing.

You need an include like this https://github.com/partkeepr/PartKeepr/blob/master/src/PartKeepr/PartBundle/Services/PartService.php#L5. Just put it with the other uses in the PartPutAction.
Next, you need a private class member. https://github.com/partkeepr/PartKeepr/blob/master/src/PartKeepr/PartBundle/Services/PartService.php#L28-L31 is an example. Put it with the other members, the ordering is irrelevant.
Last but not least you need to update the constructor. Add an additional parameter to https://github.com/partkeepr/PartKeepr/blob/master/src/PartKeepr/PartBundle/Action/PartPutAction.php#L37-L40. It must be of type EntityManager. In the initialization, you must add a similar line for the new parameter/class field.

The internal logic of Symfony should handle the rest (see dependency injection for further reading if interested).

Having done that, $this->entityMapper is known. The rest is up to you.

I hope this helped.
Christian

Jurica Grcic

unread,
Nov 28, 2020, 7:27:46 AM11/28/20
to clupu...@googlemail.com, PartKeepr Users
Dear Christian,

Thanks for your help !
Your suggestion is a very good idea.

I studied the code base this week and I was able to create a solution to the problem by slightly modifying your suggestion.

1. I've added a public function to PartService.php PartService class that will execute my SQL stored procedure:
public function createAltiumTable()
    {
        $this->entityManager->flush(); // flush all pending changes to the PartKeepr database

        $connection = $this->entityManager->getConnection()->getWrappedConnection();

        $stmt = $connection->prepare('call PartKeeprTest.CreateAltiumTempTable()');
        $stmt->execute();   
    }

2. Being that the PartService object is accessible in PartPutAction and PartPostAction classes, I added this code right before the return statement of the constructor:
public function __invoke(Request $request, $id)

        $this->partService->createAltiumTable();
    
        return $part;

That's it.
Now my stored procedure is called after each part update.

I am happy with this solution but I will try to learn more about Symfony/Doctrine/ExtJS, because I would like to make some improvements to this solution and to PartKeepr in general.
For example I would like to eliminate my stored procedure and execute the stored procedure code from php.

When I prepare the video and the final code I will share the Youtube and GitHub links in the group.

Thanks for the help !

Regards,

Jura


You received this message because you are subscribed to a topic in the Google Groups "PartKeepr Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/partkeepr-users/B0FwqC3_S_Q/unsubscribe.
To unsubscribe from this group and all its topics, send an email to partkeepr-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/partkeepr-users/271c3da4-8b0f-495b-b82e-cc468a16fcc6n%40googlegroups.com.

o1bigtenor

unread,
Nov 28, 2020, 7:48:38 AM11/28/20
to Jurica Grcic, clupu...@googlemail.com, PartKeepr Users
On Sat, Nov 28, 2020 at 6:27 AM Jurica Grcic <jurica...@gmail.com> wrote:
Dear Christian,

Thanks for your help !
Your suggestion is a very good idea.


When I prepare the video and the final code I will share the Youtube and GitHub links in the group.

Any chance that you would be able to have something that is also in text form rather than just in video 
format? - - - -(please!!!!!!)

Maybe I'm just an old fossil but I find that I learn far better from the written word than I do from a video 
that I have to stop and start some thousands of times to get it to divulge its tips and tricks. 

TIA 

Jurica Grcic

unread,
Nov 28, 2020, 7:58:15 AM11/28/20
to o1bigtenor, clupu...@googlemail.com, PartKeepr Users
No problem.
I will create a GitHub project with written instructions and the source code.

However some information is easier to explain in a video (especially regarding Altium bugs).

Jura

clupu...@googlemail.com

unread,
Nov 28, 2020, 9:32:12 AM11/28/20
to PartKeepr Users
You are welcome. Glad my hints helped you to get things running.

Mark W

unread,
Apr 12, 2021, 12:30:07 AM4/12/21
to PartKeepr Users
Hello Jura,

Did you ever package together your changes into something that can be used by others?
I also would like to have Altium use Partkeepr for parts information.

Thankyou!

Jurica Grcic

unread,
Apr 12, 2021, 1:26:49 AM4/12/21
to Mark W, PartKeepr Users
Hi Mark !

Yes, I was able to add some code to the PartKeepr code base and add some new tables to the SQL database that allows me to view my parts in Altium.
But the thing that I did is more of a hack than a proper solution (you have to manually insert PHP code in to PartKeepr codebase + you have to manually execute some SQL statements in order to create new tables in SQL ) so I did not want to publish this solution until I have a better one.
If you are interested in my hack I can prepare a small tutorial and share it with the group.

Best regards,

Jura

--
You received this message because you are subscribed to the Google Groups "PartKeepr Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to partkeepr-use...@googlegroups.com.

Mark W

unread,
Apr 12, 2021, 1:30:37 AM4/12/21
to PartKeepr Users
Hi Jura,

That sounds really promising. It would be great to see how you've done it.
I know making an instruction video takes time, I would be happy with just the modified files (or diff's), and the SQL code.
Maybe we could work towards a less hacky solution.

Thanks!

Daniel Calcoen

unread,
Apr 12, 2021, 4:08:24 AM4/12/21
to PartKeepr Users
Dear Jura,
I'm also interested.
I offer to put the explanation, examples, links here

Regards
Daniel

o1bigtenor

unread,
Apr 12, 2021, 8:18:21 AM4/12/21
to Mark W, PartKeepr Users
On Mon, Apr 12, 2021 at 12:30 AM Mark W <m...@mwp.id.au> wrote:
>
> Hi Jura,
>
> That sounds really promising. It would be great to see how you've done it.
> I know making an instruction video takes time, I would be happy with just the modified files (or diff's), and the SQL code.
> Maybe we could work towards a less hacky solution.
>

Please, please please make a written description as well.
I find video tutorials very information 'not' dense and all too often
it is not possible to catch all the bits and bobs
being talked about. The written also removes any need of the 50 times
back and forth so that I can write out
the destructions (as I call them).
> rant off

Jurica Grcic

unread,
Apr 12, 2021, 1:33:44 PM4/12/21
to o1bigtenor, Mark W, PartKeepr Users
OK, if I understood Daniel's suggestion correctly I can add the tutorial to the https://readthedocs.web.cern.ch/display/PARTK/tailing+partkeepr+code+to+your+needs ?
Do I need any special permissions for this, or is a simple register/login enough?

Jura

--
You received this message because you are subscribed to the Google Groups "PartKeepr Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to partkeepr-use...@googlegroups.com.

Daniel Calcoen

unread,
Apr 12, 2021, 1:56:00 PM4/12/21
to PartKeepr Users
Dear Jura,
you can paste at the bottom in comments and then I'll copy to the page or a new page (better) or you can send the page by e-mail.
Unfortunately for the time being I can not grant access to persons not belonging to the institution.
Regards
Daniel

Jurica Grcic

unread,
Apr 12, 2021, 3:15:36 PM4/12/21
to Daniel Calcoen, PartKeepr Users
OK. Can I prepare a Word or PDF file and send it to you?
Then you can upload the file content to the website.

Jura

You received this message because you are subscribed to a topic in the Google Groups "PartKeepr Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/partkeepr-users/B0FwqC3_S_Q/unsubscribe.
To unsubscribe from this group and all its topics, send an email to partkeepr-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/partkeepr-users/74381658-5ab2-41ff-b0f8-4eccec8615cdn%40googlegroups.com.

Daniel Calcoen

unread,
Apr 12, 2021, 3:26:05 PM4/12/21
to PartKeepr Users
Dear Jura
Better Word than PDF.
From Word I can copy and paste the text and images, then I reformat, the wiki pages are html.
The PDF is an object that can not be edited, just attached.
to have an idea in this page
there is a PDF attached in the second line

Regards
Daniel

Jurica Grcic

unread,
Apr 12, 2021, 3:27:58 PM4/12/21
to Daniel Calcoen, PartKeepr Users
OK, I will prepare a Word file.
As soon as I do, I will reply to this message.

Best regards,

Jura

Marwan Alhashmi

unread,
May 9, 2022, 8:25:01 AM5/9/22
to PartKeepr Users
Dear Jura,

I am interested in this project and the Word file would be a great help if you could share it.

Thanks,

Jurica Grcic

unread,
May 10, 2022, 11:09:44 AM5/10/22
to Marwan Alhashmi, PartKeepr Users
Dear Marwan,

Unfortunately I never finished this project. It works 90% but I never made any documentation.
After the summer I will probably have some time to finish the project and make the docs.

Jura


john griessen

unread,
May 10, 2022, 11:35:33 AM5/10/22
to PartKeepr Users
On 5/10/22 09:09, Jurica Grcic wrote:
> Dear Marwan,
>
> Unfortunately I never finished this project. It works 90% but I never made any documentation.
> After the summer I will probably have some time to finish the project and make the docs.

What kind of integration were you planning? Bill of materials to inventory check list in preparation to a production run?

Create a component inventory listing at same time as footprint entry with manufacturer, part number, distributors, alternate part
numbers as attributes?

I'd help with scripting for using pcb-rnd and sch-rnd FOSS layout and schematic tools.

--
John Griessen

Jurica Grcic

unread,
May 10, 2022, 11:43:17 AM5/10/22
to john griessen, PartKeepr Users
Hi John,

I have (partially) implemented a functionality which allows a user to enter a part in PartKeeper and that part is "visible" in an Altium Designer library.
Users put parameters in PartKeepr which describe the footprint and schematic symbol type.
This allows you to place parts on the schematic and on to the PCB.
The library type is DbLib (database library). The functionality goes only one way, meaning that if you change any info about the part in Altium it is not visible in PartKeepr.

It has not been tested yet. Most, if not all, of the code is written in SQL meaning that the code is very ugly and hard to maintain.

Jura



--
You received this message because you are subscribed to the Google Groups "PartKeepr Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to partkeepr-use...@googlegroups.com.

john griessen

unread,
May 10, 2022, 12:28:42 PM5/10/22
to Jurica Grcic, PartKeepr Users
On 5/10/22 09:43, Jurica Grcic wrote:
> I have (partially) implemented a functionality which allows a user to enter a part in PartKeeper and that part is "visible" in an
> Altium Designer library.

That sounds like a really useful tool. From the altium viewpoint, how do you define the pins and package from partkeepr? Do you
define that later in altium? Do you start with a no-pins symbol or footprint?

For foss tools starting with the schematic editor would be a natural way, then export to partkeepr. Creating a layout package
footprint or schematic symbol usually needs some pins defined is my thinking there.

--
John Griessen

Jurica Grcic

unread,
May 10, 2022, 12:40:35 PM5/10/22
to john griessen, PartKeepr Users
The tool/script is a blend of an official Altium Designer tutorial on how to integrate 3rd party databases into Altium.
The other part is fiddling with SQL in order to prepare the data in a format that Altium can interpret (this is the ugly SQL part).

The way the thing works is like this:
In PartKeepr you add 5 parameters to a part.
The first parameter tells the script whether this part will be visible in Altium or not.
The second parameter is the name of the schematic symbol.
3th parameter is the path to the SCH library.
4th parameter is the name of the Footprint.
5th parameter  is the path to the PCBLib library.

Altium allows multiple SCH and PCB symbols so you can actually have more than one SCH/PCB symbol/footprint.






--
You received this message because you are subscribed to the Google Groups "PartKeepr Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to partkeepr-use...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages