Ki-nTree - Fast part creation for KiCad and InvenTree

Hello @Kedarius

Very nice feedback, thanks for taking the time to write it!

That cryptography library you are referring to is necessary to run the pyopenssl library used by the digikey-api package allowing to pull data from Digi-Key. In your case it might feel unnecessary but Digi-Key is one of the biggest distributors in North America and used by many companies and people. Sorry for causing you trouble but happy to hear that you got Ki-nTree running fine on your machine :smiley:

Let’s find out how can we improve it :wink:

Have you scrolled past this section maybe? GitHub - sparkmicro/Ki-nTree: Fast part creation in KiCad and InvenTree
Or wasn’t it clear to you?

Would love to look at this issue if it’s still happening after category setup, would you mind opening one here and post the log output of Ki-nTree: Issues · sparkmicro/Ki-nTree · GitHub

Right that’s something I tried to improve in version 0.6.0 but it still not immune to creating new companies when it thinks they don’t exist yet in the database… It might require a download of the database and manual pick from user, in my experience it takes a few more manual step in InvenTree to fix this and happens only in very rare occasions, especially after the 0.6.0 version release.

Those are two intended behaviors at the moment.

Granted those are not well documented, if you have any question regarding those, don’t hesitate to open an issue, I’ll be happy to get back to you :smiley:

See my comment above, I didn’t really want to introduce a new lookup table just for this.

Concerning your feature proposals:

I never looked into their API, seems straight forward! I will add it soon :partying_face:

It’s a work in progress: Support hierarchical categories · Issue #87 · sparkmicro/Ki-nTree · GitHub
May take a bit more time to implement.

Will think about this one a bit more, thanks for bringing it up :wink:

I’m not sure what do you intend to do with the downloaded datasheet: where do you want it to be stored? Why would you need the datasheet locally?
My colleagues and I store all the datasheet links in InvenTree under “Suppliers” tab (Ki-nTree does that) and that’s how we use them.

Fair enough, I will look into this too.

Thanks again!

Thanks for your reply.

I understand that the openssl binding library is important and the reasoning behind why it is needed, but I’ve never had to install 6GB+ of development tool to use openssl. It took me cca an hour to download and install just the minimal set of features :slight_smile:

You got me on this :slight_smile: I glanced trough this section and I did not do it as it seemed to me as it is related to setting up categories in inventree - I mean the direction Ki-nTree → Inventree. And I am already using inventree with my own categories, so I did not want to make mess in my inventree.

What I am missing is some sort of top-level overview, what are the files used for and what can/must be done with them.

Other way could be to put the new part into one predefined category and I will move it later from Inventree.

I am using inventree also as a “local” storage for all the related files - datasheets, ECAD models, drivers, utilities,… So on the attachment tab I have a collection of all related files. I.e. datasheet from the manufacturer, from the vendor, snapeda ECAD files, Mouser ECAD files, etc… And why locally? As some of the files are from various strange sites, I prefer to store them instead of just linking them. For example I have some drivers related to an ancient HW that we still need to use and it is from a company that does not exist anymore. Or I am using a cheap USB microscope where I downloaded the docs from some Chinese “dropbox-like” site…

1 Like

Unfortunately I don’t quite know what to do with this info… if you have a well documented workaround I can add it to the README.

Done, checkout: GitHub - sparkmicro/Ki-nTree: Fast part creation in KiCad and InvenTree

I have added it to the TODO list for the moment. I may revamp the download to local files part of the software so it can be redirect to anywhere on your filesystem.

In other news I added Element14 API integration to Ki-nTree, check it out and let me know if you have any issue!

Oh and you can now disable IPN auto-creation in the configuration files (see release notes).

The cryptography package is available as a binary wheel on Windows – if you run pip install cryptography nothing needs to be compiled. @Kedarius what version of Windows are you using?

Wow, looks like very promising, I will try it tommorow and report back.

1 Like

I am using Windows 10 but my python knowledge is limited to a simple programs. I do not know what pip does in the background. I have no idea what binary wheel means (although I guess that it is some sort of prebuilt package) and I have no idea what kintree pip needs or uses…
But I did
pip install -U kintree
and it said something like this:

error: Microsoft Visual C++ 14.0 is required. Get it with "Microsoft Visual
C++ Build Tools": http.....

