KiCad StepUp New exporter for 3D MCAD (feedbacks are welcome)

Hi @kdpatino
from the errors I see it seems you have a board with some pads without layers …
I’ve tried to create a similar situation with the kicad footprint editor, but I cannot reproduce the case…
(tested with th, smd, connector and npth pads)
have you tweaked in some way one or some models in your board?
(i.e. editing the kicad_pcb file by a text editor)

would you mind to share the pcb board or to send it privately by message to see if I can find the prob?
Maurice

Hi, Maurice,
I’ve installed new v0.16 FreeCAD and StepUp stopped working.
StepUp’s path is “C:\Program Files\KiCad-Stepup\demo”,
new FreeCAD’s “C:\Program Files\FreeCAD 0.16”.

Bat files (e.g. C:\Program Files\KiCad-Stepup\demo\launch-kicad_StepUp-Tools.bat) had contained …\FreeCAD 0.15 path, so I modified batch file to …\FreeCAD 0.16.
It then succesfully fired FreeCAD, FreeCAD started to run macro, but it ended up “Exception while processing file: kicad-StepUp-tools.FCMacro [No option ‘last_pcb_path’ in section: ‘last_pcb_path’]” error.

If I start FreeCAD manually, load “C:\Program Files\KiCad-Stepup\demo\kicad-StepUp-tools.FCMacro” and run macro with Ctrl-F6, I got a
“Traceback ˙(most recent call last): File “C:/Program Files/KiCad-StepUp/demo/kicad-StepUp-tools.FCMacro”, line 1309, in cfgParsRead(configFilePath) File “C:/Program Files/KiCad-StepUp/demo/kicad-StepUp-tools.FCMacro”, line 745, in cfgPar”… message. Message should continue: this much is what I see on my display. The message was on-screen only for a couple seconds: I needed a printscreen to grab the message. Is this traceback saved to file?

I had one guess: changed directory name from “C:\Program Files\FreeCAD 0.16” back to “…FreeCAD 0.15”, but couldn’t help.

Deleting both FreeCAD and StepUp, then reinstalling FreeCAD 0.15 and StepUp probably could solve the situation, or do you have any proposal what to do?

Hi @novaktamas
Your problem is probably related to an issue that ConfigParser has with utf-8 … Do you have some path with utf-8 characters in?
To solve your issue, ATM, just delete your ksu-config.ini and after starting stepup tools just edit the new generated ksu-config.ini file to adapt your 3D folder path…
Kicad StepUp works fine up to latest FC 0.17…
I’m working to overcome that utf-8 prob just substituting ConfigParser with my own parser… But this is taking a bit…
Maurice
PS to view error messages just enable Report View in FreeCAD …

Hello @maui

I had run again your script with some debugging info and I realized what was the component with troubles, so now It works perfect… its amazing!!!. thanks for your support .

Regards,

Kevin

1 Like

Hi Maurice,
I don’t have any ksu-config.ini file. I think you mean ksu-config.cfg in “C:\Program Files\KiCad-Stepup\demo\old-script”. I deleted this .CFG file but got the same message when run FreeCad and executed the macro “C:\Program Files\KiCad-Stepup\demo\kicad-StepUp-tools.FCMacro”.
I also tried …old-script: “C:\Program Files\KiCad-Stepup\demo\old-script\kicad_StepUp.FCMacro”, got “list index out of range” error.
I also tried to uninstall FreeCad 0.16 and re-install 0.15: no success.

My Win7 is Hungarian version where we have some acuted characters over English 26 letter alphabet, but I never use special characters in paths (not even spaces, except in “Program Files”, only “-” and underscores):

Stepup: C:\Program Files\KiCad-Stepup\demo\old-script
KiCad: C:\Program Files\KiCad-7409\bin
Kicad work: D:\MUNKA\Tekinvest\RGB-keyb\RGB-kbd-128\KiCad
packages3d: D:\MUNKA\KiCAD\packages3d

Any idea what to do next?

Thanks,
Tommy

Hi @novaktamas
I see you are using a recent release of kicad StepUp ‘kicad-StepUp-tools.FCMacro

then your config file is not anymore ksu-config.cfg but it is ksu-config.ini that you can find in

NB the new config file is in home user dir
Linux and OSX:
~/ which is $HOME
Windows:
%HOMEPATH%
Click kicad-StepUp-tools.FCMacro Config Button to display the ksu-config.ini file
and Help button for a quick Help
In case of any problem, just delete ksu-config.ini file and restart the kicad StepUp
tools… a new ini file will be generated
edit your 3D prefix and re-run the tools

