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

Hi,

I’ve done a script to easily export pcb board and modules to MCAD STEP format with colors

using kicad StepUp the easiest way is done with minimal effort from user:
just add STEP models to your standard 3D packages path and run the script
(detailed instructions in README.txt)

kicad StepUp is a new approach to export kicad board and modules in STEP AP214 (with colors) and create the wrl library.

requirements:

  1. latest kicad
  2. FreeCAD 0.15

Please consider that the project is at beta state and not everything has been completed

The only difference from the actual way of using kicad is to substitute Wings3D with FreeCAD
and, obviously, populate the 3D models with STEP lib…
(anyway Wings3D can be used besides FreeCAD if the 3D STEP exporting it is not needed)

download the zip file to get:
a kicad demo project, with self containing STEP and wrl modules to be used just out of the box
(NB use the script from inside the dir)
some screen-shots of the result

here there is also a link of the script in action…

thank you for any suggestion and feedback,
Maurice

####################################
using kicad StepUp the easiest way:
(not changing the way you use kicad)

  1. just copy a STEP 3d model in the same folder in which there is your wrl 3d model and
    use the same name of the wrl model name (e.g. r_0603.wrl → r_0603.step)
  2. go to your board folder and copy the script kicad_StepUp.FCMacro and the config file ksu-config.cfg
    inside that folder, edit the config file ksu-config.cfg with e.g. notepad changing your model prefix to your
    KISYS3DMOD path
  3. export from kicad pcbnew the IDF model of the board
  4. run the script from command line or from a bash/batch file
    /freecad <kicad_pcb_name.emn> ksu-config.cfg kicad_StepUp.FCMacro
    (e.g. freecad mypcb.emn ksu-config.cfg kicad_StepUp.FCMacro)
    just watch the script assembly your 3D board with 3D models :slight_smile:

####################################
using kicad StepUp the best way:
(getting the best from STEP models)

  1. just copy a STEP 3d model in the same folder in which there is your wrl 3d model and
  2. export the STEP model, scaled 1/2.54 to wrl with the same name of the STEP model (e.g. r_0603.wrl → r_0603.step)
    in this way your 3D board in kicad pcbnew 3d-viewer and in FreeCAD workbench
  3. go to your board folder and copy the script kicad_StepUp.FCMacro and the config file ksu-config.cfg
    inside that folder, edit the config file ksu-config.cfg with e.g. notepad changing your model prefix to your KISYS3DMOD path
  4. export from kicad pcbnew the IDF model of the board
  5. run the script from command line or from a bash/batch file
    /freecad <kicad_pcb_name.emn> ksu-config.cfg kicad_StepUp.FCMacro
    (e.g. freecad mypcb.emn ksu-config.cfg kicad_StepUp.FCMacro)
    just watch the script assembly your 3D board with 3D models :slight_smile:

credits:
kicad EDA
IDF export for kicad
Cirilo Bernardo

FreeCAD

IDF import for FreeCAD
Milos Koutny (milos.koutny@gmail.com)

FreeCAD-PCB
marmni (marmni@onet.eu)

8 Likes

This looks awesome! I always found it a lot of work to go from step files to wrl for KiCad and then back to step for MCAD. Thanks!

What is your view on matching the STEP or WRL file to KiCad? There is always the 10/25.4 scaling factor and quite often you need to rotate and/or translate the 3D model as well.

I used to adjust the WRL file so that I had a scaling of 1, no translation and no rotation in the 3D settings of the KiCad footprint. With this approach of having the WRL’s automatically generated from STEP files this is not an option.

Would you recommend to edit the source STEP file or the footprint?

Hi Andrew,
please consider that the script is in a beta state…
at the moment the script does not read vrlm rotation, but only pcb footprint rotation.
So it assumes that the 3d model is correctly aligned to the pcb footprint
Moreover the scale factor is fixed to the real scale factor actually used in kicad…

