Handling of 3D models

135 views
Skip to first unread message

Mojca Miklavec

unread,
Sep 22, 2022, 8:05:57 AM9/22/22
to KiCad Developers
Hi,

I'm new to KiCad. I've been working on a pet project recently and
stumbled upon some issues with 3D models that I would like to put up
for discussion.

The most important issues are the following:
1.) I would like to see a slightly more generic way to specify the 3D
model, so that both .step and .vrml export would generate complete
models, with all the components properly placed on them.
2.) I would be grateful if KiCad allowed VRML models to be in
millimetres rather than just mils (there could be a checkbox if
needed; there is a field to enter the scale, but pipelines refuse to
accept "scaled models").

And some less important include:
3.) For some THT models that come in metric dimensions it's a bit
annoying that they need to be centered around pin 1. If I try to
submit a board with THT components for assembly (to jlcpcb at least),
the rendering of the components is wrong: they expect the components
to be centred. The same argument applies to footprints though, not
just for the 3D models. It would be super useful to me if THT
components would also have the "center point" defined and if I could
have a global checkbox on the PCB that would allow me to snap to grid
or specify locations of the center of components rather than only be
able to specify the location of pin 1.
4.) There seems to be a bug with 3D VRML models from cadquery. I'm not
yet sure if the one to blame is KiCad or cadquery, but I submitted a
bug report that should hopefully lead to some proper diagnosis and
finally a fix.

--- --- --- ---

Ad 1.)

I designed the boards in KiCad and my friend used SolidWorks to design
the 3D model of a toy accordion.

Initially I tried exporting the board into .step, but I ended up with
only the raw board being exported, without any elements. I googled a
bit and stumbled upon a suggestion to export to .vrml. Export to .vrml
seemed to work: I could open the resulting file in FreeCAD, but it
seems that SolidWorks doesn't know how to open/import a VRML file, and
I didn't manage to find any suitable way for conversion (FreeCAD
doesn't know how to convert VRML into STEP).

After some trial-and-error I figured out that I could edit the
footprints and replace all the .vrml models with the .step models and
suddenly the export to .step worked like a charm. Of course this means
that the export to .vrml no longer works as expected, it means that
there must be plenty of other users stumbling into the same problem
(just assuming that .step export is inferior in functionality?), and
it requires quite some additional work to change all the footprints
(once they are already placed to the board). (Is there an easy way to
change all the 3D models on the board from VRML to STEP other than
opening the PCB in a text editor and run a search-and-replace?)

It would be really really great if there was a way to specify the 3D
model belonging to a footprint in such a way that both exports would
work out-of-the-box. This probably means that either the extension
(.vrml/.step) needs to be left out (and KiCad would automatically pick
whatever 3D model it finds or needs for a particular export), or that
a footprint should have two fields: one for.vrml and one for .step. Or
potentially some other solution.

Ad 2.)

All the VRML models generated with CadQuery 2
https://gitlab.com/kicad/libraries/kicad-packages3D-generator/-/merge_requests/24
seem to be affected by two issues (and are thus broken, though the
generated files haven't been added to the relevant repository yet, so
it's not yet "visible"):

a) the exported models are using millimeters and KiCad expected mills
b) there's a rendering issue
(https://gitlab.com/kicad/code/kicad/-/issues/12400)

Nowadays all the footprints are specified in millimetres. It would be
helpful if millimetres also became acceptable for the 3D models one
day.

But more importantly it would be really great if the issue with
generated VRML files was fixed in one way or another. Either the
scripts need to be fixed to generate the model using a different
scale, or there needs to be some agreement that it's likely that
millimetres will become acceptable at some not too distant point in
the future.

I would like to add a few missing 3D models to the library and it
would help to know how to proceed.

Any thoughts?

Thank you very much,
Mojca

Mario Luzeiro

unread,
Sep 22, 2022, 9:59:58 AM9/22/22
to dev...@kicad.org
Hi Mojca,
I can clarify some of the points

>  there is a field to enter the scale, but pipelines refuse to accept "scaled models").