kicad StepUp is working fine with FC 0.15, 016 and latest 0.17
Please consider to download latest release:
just recently updated for new features…
Latest Enhancements:
STEP multi-part allowed (creating compound)
EdgeCuts allowed for footprint that will generate Cuts in Board
Pcb Edge as footprint allowed
edge tolerance on vertex coincidence for easier designing

KiCad: C:\Program Files\KiCad-7409\bin Kicad work: D:\MUNKA\Tekinvest\RGB-keyb\RGB-kbd-128\KiCad packages3d: D:\MUNKA\KiCAD\packages3d

so just use:
C:\Program Files\KiCad-Stepup\demo\kicad-StepUp-tools.FCMacro
and adjust your prefix in ksu-config.ini (that you will find in Windows %HOMEPATH%) to:
[prefix3D] prefix3d_1 = D:\MUNKA\KiCAD\packages3d\ prefix3d_2 =
your %HOMEPATH% should be something like:
C:\Users\your_username

Thank you for using my StepUp tools since its first release :smiley:
Please feel free to ask any further advice you may require
Maurice

PS Don’t use scripts from old-scripts DIR
Stepup: C:\Program Files\KiCad-Stepup\demo\old-script
they are there just for reference

1 Like

A huge step forward :grin:

  • switched back to FreeCAD 0.16
  • deleted ksu-config.ini, then edited .ini just recreated
    Now FreeCAD+script runs, but my project is not perfect yet:

My workflow is for a custom connector:

  • download STP from manufacturer (e.g Molex)
  • I load STP into Creo 3. When loading I can choose loading as an assembly (more parts) or a single part. I must select single part (or resulting WRL won’t be accepted). Then I save single-component model again as STP.
  • I load the modified (single component) STP into FreeCAD then export from FreeCAD to WRL.
  • Copy both single-component STP and new WRL to my packages3D directory (both the same name, and rename STP->STEP)
  • I start KiCad Footprint Editor and load connector’s footprint (I created previously)
  • set Footprint properties/3D settings to my WRL (not with full path, but like ${KISYS3DMOD}/Connect.3dshapes/…WRL)
  • set scale/rotation/offset experimentally to look good
  • save footprint
  • change footprint to the new one in pcbnew.

Now 3d viewer shows the board perfectly (well aligned).

Then I want to export board to STEP for MCAD.

  • I start script in FreeCAD
  • Load kicad Board *.kicad_pcb
    Script slowly draws components one-by one (abt 20 minutes!! is it normal?), but new component is not well positioned. Finally I got lots of “…WRL error: reset values of scale to (xyz 1 1 1 )” errors, which is an explanation to bad positioning.
    Do you know what is the problem with my WRL’s?

Thanks again…I mean to create a new, more detailed workflow of using StepUp for you. I see much better, what a rookie doesn’t know/where are the traps:)))

Tommy

1 Like

Hi
You should use stepup to align the model to the footprint before exporting it to vrml
The position in kicad should be all zeros and the scale should be 1 1 1
Edit: shown here https://youtu.be/O6vr8QFnYGw

Hi @novaktamas
that will be a long reply :smiley:

NB scale to 1,1,1 is MANDATORY for any mechanical conversion/collaboration

it highly depends on your models… I can assembly a board with hundred parts in about 30s…
Do you have the exportFusing = fuseAll option in your ksu-config.ini file? This is a time consuming option…

you don’t need to rename STP to STEP… the StepUp tools will search for .step, .stp, .iges, .igs

  1. I would suggest to start easily with i.e. a single square board with a single footprint
  2. with the recent StepUp release (since v3116) it is possible to align models in kicad pcbnew and assembly them correctly, but I would suggest to use this alternative workflow:
    a) download STP from manufacturer (e.g Molex)
    b) load STP into FreeCAD
    c) analyze your 3D model to see if it is a SOLID or a collection of SURFACES
    c1) if it is a SOLID just use the solid model
    c2) if it is a collection of SURFACES make a compound of surfaces (Part WorkBench, Make compound)
    d) load footprint in FreeCAD as @Shack suggested (‘Load kicad Footprint module’ button)
    d1) NB footprint must have
    (model path/yourModel.wrl (at (xyz 0 0 0)) (scale (xyz 1 1 1)) (rotate (xyz 0 0 0)) )
    ‘z’ rotation is allowed if needed
    That is what is also recommended for kicad library
    e) align your model (SOLID or COMPOUND) using i.e. the StepUp tools to the footprint in FreeCAD
    (That will allow you to align the model to your footprint in a mechanical environment… For most SMD models typically is enough to click on Rotate X if needed, Center X, Center Y , Put on Z buttons)
    f) when aligned, click on the button ‘Export to kicad: STEP & scaled VRML
  3. copy both STEP and WRL models to your 3D DIR PATH
  4. check if your model is fine both in footprint editor and pcbnew in kicad
  5. run the script/macro
  6. load the board using the ‘Load kicad PCB board’ button
  7. check if everything is fine
  8. if everything went fine, iterate the process for all the new models you need to add

