inventree-kicad-plugin


Nameinventree-kicad-plugin JSON
Version 1.4.0 PyPI version JSON
download
home_pagehttps://github.com/afkiwers/inventree_kicad
SummaryKiCad HTTP library plugin for InvenTree
upload_time2024-04-05 19:48:01
maintainerNone
docs_urlNone
authorAndre Iwers
requires_python>=3.9
licenseMIT
keywords inventree kicad pcb schematic inventory
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # InvenTree KiCad - HTTP Library Plugin

A KiCad Conform API endpoint plugin, designed for integration with [InvenTree](https://inventree.org), empowers users to seamlessly incorporate InvenTree parts into KiCad's parts library tool. Please note that this plugin exclusively offers metadata and necessitates the presence of corresponding symbol and footprint libraries within the KiCad EDA environment.

As of the current stage of development, KiCad exclusively offers read-only access to parts through the HTTP lib interface.

However, this plugin provides a metadata import tool to import changes made within KiCad. This enables users to add footprints, symbols and datasheets to individual parts during the schematic design process if not already available and re-import that information into InvenTree to have it available for the next time.

## Installing the Plugin

There are several methods available for installing this plugin. To gain a comprehensive understanding of the installation process, please refer to the [InvenTree - Installing a Plugin Guide](https://docs.inventree.org/en/latest/extend/plugins/install/#installation-methods). Depending on your preferred approach, the following instructions will provide you with the necessary information.

Prior to plugin installation, ensure that you've activated both **URL Integration** and **App Integration**. You can accomplish this by going to Settings → Plugin Settings → Plugins. Additionally, if you're operating within a Docker environment, be sure to enable **Check plugins on startup** as well.

![image](https://raw.githubusercontent.com/afkiwers/inventree_kicad/main/images/plugin_general_settings.png)

### Through GitHub

Navigate to the **Plugin Settings** and click on the Install Plugin button. This will trigger a new window to appear, prompting you to enter the following information:

- Package Name: inventree-kicad-plugin
- Source URL: <git+https://github.com/afkiwers/inventree_kicad>

![image](https://raw.githubusercontent.com/afkiwers/inventree_kicad/main/images/install_plugin_via_github_url.png)

### Through PiP

The plugin can be found here: [inventree-kicad-plugin](https://pypi.org/project/inventree-kicad-plugin/).

- Package Name: inventree-kicad-plugin

![image](https://raw.githubusercontent.com/afkiwers/inventree_kicad/main/images/pip_install.png)

**IMPORTANT**: Remember to restart your server and run the migrate command to implement the model changes required for this plugin. Failure to do so may result in the plugin encountering issues and not functioning correctly.

## Configure Plugin Settings

After installing the plugin, head over to the Plugin Settings and activate it. Look for **KiCadLibraryPlugin** in the list of available plugins. 

![image](https://raw.githubusercontent.com/afkiwers/inventree_kicad/main/images/plugin_settings.png)


Once activated, you'll see a new plugin **KiCad Library Endpoint** on the left hand side. Click on it to open the plugin and proceed with the setup process.

![image](https://raw.githubusercontent.com/afkiwers/inventree_kicad/main/images/new_plugin.png)


## Adding Categories to KiCad

Navigate to the admin backend, and scroll down until you find the **INVENTREE_KICAD** section. Within this section, click on **KiCad Categories**.
If the section is not visible, ensure you've enabled the "Enable URL integration" and "Enable app integration" options in the Plugin Settings and run a database migration.

![image](https://raw.githubusercontent.com/afkiwers/inventree_kicad/main/images/admin_model.png)

Once opened the "KiCad Categories" model, you'll have the option to add new categories which, once added, will be visible in KiCad's Symbol Chooser dialog.

![image](https://raw.githubusercontent.com/afkiwers/inventree_kicad/main/images/admin_add_change_categories.png)

#### Default Settings for Categories

The plugin allows you to set default values when the child part lacks specific details regarding the KiCad symbol, footprint, or reference. This feature is particularly useful when dealing with components such as resistors or capacitors, as they often share the same symbols, reducing the need for repetitive data entry.

![image](https://raw.githubusercontent.com/afkiwers/inventree_kicad/main/images/admin_add_category.png)

#### Utilizing Footprint Parameter Mapping

If you have existing Footprint/Package Type parameters assigned to your components and prefer not to define a separate KiCad Footprint Parameter for them, you can leverage the Footprint Parameter Mapping functionality to establish a connection to KiCad Footprint names. Simply incorporate the desired mappings into the KiCad category:

![image](https://raw.githubusercontent.com/afkiwers/inventree_kicad/main/images/admin_footprint_mappings.png)

Additionally, you can combine this with the per-category "Footprint Parameter Template" override to utilize a different parameter for mapping purposes.

![image](https://raw.githubusercontent.com/afkiwers/inventree_kicad/main/images/admin_footprint_parameter_override.png)

## Creating User Access Tokens

Return to the administrative backend, navigate to the USER model, and access API Tokens. Select "ADD API Token" to generate a token designated for a specific user. It's crucial to highlight the importance of creating separate tokens for each user, rather than using a universal token for everyone.

![image](https://raw.githubusercontent.com/afkiwers/inventree_kicad/main/images/admin_tokens.png)

## KiCad HTTP Library File

Below is an example config which should help you get started reasonably quickly. The only thing needed here is to replace **<http://127.0.0.1:8000>** with your server's InvenTree URL, and replace usertokendatastring with a valid token. Save it as a file with `.kicad_httplib` extension, as specified in the [preliminary KiCad docs](https://docs.kicad.org/master/en/eeschema/eeschema_advanced.html#http-libraries). To use it, add it as a symbol library inside KiCad.

**Please Note**: The config file does not contain any part or category information. It merely tells KiCad what API to expect, what token to use and where to find it.

```json
{
    "meta": {
        "version": 1.0
    },
    "name": "KiCad HTTP Library",
    "description": "A KiCad library sourced from a REST API",
    "source": {
        "type": "REST_API",
        "api_version": "v1",
        "root_url": "http://127.0.0.1:8000/plugin/kicad-library-plugin",
        "token": "usertokendatastring",
        "timeout_parts_seconds": 60,
        "timeout_categories_seconds": 6000
    }
}
```

## Add the HTTP library to KiCad

Inside KiCad's project manager, navigate to `Preferences -> Manage Symbol Libraries` and click on it. Add a GLobal Library by pressing the folder in the bottom left corner.
![image](https://raw.githubusercontent.com/afkiwers/inventree_kicad/main/images/add_symbol_lib.png)

When choosing the `.kicad_httplib` file, KiCad will automatically detect that it is a HTTP lib file and only a Nickname needs to be set.

It's recommended to put a **#** as prefix to make sure it is at the top of the list. Otherwise one might end up scrolling a lot.

## Display Stock Information in KiCad
If activated KiCad will show stock data inside the symbol chooser. The data will be updated whenever the set category timeout expires ([`timeout_categories_seconds`](#kicad-http-library-file)). 

![image](https://raw.githubusercontent.com/afkiwers/inventree_kicad/main/images/stock_data_settings.png)

Users have the option to determine the presentation style of stock data through the **Stock Count Display Format** as shown above. In this setting, {0} represents the item description, while {1} represents the stock information as a numerical value. Using those placeholders, users can customize how this data is merged and showcased according to their preferences. An example of how this would look is shown below. 

**Please Note:** The stock information is not transferred into the schematic. It is only visible inside the symbol chooser!

![image](https://raw.githubusercontent.com/afkiwers/inventree_kicad/main/images/stock_data.png)


## Use in KiCad

Once everything has been configured properly, KiCad should be able to display all the categories and parts using the Symbol Picker.

Inside the schematic, one can either use the shortcut and press **A** or navigate to the ribbon at the top and press `Place -> Add Symbol`.

![image](https://raw.githubusercontent.com/afkiwers/inventree_kicad/main/images/eeschema_open_chooser.png)

The Symbol Chooser should open up and display the parts sourced from InvenTree.

![image](https://raw.githubusercontent.com/afkiwers/inventree_kicad/main/images/symbol_chooser.png)

## Importing Metadata from Previous Projects

Since KiCad does not offer a way to push information back to the server, InvenTree needs to have all that metadata such as footprints and symbols added manually. This can be very tedious, especially when there are thousands of parts.

This plugin's import tool uses KiCad's intermediate file which is created whenever there is a BOM export. This file contains all the project's data which is needed.

![image](https://raw.githubusercontent.com/afkiwers/inventree_kicad/main/images/kicad_meta_data_import.png)

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/afkiwers/inventree_kicad",
    "name": "inventree-kicad-plugin",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": "inventree kicad pcb schematic inventory",
    "author": "Andre Iwers",
    "author_email": "iwers11@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/1e/b7/0847501b535aa10a2e8f158a769f446c58fced3c1dcd256938c574dec221/inventree-kicad-plugin-1.4.0.tar.gz",
    "platform": null,
    "description": "# InvenTree KiCad - HTTP Library Plugin\n\nA KiCad Conform API endpoint plugin, designed for integration with [InvenTree](https://inventree.org), empowers users to seamlessly incorporate InvenTree parts into KiCad's parts library tool. Please note that this plugin exclusively offers metadata and necessitates the presence of corresponding symbol and footprint libraries within the KiCad EDA environment.\n\nAs of the current stage of development, KiCad exclusively offers read-only access to parts through the HTTP lib interface.\n\nHowever, this plugin provides a metadata import tool to import changes made within KiCad. This enables users to add footprints, symbols and datasheets to individual parts during the schematic design process if not already available and re-import that information into InvenTree to have it available for the next time.\n\n## Installing the Plugin\n\nThere are several methods available for installing this plugin. To gain a comprehensive understanding of the installation process, please refer to the [InvenTree - Installing a Plugin Guide](https://docs.inventree.org/en/latest/extend/plugins/install/#installation-methods). Depending on your preferred approach, the following instructions will provide you with the necessary information.\n\nPrior to plugin installation, ensure that you've activated both **URL Integration** and **App Integration**. You can accomplish this by going to Settings \u2192 Plugin Settings \u2192 Plugins. Additionally, if you're operating within a Docker environment, be sure to enable **Check plugins on startup** as well.\n\n![image](https://raw.githubusercontent.com/afkiwers/inventree_kicad/main/images/plugin_general_settings.png)\n\n### Through GitHub\n\nNavigate to the **Plugin Settings** and click on the Install Plugin button. This will trigger a new window to appear, prompting you to enter the following information:\n\n- Package Name: inventree-kicad-plugin\n- Source URL: <git+https://github.com/afkiwers/inventree_kicad>\n\n![image](https://raw.githubusercontent.com/afkiwers/inventree_kicad/main/images/install_plugin_via_github_url.png)\n\n### Through PiP\n\nThe plugin can be found here: [inventree-kicad-plugin](https://pypi.org/project/inventree-kicad-plugin/).\n\n- Package Name: inventree-kicad-plugin\n\n![image](https://raw.githubusercontent.com/afkiwers/inventree_kicad/main/images/pip_install.png)\n\n**IMPORTANT**: Remember to restart your server and run the migrate command to implement the model changes required for this plugin. Failure to do so may result in the plugin encountering issues and not functioning correctly.\n\n## Configure Plugin Settings\n\nAfter installing the plugin, head over to the Plugin Settings and activate it. Look for **KiCadLibraryPlugin** in the list of available plugins. \n\n![image](https://raw.githubusercontent.com/afkiwers/inventree_kicad/main/images/plugin_settings.png)\n\n\nOnce activated, you'll see a new plugin **KiCad Library Endpoint** on the left hand side. Click on it to open the plugin and proceed with the setup process.\n\n![image](https://raw.githubusercontent.com/afkiwers/inventree_kicad/main/images/new_plugin.png)\n\n\n## Adding Categories to KiCad\n\nNavigate to the admin backend, and scroll down until you find the **INVENTREE_KICAD** section. Within this section, click on **KiCad Categories**.\nIf the section is not visible, ensure you've enabled the \"Enable URL integration\" and \"Enable app integration\" options in the Plugin Settings and run a database migration.\n\n![image](https://raw.githubusercontent.com/afkiwers/inventree_kicad/main/images/admin_model.png)\n\nOnce opened the \"KiCad Categories\" model, you'll have the option to add new categories which, once added, will be visible in KiCad's Symbol Chooser dialog.\n\n![image](https://raw.githubusercontent.com/afkiwers/inventree_kicad/main/images/admin_add_change_categories.png)\n\n#### Default Settings for Categories\n\nThe plugin allows you to set default values when the child part lacks specific details regarding the KiCad symbol, footprint, or reference. This feature is particularly useful when dealing with components such as resistors or capacitors, as they often share the same symbols, reducing the need for repetitive data entry.\n\n![image](https://raw.githubusercontent.com/afkiwers/inventree_kicad/main/images/admin_add_category.png)\n\n#### Utilizing Footprint Parameter Mapping\n\nIf you have existing Footprint/Package Type parameters assigned to your components and prefer not to define a separate KiCad Footprint Parameter for them, you can leverage the Footprint Parameter Mapping functionality to establish a connection to KiCad Footprint names. Simply incorporate the desired mappings into the KiCad category:\n\n![image](https://raw.githubusercontent.com/afkiwers/inventree_kicad/main/images/admin_footprint_mappings.png)\n\nAdditionally, you can combine this with the per-category \"Footprint Parameter Template\" override to utilize a different parameter for mapping purposes.\n\n![image](https://raw.githubusercontent.com/afkiwers/inventree_kicad/main/images/admin_footprint_parameter_override.png)\n\n## Creating User Access Tokens\n\nReturn to the administrative backend, navigate to the USER model, and access API Tokens. Select \"ADD API Token\" to generate a token designated for a specific user. It's crucial to highlight the importance of creating separate tokens for each user, rather than using a universal token for everyone.\n\n![image](https://raw.githubusercontent.com/afkiwers/inventree_kicad/main/images/admin_tokens.png)\n\n## KiCad HTTP Library File\n\nBelow is an example config which should help you get started reasonably quickly. The only thing needed here is to replace **<http://127.0.0.1:8000>** with your server's InvenTree URL, and replace usertokendatastring with a valid token. Save it as a file with `.kicad_httplib` extension, as specified in the [preliminary KiCad docs](https://docs.kicad.org/master/en/eeschema/eeschema_advanced.html#http-libraries). To use it, add it as a symbol library inside KiCad.\n\n**Please Note**: The config file does not contain any part or category information. It merely tells KiCad what API to expect, what token to use and where to find it.\n\n```json\n{\n    \"meta\": {\n        \"version\": 1.0\n    },\n    \"name\": \"KiCad HTTP Library\",\n    \"description\": \"A KiCad library sourced from a REST API\",\n    \"source\": {\n        \"type\": \"REST_API\",\n        \"api_version\": \"v1\",\n        \"root_url\": \"http://127.0.0.1:8000/plugin/kicad-library-plugin\",\n        \"token\": \"usertokendatastring\",\n        \"timeout_parts_seconds\": 60,\n        \"timeout_categories_seconds\": 6000\n    }\n}\n```\n\n## Add the HTTP library to KiCad\n\nInside KiCad's project manager, navigate to `Preferences -> Manage Symbol Libraries` and click on it. Add a GLobal Library by pressing the folder in the bottom left corner.\n![image](https://raw.githubusercontent.com/afkiwers/inventree_kicad/main/images/add_symbol_lib.png)\n\nWhen choosing the `.kicad_httplib` file, KiCad will automatically detect that it is a HTTP lib file and only a Nickname needs to be set.\n\nIt's recommended to put a **#** as prefix to make sure it is at the top of the list. Otherwise one might end up scrolling a lot.\n\n## Display Stock Information in KiCad\nIf activated KiCad will show stock data inside the symbol chooser. The data will be updated whenever the set category timeout expires ([`timeout_categories_seconds`](#kicad-http-library-file)). \n\n![image](https://raw.githubusercontent.com/afkiwers/inventree_kicad/main/images/stock_data_settings.png)\n\nUsers have the option to determine the presentation style of stock data through the **Stock Count Display Format** as shown above. In this setting, {0} represents the item description, while {1} represents the stock information as a numerical value. Using those placeholders, users can customize how this data is merged and showcased according to their preferences. An example of how this would look is shown below. \n\n**Please Note:** The stock information is not transferred into the schematic. It is only visible inside the symbol chooser!\n\n![image](https://raw.githubusercontent.com/afkiwers/inventree_kicad/main/images/stock_data.png)\n\n\n## Use in KiCad\n\nOnce everything has been configured properly, KiCad should be able to display all the categories and parts using the Symbol Picker.\n\nInside the schematic, one can either use the shortcut and press **A** or navigate to the ribbon at the top and press `Place -> Add Symbol`.\n\n![image](https://raw.githubusercontent.com/afkiwers/inventree_kicad/main/images/eeschema_open_chooser.png)\n\nThe Symbol Chooser should open up and display the parts sourced from InvenTree.\n\n![image](https://raw.githubusercontent.com/afkiwers/inventree_kicad/main/images/symbol_chooser.png)\n\n## Importing Metadata from Previous Projects\n\nSince KiCad does not offer a way to push information back to the server, InvenTree needs to have all that metadata such as footprints and symbols added manually. This can be very tedious, especially when there are thousands of parts.\n\nThis plugin's import tool uses KiCad's intermediate file which is created whenever there is a BOM export. This file contains all the project's data which is needed.\n\n![image](https://raw.githubusercontent.com/afkiwers/inventree_kicad/main/images/kicad_meta_data_import.png)\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "KiCad HTTP library plugin for InvenTree",
    "version": "1.4.0",
    "project_urls": {
        "Homepage": "https://github.com/afkiwers/inventree_kicad"
    },
    "split_keywords": [
        "inventree",
        "kicad",
        "pcb",
        "schematic",
        "inventory"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "46812ba977d9c80e85e75c26d6ba03f5efad182e241a0024d131b31541e4bbc5",
                "md5": "f980c22e94662a175eddd4115b0b4804",
                "sha256": "931b11856326806df9aa677ab886bdb80fdce6228dc06c07bf25110133e7df3f"
            },
            "downloads": -1,
            "filename": "inventree_kicad_plugin-1.4.0-py2.py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "f980c22e94662a175eddd4115b0b4804",
            "packagetype": "bdist_wheel",
            "python_version": "py2.py3",
            "requires_python": ">=3.9",
            "size": 24867,
            "upload_time": "2024-04-05T19:47:59",
            "upload_time_iso_8601": "2024-04-05T19:47:59.192169Z",
            "url": "https://files.pythonhosted.org/packages/46/81/2ba977d9c80e85e75c26d6ba03f5efad182e241a0024d131b31541e4bbc5/inventree_kicad_plugin-1.4.0-py2.py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "1eb70847501b535aa10a2e8f158a769f446c58fced3c1dcd256938c574dec221",
                "md5": "1c521a157f89d80da202f90ea1dce520",
                "sha256": "284dc955b1102fb51962a205dc68a34bd09d8202db4cadac8cb7dacd8e24fc6b"
            },
            "downloads": -1,
            "filename": "inventree-kicad-plugin-1.4.0.tar.gz",
            "has_sig": false,
            "md5_digest": "1c521a157f89d80da202f90ea1dce520",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 21029,
            "upload_time": "2024-04-05T19:48:01",
            "upload_time_iso_8601": "2024-04-05T19:48:01.119545Z",
            "url": "https://files.pythonhosted.org/packages/1e/b7/0847501b535aa10a2e8f158a769f446c58fced3c1dcd256938c574dec221/inventree-kicad-plugin-1.4.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-05 19:48:01",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "afkiwers",
    "github_project": "inventree_kicad",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "inventree-kicad-plugin"
}
        
Elapsed time: 0.31348s