You can manually adjust it on the scale of KiCad, or you can edit your file to make that scale
You can also create a file to inline another wrl file, and then apply the desired scale, example
Transform { translation 0 0 0 scale 0 0 0 children [ Inline { url "file.wrl" } ] }


4.) There seems to be a bug with 3D VRML models from cadquery. I'm not
yet sure if the one to blame is KiCad or cadquery, but I submitted a
bug report that should hopefully lead to some proper diagnosis and
finally a fix.

I comment already, I found that it is a problem with the triangle winding orientation of the model.
This should be fixed on the model side.

> and I didn't manage to find any suitable way for conversion (FreeCAD doesn't know how to convert VRML into STEP).

You can't (or shouldn't) convert it, because VRML is a non-CAD file format. Have a look at:

Mario

Kliment (Future Bits)

unread,
Sep 22, 2022, 10:04:14 AM9/22/22
to dev...@kicad.org

To add to this, for parts that have both a wrl and STEP model, if the
wrl model is enabled there is a checkbox in the STEP exporter to replace
similarly-named files, which then uses the same-name STEP for the
export. That's the easiest way to export STEP while WRL is enabled for
the display.
> <https://forum.kicad.info/t/what-is-the-difference-between-step-and-wrl-3d-models/17346>
>
> Mario
>
> --
> You received this message because you are subscribed to the Google
> Groups "KiCad Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to devlist+u...@kicad.org
> <mailto:devlist+u...@kicad.org>.
> To view this discussion on the web visit
> https://groups.google.com/a/kicad.org/d/msgid/devlist/CACVuZPu9PhRaQpYk1d84aLYGzUchkPjYZ%2Bj2YFL-0vy2ecfZfQ%40mail.gmail.com
> <https://groups.google.com/a/kicad.org/d/msgid/devlist/CACVuZPu9PhRaQpYk1d84aLYGzUchkPjYZ%2Bj2YFL-0vy2ecfZfQ%40mail.gmail.com?utm_medium=email&utm_source=footer>.

Mojca Miklavec

unread,
Sep 26, 2022, 9:20:56 AM9/26/22
to KiCad Developers
Hi,

On Thu, 22 Sept 2022 at 15:59, Mario Luzeiro wrote:
>
> Hi Mojca,
> I can clarify some of the points
>
> > there is a field to enter the scale, but pipelines refuse to accept "scaled models").
>
> You can manually adjust it on the scale of KiCad, or you can edit your file to make that scale
> You can also create a file to inline another wrl file, and then apply the desired scale, example
> Transform { translation 0 0 0 scale 0 0 0 children [ Inline { url "file.wrl" } ] }

I'm not sure if I really understood all of the suggestions listed
here, but let me try to paraphrase it in a slightly different way.

For example, I have entered parameters for creating a nice 3D package of a LED:
https://gitlab.com/kicad/libraries/kicad-packages3D-generator/-/merge_requests/35/diffs

(From what I understood there are two ways to render the packages: a
legacy one and a new one, based on the unreleased version of CadQuery
2.x. Maybe the old/legacy one creates better models, but I didn't
manage to figure out how to run it.)

The STEP model that I get out of the new code is "perfect", while the
VRML model is rendered too big (I'm ignoring the wrong face
orientation problem for now, hoping that CadQuery authors will
eventually fix it). I would eventually like to see the generated 3D
package end up in the 3D package repository, but I'm not sure how
"manually adjusting it on the scale of KiCad" can help me achieve
this. (I'm also not sure which option that is; the one I tried to use
will get rejected by the CI job, and also doesn't help much because
the scaling should only be applied to VRML, not to STEP in case I use
"automatic replacement" functionality at export time.)

I'm no longer sure, but somewhere in the back of my head I have a
feeling that KiCad already switched from inch-based units to
millimeters for storing the footprint libraries during the transition
to the new format.
One of my questions is basically: is there any chance that millimeters
ever become "first-class citizens" for VRML files as well? (I've seen
some rumours about cadquery potentially becoming more tightly
integrated with KiCad which might eventually eliminate the need to
store VRML models in the database in the first place, but that's
probably still a while ahead even if I understood that correctly.)

