clj / kom2 Goto Github PK
View Code? Open in Web Editor NEWInterface KiCad database libraries with non-ODBC systems using magic
License: MIT License
Interface KiCad database libraries with non-ODBC systems using magic
License: MIT License
e.g.: https://inventree.server/api/part/123/?parameters=1
Freeing handles should only be possible when all other "child" handles have been freed. This would mean tracking the relationship between handles, which isn't happening at the moment:
This is more of a nice to have, since I doubt KiCad would be trying to release handles out of order
When using pk
as key the pk is not rendered:
When using IPN
as key the IPN is rendered as name. The part can be added in that case. Note: Only one part has an IPN set
Once I click on an item without a label KiCad goes away.
Version KiCad:
Application: KiCad Schematic Editor arm64 on arm64
Version: 7.0.5-0, release build
Libraries:
wxWidgets 3.2.2
FreeType 2.12.1
HarfBuzz 5.3.1
FontConfig 2.14.0
libcurl/7.88.1 (SecureTransport) LibreSSL/3.3.6 zlib/1.2.11 nghttp2/1.51.0
Platform: macOS Ventura Version 13.4 (Build 22F66), 64 bit, Little endian, wxMac
Build Info:
Date: May 26 2023 08:14:40
wxWidgets: 3.2.2 (wchar_t,wx containers)
Boost: 1.80.0
OCC: 7.6.3
Curl: 7.77.0
ngspice: 38
Compiler: Clang 13.0.0 with C++ ABI 1002
Build settings:
KICAD_SPICE=ON
Version kom2:
[release-20230522](https://github.com/clj/kom2/releases/tag/release-20230522)
It would be great if one could define an optional config identifier to the connection string. That could then be passed to the InvenTree API as a header and be used server side to identify which host is using which config. Would be usedfull to detect outdated configs.
We need to figure out what we can use to uniquely reference a Part from KiCad. This is needed both for the documentation but also because the driver needs to know what "columns" to offer up as unique to KiCad (since it enumerates the tables on startup).
The KiCad documentation states about the contents of the .kicad_dbl file:
key
: The column name containing a unique key that will be used to identify parts from the table.
So we need something that always returns the same part for the same value of key
. As far as I understand it, the only things I can use from a Part instance in InvenTree that is unique is either:
pk
; orname
, IPN
, and revision
(see: the InvenTree Part model); orIPN
, there is the potential for them to be mostly unique, but this isn't a DB level constraint so it is possible that duplicate IPNs exist in the DB. In this case we would need to make sure that we always return the same part to KiCad if there happens to be multiple parts with the same IPN. The IPN field can also be empty, see: #5.In the InvenTree documentation the description of the name
for a part says:
Name - The Part name is a simple (unique) text label
But unless combined with IPN
and revision
that doesn't seem to be the case.
What KiCad displays the "item" column is a combination of the library name
and the value of each item's key
as defined in the .kicad_dbl file. This means that using the pk
(i.e. the Primary Key of a Part instance) yields names that aren't very "nice" (image from: #2 (comment)):
IPN
is perhaps a bit nicer, at least how I use it. But I fear that the combination of name
, IPN
and revision
might be a bit long. Although this would depend on what users have in the name column for their Parts.
Hi there! Very nice work here; I would recommend adding a check somewhere for the API version (https://demo.inventree.org/api/) to make sure you're not running into too old instances.
Would love to see Windows support, and happy to provide time / code to implement.
@clj any pointers where to start? I have zero experience with Go or ODBC ;)
See issue #3 for an example of how rows with an empty IPN are shown in KiCad, but does not produce useful behaviour and sometimes (but not always) causes KiCad to crash.
I am not sure what the best way to deal with this is. The problem is that the driver is implemented so that filtering can be done either using:
pk
; orIPN
When the initial SELECT * FROM "category"
is issued, the driver doesn't know which is being used. This means if the driver always filters out rows without an IPN
then the driver becomes unusable for people who set the key to pk
, since if they don't use IPNs at all, then all the rows will get filtered. As an example, the InvenTree demo server does not always have IPNs attached to parts.
How to solve:
I saw an interesting crash the first time I loaded the data. The following request was made to the API, and then KiCad crashed:
Originally posted by @SchrodingersGat in #2 (comment)
Probably by the part primary key. This would primarily be to make parts with duplicate IPN behave deterministically. E.g. if we say that if there are more than one part with the same IPN, and the first one is the one that we return to KiCad, then ordering by PK would ensure that this part is always the same.
?ordering=pk
should achieve that.
@clj if you are not already, I suggest that you use an API token to perform requests. It is significantly faster than username/password auth.
If you are already doing this, please ignore and close out this issue :)
I have discovered one source of crash:
If your .kicad_dbl
configuration file has invalid InvenTree credentials, KiCad simply crashes without warning.
This is repeatable, and there is no "error message" or anything, simply a hard crash out of the KiCad application
If possible within the kicad_dbl
file format, it would be very handy to be able to add a "filters" attribute to each library entry.
For example, only return parts in the "Resistors" category which have the "KiCadFootprint" parameter defined
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.