Hi,
I developed this tool following some users need in relation to download or update 3D models on a KiCad pcb board.
This tool, after a small configuration, will automatically download WRL and STEP files placing them to the relative local folder.
The nice thing is that the tool will download/update ONLY the 3D models needed by the selected kicad_pcb board, as defined in the board footprints.
This can be handful when using standard KiCad footprints, that have pre-configured 3D models.
The tool could be also improved to allow a server proxieā¦
No git versioning or svn support, just a simple downloader/updater for the required 3D models of a single project. Feedback welcome.
Plese note that is a very initial release (not deeply tested):
The script can be launched ATM only on win OS.
Just configure your parameters inside the ā.batā file and launch collect3Dmod.bat
For Linux or Osx one must use the command line as for example: python list_models.py your_kicad_3D_folder 4 your_kicad_board_full_file_path
Nice! Iād love to see such a concept integrated directly into KiCad. I imagine it would still have to be a python script rather than being compiler in, for 2 reasons:
Python is a much better tool for doing this than C++
If the library links ever change, you want to be able to quickly tweak the scripts rather than have to recompile KiCad.
Iāve been trying for ages to think of a better way to download models than the raw.github approach. Iām not sure there is one.
I played with uploading a .7z file for each model onto kicad.github.io but it takes too long to compile the library data and also creates a LOT of extra data.
I donāt think so but Iām not 100% sure. I know nothing about how the Python scripting interface works. Iād love to see a tighter python integration, thereās a lot of functionality that further scripting would provide
There are at least two problems ATM to integrate this script into Kicad:
pcbnew python API have little functions exposedā¦ (I couldnāt even search for 3D models inside a board)
there is no easy way to write on default standard 3D packages folders from inside pcbnew because those folders are under Administrator permissionā¦
There is already a better kicad-python implementation, but it is outside the standard installation of KiCad
If you want to download the zipped version of a file there is the DownGit approach ā¦
Download the zipped dynamically generated file and then you can unzip it and place it to the desired folderā¦
Iāve updated the program to be a pcbnew Tools menu item. It has the issue of not being able to write to system libraries (unless presumably you start KiCad as administrator). And the library paths are hard coded for Windows.
Itās available as a fork on GitHub, and thereās an outstanding pull request.
I havenāt tested it except for the menu item. I tried to modify the original as little as possible.
Hi @HiGreg
thank you for your contribution but unfortunately it would be useless on most user caseā¦
I started my code as an external script exactly because of the system libraries standard location ā¦ they are as default located where Administrator rights are requiredā¦
You can see that on my previous post.
Launching the script from inside KiCad would be most useless because of administrative rights.
So unless the libraries folder location would change (that I donāt thint it will happen) this tool will not be useful as an action script.
ATM the script is already considering:
KISYS3DMOD
KIPRJMOD
to place locally the 3D downloaded models, but the var has to be manually configured at first run.
KISY3DMOD var is available safety only inside pcbnew (not all users are setting environment variables in the OS, but just internally in kicad)
It could be read from kicad userās profile configuration files, but atm it is not done.
yes, but the average user is not expected to do it.
Moreover if you have followed the dev mailing list, the probability that the actual location may vary is very very littleā¦
it is easier to just use the script with administrative right in that caseā¦
I never used this library location, but this is aimed to help users that are not familiar to kicad environment.
the script will substitute the internal {$KISYS3DMOD} with the configured pathā¦
If instead {$KIPRJMOD} is present, the script will save the 3D model to a relative path
This is the case when someone is saving a project to GitHub, using explicitly this var inside the pcbnew file, for a real 3D feature portability.
In that case instead of {$KISYS3DMOD} the user will put {$KIPRJMOD} for each modelā¦ Icezum board is an example
Iāve figured out how to elevate privileges in Windows python and can run the āupdate 3d modelsā script as admin. I think this would be very useful as a menu item within KiCad, where it can automatically know the project and the library. I can come up with modifications that will enable this on Windows KiCad. It will require a little more investigation to get it working under Linux.
As long as you are within the fakeroot shell, it looks like if you are root - as long as you do not try to do anything that really needs root privileges. And this is exactly what a packaging tool need to make packages that will make sense on any machine.
So the subprocess.Popen should be the candidate for Win and Unix
The library script actually needs root for access to the directory. And I havenāt seen Popen used for process elevation on windows, only ShellExecute.
Popen works fine with PowerShell, and it can be used to ask for Administrator rightā¦
Probably Popen could be used also in Unix to ask for Admin rightsā¦ I need to have some spare time to check itā¦
Iām fully agree and support for relative paths. It more useful for me. It do not require to monkey with KISYS3DMOD variables. I personally still have hard time to see KISYS3DMOD work for may case.