kicad-automation-scripts
kicad-automation-scripts copied to clipboard
generate STEP file?
Has anyone played around with auto generating STEP files (File -> Export -> STEP)? Any tips?
@set-soft, maybe your fork is more suitable for this?
Hi!
My fork doesn't currently support it, but this is something I would like to add. I generate STEP files from time to time. I didn't include them in my first approach just because they are huge and testing them is complex. Note that my fork is currently focused on KiCad 5.1.5, dropping support for KiCad 4. Functional docker images are available and the scripts run perfectly without docker. But I'm focused on Linux, don't have access to Windows or Mac OSX. I'm currently adding automatic tests to the scripts to make them more reliable. If you want: detail what features and options do you expect from it. Also: are you willing to help coding?
Regards, SET
@maholli @set-soft I made an initial script to export the step. I can make a PR to your repo if needed.
@set-soft Thanks for the response! I'm afraid most of this code is outside my wheelhouse, so I likely wouldn't be much help with the initial legwork. I do, however, have your fork up and running with github actions and can help test!
@leoheck Sweet! I see you have a kicad-automation repo, but it doesn't look like you've forked off of productize or elsewhere. I'd love to check the code out if you want to push to your repo or make a PR to @set-soft's (if applicable).
@maholli I do have, but just because I was merging code from all of the forks to make it work fast, for my purposes.
Hi @leoheck I'll take a look at what's needed to export the STEP files. If you have working code tell me where is and I'll take a look at it.
I took a look into this. There is no need to add it to these scripts. The "File -> Export -> Step" dialog is just a wrapper for /usr/bin/kicad2step.
This functionality could be added to kiplot (my fork uses kicad-automation-scripts)
Nice /usr/bin/kicad2step
you are good in finding info. Let us know if this is working, please.
My first attempt (and it is working, at least for me) is this https://www.dropbox.com/s/tl3gk2739pe0n5f/export_step.py?dl=0
If you want to test it you may need my whole folder since it adds other dependencies from other forks. It is not well organized yet https://www.dropbox.com/sh/y1bz4xufxokotqu/AADSeIgBeCs_jAk4FO8_1u6ca?dl=0
Thanks @leoheck I'm finishing some details on my fork and then I'll see how to export the step file.
Totally off-topic question for you @set-soft (where I can talk to you?)
Do you have any idea if it is possible to run these tools, on a system without GUI?
I want to integrate them into my CI (using GitHub workspaces) I am using a self-hosted server, but it does not have GUI right now.
So, I can see 2 problems here.
- The Server does not have Gui (but this is not the issue since I can install it if needed)
- Github logs-in into my server (through ssh I believe). So it is possible that I can't change this passing the
-X flag
to enable the X11 export
So, the issue I see is that these tools are GUI dependent since they need Windows to do the job.
Do you know if there is any way to work around this GUI dependency?
Ah, just found this Xvfb to fake a Display. It looks good.
I'm not sure if I understand, the whole idea is to run them in a server without X and using them for continuous integration. Like in this example: https://github.com/INTI-CMNB/kicad_ci_test also this example: https://gitlab.com/set-soft/kicad-ci-test-spora
The Makefile included in my fork has a target "test_docker_local" to run the tools inside a docker image without access to the host X server, simulating the same situation you'll find in a machine without X.
Also take a look at our KiPlot repo: https://github.com/INTI-CMNB/kiplot
And yes the tools runs KiCad inside a fake X server created by Xvfb
The current version in the repo can also start a Window Manager (inside the fake server) and export it using VNC protocol, so you can connect with the virtual server and interact with it inside a window of your real X server. This is greate for debug.
And yes the tools run KiCad inside a fake X server created by Xvfb
Oh, thank you for this info. I was not using your repo as a whole since I was using things from different places. I also dropping the docker part to use on my computer for simplicity, but it may be an interesting solution for CI. Thank you for explaining to me all of that.
This comment relates to this thread.
If you are adding a way to export the step file in your repo. A good thing to do is to also test if 3d-models of the parts are good (test if they are not multipart, for instance). Maybe Freecad has something to help here. This is especially helpful when the user adds external 3d-models. When 3d-models are not good, the generated step file (is usable) but a single part is not generated because the boolean operation used to make it fails.
@maholli @set-soft , this is the command Kicad uses to generate the 3d-model
/usr/bin/kicad2step --user-origin="148.088301 x 103.570169" -f -o ./board.step ./board.kicad_pcb
Ok, added something.
@leoheck Do you have examples for the issue you mention? What should we do in this case? Print a warning about it?
Are you talking about the issues here https://github.com/productize/kicad-automation-scripts/issues/9#issuecomment-634980819 ?
Maybe they are not issues anymore. You've solved this when you told us that these tools were running on docker/ci. And I verified it by myself running it on my own ci and on my my computer ssh-ing to it without X11.
Considering my last comment here...
I would just suggest changing this part. I forgot to say it when I was showing the comment before.
--user-origin="148.088301 x 103.570169"
but a config to change these settings on kiplot.json would be good too in future if you didn't implement it this time.
Are you talking about the issues here #9 (comment) ?
Nope, sorry for not quoting to make it clear, I was talinkg about:
A good thing to do is to also test if 3d-models of the parts are good (test if they are not multipart, for instance).
And:
but a config to change these settings on kiplot.json would be good too in future if you didn't implement it this time.
Of course, all the command line options can be controlled.
A good thing to do is to also test if 3d-models of the parts are good (test if they are not multipart, for instance).
Oh ok, I see. I was looking into it, and this looks something hard to do since even KicadStepUp plugin for Freecad not always can't tell the right answer.
For instance, when the board uses only the 3d-models coming from the Kicad library the exported part is a single solid since KicadStepUp owner builds the Kicad Library considering this.
But if the user, like me, uses models from the internet, to fulfill the missing parts, sometimes these models are not good (as in they can't be used on boolean operations like addition) and Kicad won't export the .step file as a single solid.
This "single solid" feature is a good thing to have because when working with MCAD, you can use the explode operation, to visualize the device and system's parts better, and the board won't explode in many thousands of pieces. It will be handled as a single part.
So, long story short, this is a good feature to have, but it is hard to implement unless we find something useful here. Also, its result not something really important since the exported .step file can be used normally.
I was discussing this with @easyw, here https://github.com/easyw/kicadStepUpMod/issues/50
So, long story short, this is a good feature to have, but it is hard to implement unless we find something useful here. Also, its result not something really important since the exported .step file can be used normally.
Ok, I understand the idea. If we find a rasonable way to detect I'll add a warning. Thanks.