(I am not sure that this is the exactly same error message as I already installed VS but it looks the same). And after some googling and stackoverflowing I’ve found that people recommend installing Visual Studio. And also a lengthy discussions that you should compile your own crypto libraries because it is more secure…

So I’ve tried to install the minimal installation of the Visual Studio and the error message changed to some missing header files. Which turned out that I needed Windows 10/11 SDK.

And after installing that pip was happy and kintree started…

I have a programming background, just installed VS from the link which took me to a general page of Microsoft Tools, but am lacking the time to look at this. Here is the error message I get under Windows 11, which I hope is helpful, until I have time to find my own way around this install issue.

I should mention I just updated KiCad to 6.0.10 prior to this install:
Application: KiCad PCB Editor (64-bit)

Version: (6.0.10), release build

Libraries:
wxWidgets 3.2.1
libcurl/7.86.0-DEV Schannel zlib/1.2.13

Platform: Windows 11 (build 22621), 64-bit edition, 64 bit, Little endian, wxMSW

Build Info:
Date: Dec 19 2022 21:23:04
wxWidgets: 3.2.1 (wchar_t,wx containers)
Boost: 1.80.0
OCC: 7.6.2
Curl: 7.86.0-DEV
ngspice: 38
Compiler: Visual C++ 1929 without C++ ABI

Build settings:
KICAD_USE_OCC=ON
KICAD_SPICE=ON

What is the command you ran to get this error? It is not shown in your prompt.

Also a bit confused on what are you trying to do…? Ki-nTree is separate from KiCad so it is unrelated to your issue with the python-Levenshtein library.

First I would like to thank you for such a quick update. Almost everything I need is working now and it basically changed the tool from “unusable for me” to “usable with minor issues” :slight_smile:

As I said in other post, although I have a multi-decade programmer background, I do not know the python ecosystem (mainly PIP) inner workings. But I have installed a quite a few pip packages (i.e. fpga development chain) and I never had to install Visual C. However that solved it for me and if it was only mine problem then it is fine…

Great, this is exactly what I wanted. The only part that I am still confused about are the categories :slight_smile: I feel like just something is not clicking in the right place in my brain and/or there is something that I am completely missing.
I have a structure in my inventree, for example:

So all the components are in a component main category and there are subcategories like Capacitor, Button, Resistor,…
So I edited the categories.yaml to contain a few of them to test it:

CATEGORIES:
  Component:
  - Resistor
  - Logic
  - Capacitor
  - Button
CODES: null

But when I try to add a part from farnell, Ki-nTree still shows some categories from somewhere (maybe from digikey_categories.yaml ?):

image

However if I select Component and enter a custom name Resistor, then it works :slight_smile: So there is a way however it would be much better if I would be able to select the category from the combobox…

This works fine, I only found a small glitch that the Ki-nTree crashes if there is no store selected. But it crashes even as I try to open the config dialog, so I had to manually specify the store in the config file…

Traceback (most recent call last):
...
File "C:\Users\root\AppData\Roaming\Python\Python38\site-packages\kintree\kintree_gui.py", line 226, in element14_api_settings_window
sg.Text(f'URL: {element14_api.STORES[supplier][default_store]}', key='store_url'),                                                                                                                             KeyError: None                                                                 

Great it works fine…

And last thing is the Manufacturer naming. I found out that you can setup supplier name in its config and that solved a lot of work for me. This should be mentioned in the README as it is a very useful option. And one last thing (except for being able to select the company from a combobox), would it be possible to match the company in inventree case insensitive?
image

Once more thank you for a great work.

1 Like

Thanks @Kedarius for your appreciation and feedback, I went over it and here are my comments:

This is all good! Unfortunately yes the dropdown list is a bit of legacy code and gets overwritten with Digi-Key categories as at first it was the only supplier supported by Ki-nTree. Since then I added many more suppliers and this part of the code needs a good refresh, which I was planning to do when integrating hierarchical categories selection pulled directly from InvenTree.

Also the first time, you will get all the subcategories showing up when you click the “Confirm” button next to it. However the next time around, only one will show up… The workaround is to add this in your digikey_categories.yaml file:

Component:
  Resistor: null
  Logic: null
  Capacitor: null
  Button: null

Then it should work every time.

Lastly, you still have the option to overwrite the default configuration files in your Ki-nTree installation path:

Even if I don’t recommend it as it will be overwritten when updating :laughing:

Anyway as I said, big refactoring of part of the software is needed!

