inventree
Inventree
Used plugins
- inventree-kicad-plugin
- inventree-bulk-plugin
- inventree-ipn-generator
Inventree Bulk Plugin
Generate resistors
{"name":"","template_type":"PART","template":{"version":"1.2.3","input":{"firstDecade":"-3","tolerance":"1","decimalPlacesInBaseValues":"2","unitLetter":"R"},"templates":[],"output":{"parent_name_match":"true","dimensions":["1.0, 1.2, 1.5, 1.8, 2.2, 2.7, 3.3, 3.9, 4.7, 5.6, 6.8, 8.2","*NUMERIC","01005,0201,0402,0603,0805,1206,1210,2010,2512"],"count":["","11",""],"generate":{"name":"RES SMD {{global.descriptionValueStr}} OHM {{inp.tolerance}}% {{global.powerDescription}} {{global.footprintCode}}","parameters":[{"template":"1","value":"{{global.titleValueStr}}"},{"template":"7","value":"{{inp.tolerance}}"},{"template":"8","value":"-{{inp.tolerance}}"},{"template":"23","value":"{{global.power}}"},{"template":"27","value":"Thick Film"},{"template":"24","value":"100"},{"template":"25","value":"-100"},{"template":"3","value":"155"},{"template":"4","value":"-55"},{"template":"6","value":"{{global.footprintName}}"},{"template":"26","value":"{{global.footprintCode}}"}]},"global_context":"{# Prepare lookup tables #}\n{% set prefixes = {-4: 'p', -3: 'n', -2: 'u', -1: 'm', 0: inp.unitLetter, 1: 'k', 2: 'M', 3: 'G', 4: 'T'} %}\n{% set footprintNames = {'01005': '01005 (0402 Metric)','0201': '0201 (0603 Metric)','0402': '0402 (1010 Metric)','0603': '0603 (1608 Metric)','0805': '0805 (2012 Metric)','1206': '1206 (3216 Metric)','1210': '1210 (3225 Metric)','2010': '2010 (5025 Metric)','2512': '2512 (6332 Metric)'} %}\n{% set footprintPower = {'01005': '30m','0201': '50m','0402': '62.5m','0603': '100m','0805': '125m','1206': '250m','1210': '500m','2010': '750m','2512': '1'} %}\n{% set footprintDescriptionPower = {'01005': '1/32W','0201': '1/20W','0402': '1/16W','0603': '1/10W','0805': '1/8W','1206': '1/4W','1210': '1/2W','2010': '3/4W','2512': '1W'} %}\n\n{# Prepare arguments and dimensions #}\n{% set baseValue = dim.1|float %}\n{% set decade = (dim.2|int-1)+(inp.firstDecade|int) %}\n{% set footprintCode = dim.3|string %}\n{% set footprintName = footprintNames[footprintCode] %}\n\n{# Calculate which prefix we are having #}\n{% set prefixIndex = decade//3 %}\n{% set prefix = prefixes[prefixIndex] %}\n\n{# Calculate values for different text formattings and round them to avoid float artifacts #}\n{% set actualValue = (baseValue * 10 ** decade)|round(inp.decimalPlacesInBaseValues|int -decade) %}\n{% set prefixedValue = (baseValue * 10 ** (decade % 3))|round(inp.decimalPlacesInBaseValues|int) %}\n\n{# Format a string for the value in my personal prefered format #}\n{% set titleValueStr = prefixedValue|string|replace('.',prefix)|trim('0') %}\n\n{# Format a string for the value in DigiKeys description format #}\n{# The adding of the @ sign is just an ugly way of inventing trim trailing characters.. #}\n{% if decade >= 0 and decade < 3 %}\n{% set descriptionValueStr = ('@'+prefixedValue|string)|trim('0')|trim('.')|trim('@') %}\n{% else %}\n{% set descriptionValueStr = ('@'+prefixedValue|string)|trim('0')|trim('.')|trim('@') + prefix %}\n{% endif %}\n\n{% set power = footprintPower[footprintCode] %}\n{% set powerDescription = footprintDescriptionPower[footprintCode] %}"}}}
Working config
## Last bit of .env file ## # Site URL - update this to match your host (and update the Caddyfile too!) INVENTREE_SITE_URL="https://parts.jegatron.se" INVENTREE_ALLOWED_HOSTS=parts.jegatron.se,toast.home.arpa INVENTREE_TRUSTED_ORIGINS=https://parts.jegatron.se #INVENTREE_CORS_ORIGIN_ALLOW_ALL=True INVENTREE_CORS_ALLOW_CREDENTIALS=True INVENTREE_USE_X_FORWARDED_HOST=True #INVENTREE_USE_X_FORWARDED_PORT=True #INVENTREE_CORS_ORIGIN_REGEX=.*jegatron.se
## Single line change of Caddyfile ##
# Change the host to your domain (this will serve at inventree.localhost)
toast.home.arpa {
## NginxProxyManager custom config box ##
location / {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_http_version 1.1;
add_header X-Served-By parts.jegatron.se;
proxy_set_header Host toast.home.arpa;
proxy_set_header X-Forwarded-Scheme $scheme;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass https://toast.home.arpa:443$request_uri;
proxy_ssl_name toast.home.arpa;
proxy_ssl_server_name on;
#proxy_ssl_session_reuse off;
#proxy_ssl_trusted_certificate /data/custom_ssl/toast.home.arpa.pem;
#proxy_ssl_verify off;
}
inventree.txt · Last modified: 2024/05/04 22:10 by utedass