The way to build a STEP models library to be easily used by the script should be to:

  • start modelling your 3d object in scale 1:1 in mm
    (which is the way in which mechanical stuff are used to be)
  • convert your model to STEP in scale 1:1
  • assure that your STEP module is fused to just one solid object
  • convert the model to wrl in scale 1/2.54 (it’s about 0.3937)
    (which is the scale used by 3d-viewer or maintain 1:1 scale in exporting and apply
    the scale 1/2.54 to the wrl model in 3d-viewer)
  • use the same name to wrl and STEP model
  • put the STEP model and VRML model in the same place
  • check if your vrml model is aligned to the kicad pcb footprint in pcbnew 3d-viewer
  • launch the script and check if the FreeCAD model and the kicad 3D viewer are aligned
  • in case of misalignment just verify your model

As you see the FreeCAD STEP library should be the starting base for the vrml models and scale and orientations should be fixed.
The orientation of the module is achieved by getting the orientation of the pcbnew footprint
Once a STEP library is done with the right models and orientation, the script should work just smoothly.
And don’t forget to export the pcb to IDF in mm

I know it is a bit a rigid schema, but it a small fee to pay to achieve the 3D out in STEP fully aligned to the VRML models.
To be honest I realized that I normally have built my Wings3D models with the same schema…
so in my point of view the only big change is to learn FreeCAD :smile:

Please let me know if you have a STEP or FreeCAD library of electronic parts,
I would like to build a base library to be available to kicad community…

thank you again for your feedback
Maurice

The best thing to do is to provide the appropriate scale etc. for the WRL file as used in KiCad. The STEP files should not be scaled since these contain a lot of mechanical data such as the actual units used (mm, inch, mil) and you will be corrupting that data with ad-hoc scaling. Of course if the data in the STEP file was garbage to begin with then you can do whatever you want with it, but then what’s the point of the STEP file?

The positioning of the STEP files within the final model is easily done (and should be done correctly by the scripts); the offsets used for the VRML files should be interpreted as inches (or was it 0.1 inches - I need to check) and that would have to be converted to the native units of FreeCAD (which I suspect is mm, even if you later select inches for the output units).

So your challenge is to make measurements in FreeCAD to determine what scale, offsets and rotations will be required to make the exported VRML model match. (The scale should be ignored by the scripts when they create the STEP assembly).

From Maurice’s comment above it looks to me like the script requires a little more work so that it can make good use of STEP files provided by retailers and manufacturers.

Hi Cirilo,
please find at this link the Ed’s board with multiple parts…
http://wikisend.com/download/114962/PCA150701-multipart.7z

I don’t know why but if I reply to your mail, the message is being rejected with delivery failure…
Anyway the prob was just related to the incorrect placement of the 2nd part in
the same model (the script do not consider multiple part objects and get
only first shape)

following the previous conversation,
alignment can be easily done importing from demo a model (e.g. r0603) beside the model to verify…
then you get the origin to be moved to …
so if you get a model from a manufacturer, typically scale is already fine, eventually you have to check alignment and you may need to make a fusion of the objects (but typically the model is already fused)
then export the model with 1/2.54 scale to vrml
so there is not to much work to do :smile:
Maurice

Hi,

I am aware that it is essential that the STEP and WRL file have the same orientation. The WRL file should be auto-generated from the script and there must be no manual adjustments as that will screw up the alignment with the generated STEP file of the assembled board.

If I make a 3D model of a part there is no issue because than I can use the same reference frame for the 3D model as for the PCB footprint. It is different when I download a STEP file from a manufacturer (for example, a connector). I used to convert the STEP file to WRL and then edit the WRL file so that it had the same orientation as the footprint. With this new method I cannot edit the WRL anymore as this will break the relation to the STEP file.

There are two solutions:
(1) Edit the STEP file; which I would like to avoid since this is a controlled document from a supplier
(2) Edit the PCB footprint 3D settings to make sure it has the right orientation.

My guess is that (2) is the only proper solution; except that it is a PITA to do.

Hi Andrew,
at the moment the script does not read WRL orientation, only footprint orientation…
may be I will take in care those options in future

the right solution is number 1)
open the STEP module in FreeCAD and just offset and rotate it in a way that will fulfill the footprint orientation and position…
if you want to do it easily just use this FreeCAD macro
http://www.freecadweb.org/wiki/index.php?title=Macro_CloneConvert
or just Place and Rotate the solid in FreeCAD using the Property Data Tab
and save the modified model
I don’t see any problem in just eventually offsetting and moving the origin of the STEP model…
you don’t scale or change any dimension…
the nbr 2 option is not to be used…