>> 4.) There seems to be a bug with 3D VRML models from cadquery. I'm not
>> yet sure if the one to blame is KiCad or cadquery, but I submitted a
>> bug report that should hopefully lead to some proper diagnosis and
>> finally a fix.
>
> I comment already, I found that it is a problem with the triangle winding orientation of the model.
> This should be fixed on the model side.

I opened a bug report in CadQuery. Thank you.

> > and I didn't manage to find any suitable way for conversion (FreeCAD doesn't know how to convert VRML into STEP).
>
> You can't (or shouldn't) convert it, because VRML is a non-CAD file format. Have a look at:
> https://forum.kicad.info/t/what-is-the-difference-between-step-and-wrl-3d-models/17346

Thank you, this piece of FAQ was super super helpful.

On Thu, 22 Sept 2022 at 16:04, Kliment (Future Bits) wrote:
>
> To add to this, for parts that have both a wrl and STEP model, if the
> wrl model is enabled there is a checkbox in the STEP exporter to replace
> similarly-named files, which then uses the same-name STEP for the
> export. That's the easiest way to export STEP while WRL is enabled for
> the display.
> Mario

Thank you, I failed to realize that there was a special option for
this. I might have seen it, but in case I did, I wasn't sure what it
meant.

(I should have found
https://forum.kicad.info/t/v6-step-3d-model-export-missing-components-or-completely-empty-board-is-exported/33847
earlier.)

I can no longer find the relevant blog post that misled me, but the
one I found earlier was suggesting to use VRML export instead of STEP
to overcome the problem with the missing components, and I blindly
believed that suggestion

Humble question/request: would it be possible to turn that option into
a default one in KiCad 7?
Is there any reason why average users wouldn't want this option to be turned on?

Thank you,
Mojca

Mario Luzeiro

unread,
Sep 27, 2022, 3:37:58 AM9/27/22
to dev...@kicad.org
Hi Mojca,

From what you describe and from what you learned about VRML, it looks you may want to stay just with STEP and you don't need VRML files.
If for other reasons you need VRML or someone requests it to you, you can use StepUp plugin to FreeCAD, as it is producing correct and size optimized VRML files.
Both example files you present, has lots of not used features (eg lines contours, etc) that are wasting file space and the geometry data it self loots not to be optimized.

 but I'm not sure how
"manually adjusting it on the scale of KiCad" can help me achieve
this. (I'm also not sure which option that is;

By manually adjusting I mean, edit the file with a text editor or by a script meaning. You may need to learn the VRML file format, but it is very simple to understand.

Mario

Mojca Miklavec

unread,
Sep 28, 2022, 3:40:20 AM9/28/22
to dev...@kicad.org
Dear Mario,

On Tue, 27 Sept 2022 at 09:37, Mario Luzeiro wrote:
>
> From what you describe and from what you learned about VRML, it looks you may want to stay just with STEP and you don't need VRML files.

Are you saying that KiCad will accept a merge request submission of a
3D model with only the STEP file, and with the STEP file being
referenced in the footprint instead of the VRML?

> Both example files you present, has lots of not used features (eg lines contours, etc) that are wasting file space and the geometry data it self loots not to be optimized.

The example that I presented is merely a simplified form of the models
that get generated by the following code:
https://gitlab.com/kicad/libraries/kicad-packages3D-generator/-/tree/master/LED_SMD
(because the complex VRML generated by the above code is even less
comprehendable than the already complex VRML of a simple box).

I asked upstream to look into the orientation issue:
https://github.com/CadQuery/cadquery/issues/1158
while optimisation seems to be yet another problem that might need to
be addressed even higher in the chain (possibly in one of the CadQuery
dependencies).

Mojca

Mario Luzeiro

unread,
Sep 28, 2022, 4:24:29 AM9/28/22
to dev...@kicad.org
Are you saying that KiCad will accept a merge request submission of a
3D model with only the STEP file, and with the STEP file being
referenced in the footprint instead of the VRML?

You have to contact the KiCad library team, this is the development mailing list.

This related discussion may interest you as well:

You may want to contact Maurice (easyw) regarding export to VRML:

Since our discussion is out of scope of this mailing list,
you can contact me directly if you want to discuss about VRML.

Mario
Reply all
Reply to author
Forward
0 new messages