Difference between revisions of "Downloading KiCAD files for LCSC components"

From Da Nerd Mage Wiki
Jump to navigation Jump to search
(Created page with "<pre> #!/usr/bin/bash ######################################################## ### This little script wraps around ### ### https://github.com/uPesy/easyeda2kicad.py ### ### and provides a much more usable set of downloads ### ### ### ### Before using, either create an LCSC folder in ### ### your Documents or edit the OUTPUT= line below. ### #####################################################...")
 
 
(12 intermediate revisions by the same user not shown)
Line 1: Line 1:
<pre>
'''NOTE:''' This is all based on using a fresh install of Debian 12.
 
I've created a little wrapper script to simplify using [https://github.com/uPesy/easyeda2kicad.py easyeda2kicad] and saving the downloaded files in a reasonable way.
 
= Installing easyeda2kicad =
 
Well... Here's a "better" install sequence...
 
* <code>su -</code>
* <code>apt install pip python3.11-venv</code>
* <code>python3 -m venv .venv</code>
* <code>source .venv/bin/activate</code>
* <code>pip install pipx</code>
* <code>pipx ensurepath --global</code>
* <code>pipx install --global easyeda2kicad</code>
 
= The Wrapper Script =
Copy this into a file in your execution path & make it executable. (I called it '''lcsc''' here)
* <code>vi ~/bin/lcsc</code>
* <code>chmod +x ~/bin/lcsc</code>
 
<SyntaxHighlight lang="bash" line>
#!/usr/bin/bash
#!/usr/bin/bash


Line 22: Line 43:
   mv    ~/${OUTPUT}${i}.3dshapes/*.step ~/${OUTPUT}${i}/
   mv    ~/${OUTPUT}${i}.3dshapes/*.step ~/${OUTPUT}${i}/
           # if you really want the WRL also, change the above line to:
           # if you really want the WRL also, change the above line to:
           #    mv    ~/${OUTPUT}${i}.3dshapes/*.step ~/${OUTPUT}${i}/
           #    mv    ~/${OUTPUT}${i}.3dshapes/* ~/${OUTPUT}${i}/
   mv    ~/${OUTPUT}${i}.pretty/* ~/${OUTPUT}${i}/
   mv    ~/${OUTPUT}${i}.pretty/* ~/${OUTPUT}${i}/
   rm -r  ~/${OUTPUT}${i}.*
   rm -r  ~/${OUTPUT}${i}.*
Line 32: Line 53:
  fi
  fi
done
done
</pre>
</SyntaxHighlight>
 
= Usage =
You can download files for one or more LCSC components at a time.
 
(If you haven't changed '''OUTPUT''' in the script, do ensure that '''~/Documents/LCSC''' exists...)
 
Each component retrieved will result in a sub-folder named for the component & containing symbol, footprint & 3D files.
 
If there are no files actually available from EasyEDA, a file will be created with the extension '''.HasNoStuffAvailable''' instead.
 
As an unplanned bonus, trying a previously attempted component again after EasyEDA has added support will clean this file up & create the appropriate sub-folder.
== Examples: ==
* lcsc C2040
** will download symbol, footprint & 3D files for the component with LCSC catalogue number C2040 into a subfolder of ~/Documents/LCSC
* lcsc C2040 C5350143 C5374682
** will download symbol, footprint & 3D files for all 3 component into separate subfolders of ~/Documents/LCSC

Latest revision as of 02:01, 11 June 2024

NOTE: This is all based on using a fresh install of Debian 12.

I've created a little wrapper script to simplify using easyeda2kicad and saving the downloaded files in a reasonable way.

Installing easyeda2kicad

Well... Here's a "better" install sequence...

  • su -
  • apt install pip python3.11-venv
  • python3 -m venv .venv
  • source .venv/bin/activate
  • pip install pipx
  • pipx ensurepath --global
  • pipx install --global easyeda2kicad

The Wrapper Script

Copy this into a file in your execution path & make it executable. (I called it lcsc here)

  • vi ~/bin/lcsc
  • chmod +x ~/bin/lcsc
#!/usr/bin/bash

########################################################
### This little script wraps around                  ###
### https://github.com/uPesy/easyeda2kicad.py        ###
### and provides a much more usable set of downloads ###
###                                                  ###
### Before using, either create an LCSC folder in    ###
### your Documents or edit the OUTPUT= line below.   ###
########################################################

OUTPUT='Documents/LCSC/'
for i in ${*}
 do
 echo ${i}

 if easyeda2kicad --full --overwrite --lcsc_id=${i} --output ~/${OUTPUT}${i}
  then
   mkdir  ~/${OUTPUT}${i}/
   mv     ~/${OUTPUT}${i}.kicad_sym ~/${OUTPUT}${i}/
   mv     ~/${OUTPUT}${i}.3dshapes/*.step ~/${OUTPUT}${i}/
          # if you really want the WRL also, change the above line to:
          #    mv     ~/${OUTPUT}${i}.3dshapes/* ~/${OUTPUT}${i}/
   mv     ~/${OUTPUT}${i}.pretty/* ~/${OUTPUT}${i}/
   rm -r  ~/${OUTPUT}${i}.*
   echo Got it...
  else
   rm -r  ~/${OUTPUT}${i}.*
   touch  ~/${OUTPUT}${i}.HasNoStuffAvailable
   echo Nothing to get...
 fi
done

Usage

You can download files for one or more LCSC components at a time.

(If you haven't changed OUTPUT in the script, do ensure that ~/Documents/LCSC exists...)

Each component retrieved will result in a sub-folder named for the component & containing symbol, footprint & 3D files.

If there are no files actually available from EasyEDA, a file will be created with the extension .HasNoStuffAvailable instead.

As an unplanned bonus, trying a previously attempted component again after EasyEDA has added support will clean this file up & create the appropriate sub-folder.

Examples:

  • lcsc C2040
    • will download symbol, footprint & 3D files for the component with LCSC catalogue number C2040 into a subfolder of ~/Documents/LCSC
  • lcsc C2040 C5350143 C5374682
    • will download symbol, footprint & 3D files for all 3 component into separate subfolders of ~/Documents/LCSC