please let me know if that way is fine for you or you think there are some inconvenience in using it…
Maurice

Hi Cirilo and Andrew,
now the script can manage also wrl offset and orientation.
I’ve done a test with this module that I found at the official repository,
Displays_7-Segment.3dshapes/Cx56-12.fcstd
generated in FreeCAD, exported to VRML with the offset to be complaint the footprint values.
Cx56-12.wrl
Cx56-12.kicad_mod
then I applied the same offset before export the STEP model and everything became aligned…
same 3D view in kicad and in MCAD!
attached the STEP model Cx56-12.step (850.2 KB) to be used with the script
So I wouldn’t see any limitation in using the script… just the base would be a STEP or FreeCAD model (not wings3D)
:smile:

I seem to have an issue running the demo that might be Windows related. Opening the Demo.pro and pulling up pcbnew, I do not see the WRL models populated in the 3D view. However, the FreeCAD step conversion works beautifully with all the STEP models properly shown. If I edit a footprint in pcbnew to set the WRL model to an absolute path (i.e. ‘C:<somepath>\shapes\c_tant_D.wrl’ instead of the defualt ‘././shapes/c_tant_D.wrl’) the pcbnew 3D looks good but the FreeCAD STEP model throws a file not found error. I noted that error shows the correct path and filename.

Anything I am missing running on Windows?

I’m running Freecad 0.15 and KiCAD r5596 on Windows 8.1.

Aaron

Ok, after some digging, I have found two things in my case:

  1. For the WRL to render in pcbnew, I have to remove and re-create the links in the footprints. I assume this is a Windows vs Linux path issue.

  2. The FreeCAD macro will throw a file not found error if the WRL relative link is more than five sub-directories deep. I verified this was not a whitespace or path length issue. Also, oddly, a direct link with spaces doesn’t work.

So, I seem to have to use direct links without white space in the path to get both the WRL to show up in pcbnew and the FreeCAD Macro to work on Windows.

Aaron

Hi Aaron,
I use the script in windows 8 with dir with spaces and more then 5 levels without any issues.

Try to cd to the project folder and then launch kicad by command line
(e.g. cd C:\Users\your user name\Downloads\demo and launch kicad demo.pro )
so the path will be fine to the demo models and then you should see the .wrl models
Or just launch the demo.pro double-clicking on the file …

The problem of non displaying wrl models is just a path problem for kicad demo project…
The script doesn’t have anything to do with the displaying of wrl models in 3d-viewer.
The demo.pro has been done to be moved to any location, so you need to follow exactly the readme instructions to have all in the right mode.

There is also a config file for the script (ksu-config.cfg), so the user can adjust the path for its own designs/preferences.

Thank you for trying the script and for your feed back
Maurice

Maurice,

You are correct. Launching from the command line fixes the WRL display issue.

I have StepUp working now on a new board design and updated a previous design. The workflow is straight forward after walking it once. Currently, I am exporting boards into Inventor as part of a larger product assembly. The previous workflow was to export the IDF, then populate the major component STEP models on the MCAD side.

This works great, thanks for all your effort on this. Between this effort and CERN’s differential routing features, I have been able to move to KiCAD instead of a much more expensive option.

Aaron

3 Likes

Hi @aaron,
I’ve updated the script


adding a starter user guide
kicadStepUp-starter-Guide.pdf
and a FreeCAD macro to easily align and convert to vrml, manufacturer’s 3D STEP models
move-rotate-scale.FCMacro
plus some minor improvements.
hyOzd and me have also done a new repository with parametric STEP models for:
SOIC, SSOP, TSSOP, SOT, QFP (all gullwings in general), QFN ICs, DIP ICs, Chip Resistors, Chip Capacitors, Tantalum smd capacitors, Aluminum Radial smd and TH capacitors, Pin Headers.

The models can be parametric generated or just downloaded in STEP and VRML format.
Maurice

Thanks Maui. I am working on a new board and updated to KiCAD BZR 6194 (from 5596) and just ran the StepUp 0.532. Things I noticed:

  • KiCAD now renders VRML colors saved from a FreeCAD 0.15 step correctly now
  • An X-Y offset I had between the PCB and populated parts on some boards in FreeCAD went away.

I glanced at the rotation and scale macro, but it looked about like the same parameters and complexity as the FreeCAD placement dialog. I am guessing there is some advantage I am missing?