Fixed in 0.6.5, thanks for reporting it. Do you have a Github account? I would prefer those issue reported there (easier to track): Issues · sparkmicro/Ki-nTree · GitHub

Try 0.6.5 as I propagated the manufacturer name match method to the main part creation flow (it was reserved to alternate part until now).
I have tested it with my local work database and should work fine.

I finally managed to get the component categories working via inserting them to the digikey_categories.yaml file. Also the company matching now is case insensitive which is great.

I will report future bugs in GitHub.

1 Like

For anybody interested in the project, I am currently migrating Ki-nTree to a newer, nicer looking GUI framework called Flet: https://flet.dev/

I have released the first version (1.0.0 alpha1) :partying_face:




To try it out:

pip install -U kintree --pre

Let me know what you think!

8 Likes

Hello everyone,
I’m trying to install Ki-nTree but I’m stuck with the error message “Microsoft Visual C++ 14.0 is required”.

 × python setup.py bdist_wheel did not run successfully.
  │ exit code: 1
  ╰─> [27 lines of output]
      running bdist_wheel
      running build
      running build_py
      creating build
      creating build\lib.win-amd64-3.8
      creating build\lib.win-amd64-3.8\Levenshtein
      copying Levenshtein\StringMatcher.py -> build\lib.win-amd64-3.8\Levenshtein
      copying Levenshtein\__init__.py -> build\lib.win-amd64-3.8\Levenshtein
      running egg_info
      writing python_Levenshtein.egg-info\PKG-INFO
      writing dependency_links to python_Levenshtein.egg-info\dependency_links.txt
      writing entry points to python_Levenshtein.egg-info\entry_points.txt
      writing namespace_packages to python_Levenshtein.egg-info\namespace_packages.txt
      writing requirements to python_Levenshtein.egg-info\requires.txt
      writing top-level names to python_Levenshtein.egg-info\top_level.txt
      reading manifest file 'python_Levenshtein.egg-info\SOURCES.txt'
      reading manifest template 'MANIFEST.in'
      warning: no previously-included files matching '*pyc' found anywhere in distribution
      warning: no previously-included files matching '*so' found anywhere in distribution
      warning: no previously-included files matching '.project' found anywhere in distribution
      warning: no previously-included files matching '.pydevproject' found anywhere in distribution
      writing manifest file 'python_Levenshtein.egg-info\SOURCES.txt'
      copying Levenshtein\_levenshtein.c -> build\lib.win-amd64-3.8\Levenshtein
      copying Levenshtein\_levenshtein.h -> build\lib.win-amd64-3.8\Levenshtein
      running build_ext
      building 'Levenshtein._levenshtein' extension
      error: Microsoft Visual C++ 14.0 is required. Get it with "Build Tools for Visual Studio": https://visualstudio.microsoft.com/downloads/

I have installed Visual Studio Build Tools 2022. Is there anything else I should install?

Hello @Insanoff and sorry for your trouble.

Do you mind opening an issue here and I can follow-up there? Thanks!

The new UI looks very nice and works great.

1 Like

I’m glad you like it!

I have just released beta1 which offers much more user customization for the part creation flow (most were previously hidden in the background…), check it out and let me know what you think :wink:

The 1.0.0 release is finally out! :tada:
Checkout the README for an updated demo video and info: GitHub - sparkmicro/Ki-nTree: Fast part creation for KiCad and InvenTree

You can update with: pip install -U kintree

I hope you’ll enjoy the new GUI and features!

4 Likes

It’s pretty cool. I’m liking it so far! Setting it and Inventree up were mostly painless - thanks for the help on Github. Got the first few parts in the db already.

A minor quibble is around part search on Digikey - would it be possible to search on a smaller fragment of the part number? It seems it needs the search to return only one result to be successful, which I totally get from a programming standpoint but is a mild pain point when bulk-adding existing stocked parts.

The option to set stock level when adding a new part would also be nice. Just a ‘quantity’ text box, and then have ki-ntree create a stock item after part creation.

All in all, I’m looking forward to using it :slight_smile:

2 Likes

Hello @ScoPi

Glad to hear you like it!

Regarding multiple search results, that is something that could be done but never were asked for.
I’m thinking a pop-up window with a list of the parts from the search result where you could select one.
I’m not sure I understand your use-case though, do you want to add multiple parts at the same time?

Stock item option could be added to the InvenTree view yes, this is doable.

Do you mind opening separate issues on the Github repository to discuss further?

Thanks!