Hoping to giving you the right road to obtain your pcb 3D model result :slight_smile:
Maurice

1 Like

How to decide if solid or surfaces?

In MCAD there are “part” and “assembly”. Parts may be solid or may consist of surfaces. It seems my STEP is an assembly: it contains multiple solid parts.
See printscreen of FreeCAD:

Yes, the problem is surely with model complexity. I exported STEP from KiCAD, and it resulted a 700MB stp file…hard to swallow for my poor box:-). Stp downloaded from part manufacturer can be highly detailed. E.g. I have a stp for a switch where even internal metal and plastic structures are 100% detailed!! Is there a way to simplify those over-complicated models?

Load them in FreeCAD and delete the parts you don’t want.

If that still doesn’t work you have to remake it yourself as you can’t get rid of details in an automated way that I would know of for MCAD.

I use DesignSpark Mechanical to open the original STEP file and see if there are SOLIDS or SURFACES


https://kicad-info.s3-us-west-2.amazonaws.com/optimized/2X/c/c1de071b1462709d65d212dc87bf3e1f2589ff8a_1_625x500.png

yes in fact… the best option would be to make a union of parts to obtain a single object fused … FC has some issues in fusing objects when they are coplanar and don’t have any common parts… sometimes is sufficient to move a part i.e. 10um (0.01mm) to be able to make a usable union of parts… or just try with PTCreo and check the result in FC
Anyway the latest release is supporting multi-part STEP models … to align those just use Part Make compound and align the compound… this it will be a bit time consuming when assembling the board, because the multipart, reloaded in FC will have to be re-elaborated as compound… so the fused object is the best option

as @Joan_Sparky pointed out the simplest is to delete the sub-parts you don’t want in your MCAD sw
An other option is to use bounding boxes and i.e. height or volume constraint for parts you don’t consider useful for your mechanical design… then kicad StepUp will assembly only relevant parts and will substitute a part with its bounding box

Here an example of a board with small volume parts discarded, bounding boxes on internal parts, and connector as real STEP models

The result will have a much lighter file size for STEP

2 Likes

Hi Maurice,
Firt of all, congrats for your KiCAD StepUp

I’m trying the wrl export feature and I like to add my materials
How can I do it?

I think the wrl file created by KiCAD StepUp has all material available included it.

my test file:
Terminais.wrl (18.7 KB)

Jorge

The materials in stepup are hardcoded. if you want to add more materials you need to add them to the code.

Hi @Tech_JA
you can select the materials among the available using the combo box

If you want to add or modify the materials, you need, as @Rene_Poschl pointed out, to add/modify the code inside the ‘py’ or ‘FCMacro’ file

You can also use a text editor to edit your WRL file and manually edit your materials.
I made this guidelines that will help understand how materials work:

1 Like

Hi Mario @kammutierspule
would you mind to post the two Materials documents in LibreOffice format? ATM we linked the pdf, but then tey are not modifiable to add new materials :wink:
Then we could include them at the packages3D GH repo

1 Like

thanks for the replies
I will check the python code to add more materials

Hi Mário,
yes, I know I can edit the wrl file to edit the materials but it will more simple if I can choose the correct material in KiCAD SteUp

Maurice,
a suggestion:
Could be a nice feature if you add file for user can add owns materials list

1 Like

Hi @Tech_JA
StepUp has started as a single macro file, so it is still a single file embedded in a FreeCAD workbench…
The idea to include a material list is a nice feature, but it will require to be compatible with both WB and Macro approach…

At the same time, if you have defined some nice materials, please post them here or at GH repo…
I could just add those to StepUp and update the suite for all users…

Thx
Maurice

Well i separated the material definitions for the vrml export used in our cadquery scripts. (Not sure if my implementation is still used.)
It might be possible to use that part for stepup. But it will definitely require some work. I will not be able to look into this until after the v5 release. (And the list of things to do after the v5 release is already quite long.)