I generally only export the major components (connectors, large caps, fuses, power modules, etc.) to the MCAD, so as to not bog things down with a step model that contains 100 caps and resistors when it does not affect the top level mechanical assembly. My current part workflow looks like this:

  1. Download vendor’s step model (or hit GrabCAD, etc.)
  2. Create/Open footprint in KiCAD
  3. Open model in Freecad
  4. Make Fusion in FreeCAD
  5. Adjust rotation/size in FreeCAD, export VRML
  6. Add VRML to footprint in KICAD, check rotation (at this point KiCAD shows a ghost of the non-rotated part)
  7. Export adjusted part to new step file in FreeCAD
  8. Open new step file in FreeCAD, and export new VRML (this removes the non-rotated ghost in KiCAD viewer)

It looks long because it’s verbose. Making a part is pretty quick now.

Nice improvements, thanks again.

Aaron

Hi @aaron,

“I glanced at the rotation and scale macro, but it looked about like the same parameters and complexity as the FreeCAD placement dialog. I am guessing there is some advantage I am missing?”
with the new macro you can:

  • open in FC your model,
  • open and run the Macro,
  • select your FC file and click on Create Axis (this will put a reference for your VRML model in kicad)
  • select your STEP model and rotate X,Y,Z as required to align the object with the right axis sequence
  • use center X,Y,Z as required to center your model (typically is the center of your footprint)
  • use put on Z if you want to align the SMD model to plane Z
  • if everything seems aligned correctly, click on ‘scale to kicad VRML’ and get a scaled version of your model to be exported to vrml
  • check in kicad if the model is aligned…
  • if required use Translate X,Y,Z

    Note: this macro resets automatically the object properties, so it is easier to make placement in FC

If you want you can also configure the script to convert parts to bounding boxes, and selectively apply this rule to all except e.g. connectors, obtaining a mixed board with some real 3D models and some bboxes.

Some minor improvements:

  • more FC 016 compatibility
  • ${KIPRJMOD} var support for best 3D model portability

Maurice :smile:
PS: I develop very small boards that require all the models to be correctly located to the container, so that was my need for the 3D repo of parametric parts.

Hey maui, I can get the demo to work, and I’ve had your script working before in the past, but I changed to a new machine and broke my workflow. I’m trying to put it back together, but I’m getting this error after running the script in the command prompt:

Exception while processing file: kicad_SteupUp.FCMacro [could not convert string to float: none]

This is with Freecad 0.16 (5536 Windows 7 64 bit).

This is a great tool by the way! Thanks.

Hi @jwpartain1,
I would need some more info…

  1. which version of kicad StepUp script are you running?
  2. have you tried to download the demo project from
    kicad StepUp site and run it to test?
  3. which command are you using to launch the script and from which folder?
  4. could you post the batch file and the ksu-config.cfg file you are using to configure the script?

Please consider that all the parameters in config files have to be assigned to a right value…
if you comment a parameter without giving it a value, the script will get the next value as the value for the previous parameter… that could give this kind of error…

I’ve tested the script with win 8 64bit and FC 0.16 5560 git without problems.
these are the needed parameters in ksu-config.cfg files:

## put here your KISYS3DMOD path
./
## put here your model names that you don’t want to load (e.g. smallest ones)
none
## pcb color r,g,b e.g. 0.0,0.5,0.0,light green
0.0,0.298,1.0,lightblue (0,76,255)
## bounding box option for existing -bbox modules
bbox off default
## placement options
placement: useBaseOrigin #place board @ 0,0,0
## virtual modules to be or not added to board
noVirtual
## fuse modules to board
## be careful … fusion can be heavy or generate FC crash with a lot of objects
## please consider to use bbox or blacklist small objs
#fuseAll
nofuse #default

keep in touch,
Maurice

Hi maui, thanks for the thorough reply. I did solve it, noticing I had screwed up the ksu-config.cfg yesterday (wrote my KISYS3DMOD path over one of the comments instead of the “./”). One of my components is not placing quite right, but it’s likely something else on my end again.

thanks to the guys at Bitcraze for sharing my 3D kicad StepUp video :smile:

in the video the simple exporting procedure from kicad to 3D mechanical STEP model in just one click!

2 Likes