Exporting step files fails for some components

Hi,

In my design I have some footprints with custom 3D models created using FreeCAD and KiCadStepUp FreeCAD Add-On. The resulting wrl and step files load fine in KiCad and work in the 3D View. However, when exporting the model as a step file I get Opencascade errors for 3 of my custom footprints:

....
could not add component J4
>>Opencascade error: Geom_TrimmedCurve::U1 == U2
...
could not add component J5
>>Opencascade error: Geom_TrimmedCurve::U1 == U2
...
could not add component U1
>>Opencascade error: Geom_RectangularTrimmedSurface::U1==U2
...

Version Info:

Application: Pcbnew

Version: (5.99.0-8951-g09be44a352), release build

Libraries:
	wxWidgets 3.0.5
	libcurl/7.74.0 OpenSSL/1.1.1i zlib/1.2.11 zstd/1.4.8 libidn2/2.3.0 libpsl/0.21.1 (+libidn2/2.3.0) libssh2/1.9.0 nghttp2/1.41.0

Platform: Linux 5.9.9-arch1-1-custom x86_64, 64 bit, Little endian, wxGTK, gnome, wayland

Build Info:
	Date: Feb 10 2021 10:42:57
	wxWidgets: 3.0.5 (wchar_t,wx containers,compatible with 2.8) GTK+ 3.24
	Boost: 1.75.0
	OCC: 7.5.0
	Curl: 7.74.0
	ngspice: 33
	Compiler: GCC 10.2.0 with C++ ABI 1014

Build settings:
	KICAD_SCRIPTING=ON
	KICAD_SCRIPTING_MODULES=ON
	KICAD_SCRIPTING_PYTHON3=ON
	KICAD_SCRIPTING_WXPYTHON=ON
	KICAD_SCRIPTING_WXPYTHON_PHOENIX=ON
	KICAD_SCRIPTING_ACTION_MENU=ON
	KICAD_USE_OCC=ON
	KICAD_SPICE=ON

Opencascade version is opencascade 7.5.0-3 according to the Arch Linux package manager.

Since only some components seem to make problems it must be related to that particular 3D model. Any hints on how to debug/fix that problem?

Best regards,
Stefan

Good news is that I did make some progress, but one component still throws an error.

Checking and reexporting the models from FreeCAD did not help. So I was thinking the problem sounds like a numeric problem, the model is too detailed, rounding or other numeric effects lead to points getting the same value and ultimately those errors. I noticed that the models causing problems were a bit on the larger end of the spectrum.

So I tried to simplify the models in FreeCAD, but wasn’t really successful. When exporting using KiCadStepUp FreeCAD asks for “Mesh Deviation”, but from what I understand that is for wrl and not for the step files.

I then tried it on the other side: KiCad STEP file export has a “Tolerance” setting. But even with tightest Tolerance I the same three components kept failing.

I then tried to call kicad2step directly from console. Pretty much all options are available from the dialog already, so not really new options to tweak. However, the tolerance parameter (--min-distance) is not restricted by the three values available in KiCad… So I tried 0.0001 mm, and it indeed worked! Two more models now export just fine! Now it is just one which still causes issues (U1). Unfortunately I wasn’t able to fix that by decreasing tolerance even more :frowning: Pushing the value to much makes the exporter to get into other seemingly numeric troubles during the “Create PCB solid model” phase: “could not close outline (dropping outline data with 3 segments)”.

If somebody else hits this issues, that is how I executed kicad2step outside KiCad:

# Run STEP export in KiCad
ps x | grep kicad2step
# (copy kicad2step command)
# kicad2step needs some environment setup. Use the following to get the same environment in your current shell
source <(xargs -0 bash -c 'printf "export %q\n" "$@"' -- < /proc/$(pidof kicad2step)/environ)
# Now run the command with distance of your choosing. You might need to add some quotes for parameters, e.g.
/usr/lib/kicad-nightly/bin/kicad2step --user-origin="20.000000 x 20.000000" --min-distance="0.0001 mm" -f -o /path/to/step/file.step /path/to/file.kicad_pcb

I still have that one model which has troubles. So if somebody has an idea how to simplify/fix that, ideas welcome.

Calling @maui, our resident STEP expert

Can you import your board in FC (through KSU) and export it from FC to step? This shouldn’t fail.

playing with tolerance means you probably have a model with mechanical issues.

would you mind to upload the FC and STEP file & fp that is failing?

1 Like

Can you import your board in FC (through KSU) and export it from FC to step? This shouldn’t fail.

That indeed seems to work, didn’t realize that this is possible! Thanks for the hint!

would you mind to upload the FC and STEP file & fp that is failing?

The one which is still failing is the Raspberry Pi Compute Module 4 STEP file.

I am actually using a simplified version from the Forum, but both models have the same issue.

I created a small test board with the CM4 set as a footprint to a fiducial, hacky but I guess that shouldn’t matter. You can download it from here.

One of the other problematic models which caused issues is a stacked USB 2.0 connector from Octopart (WĂĽrth Elektronik 61400826021). However, after re-downloading and going through FC KSU export again, everything seems fine on my small test board now. Not sure what went wrong there.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.