Re-import of Kicad generated VRML file

I’m using Kicad build 5365 on Windows 8 and am starting to have a little trouble with the 3D viewer. I’ve been rendering boards in 3D with great success, using both publicly available models (most created in Wings3D) and also my own models (created in ViaCAD and exported to .wrl).

Everything was going swimmingly until I built up a fairly complex board that has several daughter boards. I exported these smaller boards to .VRML and then associated that modell to a module in the larger motherboard. Problem is that Kicad won’t render the VRML files it exported. Creating my own models and exporting as VRML from ViaCAD is fine, but a VRML model exported from Kicad can’t be read by the 3D viewer. There’s no error message, it just doesn’t render.

I’ve looked over a few threads that have covered VRML issues, but they seem mostly related to other CAD software not being able to properly render the Kicad VRML export. Using FreeCAD I can see that the VRML export of the daughter boards is just fine.

Any tips?

Hi @minisystem,

I am one of recent contributors/developers of kiCad 3D viewer.
Kicad only supports some VRML subset, initially, only supported models from Wings3D.

Currently there is no support for VRML reading external VRML files (embedded links) as it is probably the case that Kicad exports the VRML.

You maybe have some success if you open the file with 3rd part software and then export it again (to VRML or X3D) in a single VRML file.

However, what are you trying to do with KiCad I don’t recommend any way. Making a powerful 3D viewer is something not in Kicad plans, so, probably would be wise to think in use the export capability and try to load your project with an 3rd part 3D software.
If you still want to use 3D viewer from Kicad, maybe you can convert somehow your daughter boards to a simpler “3D blocks”, and then use the 3rd part software to make the final assemblage.

I will be happy if you would like to share any files that is not working, I can have a check.
Mario Luzeiro

Hi Mario, thanks for replying.

Good to know. I did open the daughter board files in FreeCAD and exported them as a single VRML file but that didn’t work.

I ultimately did what you suggested and imported the motherboard and daughter boards into FreeCAD and positioned them manually. The results are satisfactory. I was a bit resistant to do this only because I’m a little rusty with FreeCAD.

Out of curiosity, under what conditions would you expect the KiCad 3D viewer to start choking? I’ve been importing fairly detailed (read large file size) VRML models into a medium sized board (15 cm x 20 cm) and, other than it taking a minute or so to render, haven’t had any problems. In fact, things have been going so smoothly that I’ve really come to depend on the 3D viewer! :smile:

KiCad still dont support the format that the VRML FreeCAD exports. You may want to try also with blender and export it to X3D.
Also, I read someone suggesting to export using FreeCAD to some other format (STEP?), then import again with FreeCAD and export it to VRML.

There are no pre-set limits for “complexity” of models you load with kicad. The thing is that it is not an optimized 3D engine, you may expect it to take a long time to open / process / render.
But, things are getting better with KiCad, we may see some more improvements in the future!

The limitations of KiCad’s VRML support means that KiCad cannot use the VRML models which it exports. If you really want to do that it should be possible to write code which exports model name and position data which can be used by the ‘vrmlstitch’ tool to create an assembly which KiCad can import. (The tool is not part of KiCad, it is at Why do you want such a complex subassembly? Is it only for rendering images or do you use it for other things?

Hi @minisystem,
Would you like to try the latest main trunk version of KiCad? After revision 5544


I am trying to do the same now in 2016. I am creating a pcb that i later want to mount on another pcb. So i created a footprint and tried to attach a .vrml file that i had exported from the 3d-viewer. Has anyone found any workaround?

(also, should i create new threads or reopen old ones? )

A long time ago I added a scaling factor; maybe the ‘stable’ version can reuse the exported VRML now? If not, the development version definitely can since we replaced all the model parsers and recently changed the VRML exporter. The new parsers will not follow an arbitrary number of links to model files within a VRML file so you probably need to make sure the “Copy 3D files” checkbox is not checked - that way the (new) VRML exporter will put all the model data into a single file.

1 Like

Yes, i found a way to get them to show up! the problem is in the scalings. I opened the file in freecad and found that they were very small. theiy were reported to be ~3um when they should be 20.75mm. After fiddling a bit with the settings i found that i could make it visible. But they never become the correct size so i am doing something wrong.

If i set the export settings to mm -> mm. The resulting models become 2.54 times smaller. Seems some inch conversion is spooky here.

Then if i set these configurations in the 3d model of the footprint they show up okay ( sorry cant show the part)

Most of the other combinations in the export settings produce supersmall models.

you may consider to have a look here

So, i managed to get the scale working correctly. Seems there was a strange scaling factor in the code. I downloaded from the kicad mirror on github.

diff --git a/pcbnew/exporters/export_vrml.cpp b/pcbnew/exporters/export_vrml.cpp
index 7fc0a76..5e1c043 100644
--- a/pcbnew/exporters/export_vrml.cpp
+++ b/pcbnew/exporters/export_vrml.cpp
@@ -278,7 +278,7 @@ public:
         // expectations. This requires us to divide aWorldScale
         // by 2.54 in order to generate the scaling which the
         // user specified in the Export VRML GUI.
-        OutputPCB.SetScale( aWorldScale / 2.54 );
+        OutputPCB.SetScale( aWorldScale * 2.54);
         WORLD_SCALE = aWorldScale * 2.54;

This now makes the conversion mm->mm work with freecad.
And if you want to create a model for the footprints use mm->0.1inches

the offset of the model is still off. Might look into it.

(Edit: The offset is correct, my bad)
(Edit: Maybe should fix the comment as well…)

In order not to break its historical behavior, KiCad uses 1VRML unit = 0.1inch. The VRML specifications state that 1unit = 1m but no one ever enforced that. If you’re using a VRML model exported by FreeCAD it may be using t 1u=1m, in which case you need a scale factor of 393.7 in KiCad. In general I would not recommend VRML at all except for visualization. The development version of KiCad supports IGES and STEP which are solid model formats which contain information about the underlying model units so that there is no confusion over units as there are with VRML.

Yes, but the export dialog let me set the output units to 0.1inch. After the small change it now outputs correct sizes for kicad if you choose 0.1inch. It also outputs correct sizes for freecad when you choose mm as output.

The change I made does not break the historical behavious. The step functionality is not enabled by default. I see no harm in having both export to vrml and step working.

FreeCAD uses 1unit=1mm so the scale factor to use the exported model is 0.3937
It is still fine to use VRML models in kicad, to achieve extra rendering effect coming from material properties, but for a correct dimension scale, I would suggest to generate the models in a mechanical environment as FreeCAD or starting from a STEP model.
That will allow you to check mechanical constraints and will help in design an enclosure for the pcb

that is a probably a good option to avoid extra scale factor

I’m using the latest git version of kicad.
I export using 0.1 Inch, I was expecting that it match 1:1:1 while import back on 3D Viewer.
Is this an issue or Am I doing something wrong?

1 Like

This is what I was expecting as well. Therefore I filed a bug report for it and submitted a patch at:

I will check the scaling factors; using .1inch should allow you to use the model in kicad with a scale factor of 1. I could have made a mistake when I modified the exporter to use the scenegraph system to include model data.


Thank you for fixing this! I just tested it and it seemed to be working :slight_smile:

I know this is an old thread, but I am having the same issue with the latest KiCad version 5.1.10. I have to set the output units to inch and when adding the model to a footprint the xyz scales need to be set to 10 to get the correct size. This was said to be fixed but somewhere along the line something may have gotten reverted unless I’m doing something wrong.

Please start a new thread. Reading through posts that my not apply is a little time consuming.