Trouble with 3D model --- FreeCAD's fault, or KiCad's?

[[ Using KiCAD 5.0.2 on Ubuntu 18.04, and FreeCAD 0.16 64-bit based on Qt 4.8.7 ]]

I created a custom footprint for this barrier block connector; the pins are centered; this one does not come with manufacturer’s 3D model; so, I downloaded the 3D model for this other connector from Molex. Problem is, the pins are non-centered.

So, I edit the model with FreeCAD, and moved the pins to get them centered. This is what the modified model looks like in FreeCAD:

But this is what it looks like when I import it into KiCAD’s footprint editor (through-hole pins in the footprint are centered; pins of the 3D model are not):

I have little experience with 3D CAD software or file formats (just enough to, guided by Google searches, make these modifications using FreeCAD) — can someone with enough experience in 3D software and file formats shed some light on this?

This is the 3D model file:
Barrier-block-2pin-centered-0.325.step (1.6 MB)

Thanks!

Neither Kicad’s nor Freecad’s. You think the 3dmodel and the footprint are centered but they aren’t.

Install Freecad 0.17 and the workbench kicad-stepup.
Load the footprint and center the footprint and the 3d model.
Then export again the step model from kicad-stepup.

You will need to learn kicad-stepup…

1 Like

I opened the model with FreeCAD 0.17 and exported it with StepUp workbench. It works well.

1 Like

I really don’t understand this (which makes me suspect that you may not have understood what I meant).

Look at the FreeCAD screen capture — look on the bottom surface, a bit to the left of the pins; those two holes, those are the positions of the pins in the original file as I downloaded it (because the Molex connector has the pins close to one of the edges of the connector). I moved them towards the right, so now they’re centered (the pins, with respect to the bottom surface of the connector).

That clearly shows in the screen shot; however, in KiCAD’s footprint editor, the pins are clearly not in the same position as they are in FreeCAD.

Does this change your comment or clarify what I meant?

Huh — I’m not sure what to make of this (or Pedro’s suggestion regarding this). From this stepup’s description, I see: “KiCad StepUp allows exporting KiCad 3D board and components to FreeCad which allows further export options.

However, I can already export (at least as .step or .wrl), and I can see the model in FreeCAD (and I’ve sent those to a colleague that then has incorporated them to his design of the enclosure, all in 3D CAD software).

I’m not sure I can visualize the workflow of what you did (maybe I just need to get FreeCAD 0.17 and kicad-stepup and play with them? … …Who knew!! :slight_smile: )

This is only one of the kicad-stepup features.

There is another feature for aligning footprints and 3d models

I doesn’t change my mind. Your modified 3d model is not centered/aligned with the footprint though you think they are. You will see it with stepup.

Sometimes a step model doesn’t work well in KiCad. In that case exporting it from StepUp workbench may fix the problem even though an ordinary human being can’t tell why. Additionally you get also automatically a wrl model.

To me it looks like the model in the screenshot is indeed wrong, the pins aren’t in the center of the 3d model body. Try to see it without the board in there.

1 Like

My guess is that the model consists of multiple “bodies” but @cal-linux only shifted the “body” that represents the black part of the model. (A body is a CAD container representing one singular solid.)

Would you mind reporting this as a bug to https://bugs.launchpad.net/kicad along with the file? The file is correct but KiCad is not displaying it correctly. As to the reason, I’d be guessing right now so I’ll avoid that.

Actually, no, I moved the 14 surfaces (“bodies”?) that form the two connection pins at the bottom (7 surfaces each pin, given the curved/filleted ends). In FreeCAD, I started with the toolbar button that “breaks” the model into its parts (the blue down arrow, below-right from the red circle button in the above screen shot) — that is what gives me the Face001 to Face118 surfaces. Face001 to Face014 happen to be the pins at the bottom; I selected those and set the z coordinate to 3.9mm (instead of 0mm original value).

To save, I selected Face001 to Face118 and went to menu File → Export and selected a .step output file.

Not sure whether this would provide any clues as to why/how KiCAD is failing to interpret the 3D model (going with Seth’s comment that the 3D file is indeed correct).

Indeed as soon as I do, in KiCAD’s footprint editor, “Add 3D shape” and select this file, the footprint editor shows the 3D model by itself, without the board, and it does show with the pins non-centered:

(it’s kind of hard to see, since the background is black, but one can actually tell)

A note about your model (not necessaraly the source of your problems but it might make it harder for freecad to generate a step file from it.):

Surface only models are generally a bad idea. (A lot of CAD functions only work on volumetric models. Surface modeling requires specialized tools. Even with such specialized tools you would never use surface models for anything else than getting a guide. The outer shell of a car for example starts as a surface from the designer. The engineers then convert it into a volumetric model that represents material thicknesses and also things like welding joins, …)

I am also unsure how you managed to damaged the model this badly to be honest. If i download the manufacturer model i get a solid as it should be.
I ran freecads geometry check on the original model. Lets say it has errors is an understatement. (Even looking at the model already shows problems. Check the outer sides closely. Especially the area around the rounded edges. Something is seriously wrong with this model as it is from the manufacturer. Or there are massive bugs in freecads step import.)


It would also help if you uploaded your footprint.

Hi @cal-linux
the original Molex model is a solid, instead your FC rework is a shell (part made of faces) wich doesn’t belong to a solid. This is the main culprit of your issue.

  1. You should modify the molex model maintaining the model solid.
  2. After that you can export your model to be used in kicad.

(@Rene_Poschl was faster :wink: )

Please have a look at this kicadStepUp-cheat-sheet.pdf to have an overview of StepUp…

The Molex model is shown exactly the same in DesignSpark Mechanical…
The only issue in FC is that often the internal geometry check gives false positives.

1 Like

I would have assumed false positives as well would it not look that strange in this particular area. (The rounded edge looks like it failed to properly generate. I kind of assumed this could be one of the problems reported. I did not invest the time to really check the reported errors.)

No issue with geometry error check in DSM with both the objects.
DSM is much more reliable for the checking.
As @Seth_h reported,

the STEP file is fine, is the KiCAD parser that is failing in this case, because the reader is more reliable when the part is solid instead of shell.

Not sure whether at this point it would make a significant difference, but good point — here it is:

(module TerminalBlock--P0.325--8.25mm (layer F.Cu) (tedit 5C5F8D8B)
  (descr "simple 2-pin terminal block, pitch 5.08mm, revamped version of bornier2")
  (tags "terminal block bornier2")
  (clearance 1)
  (fp_text reference REF** (at 2.54 -5.08) (layer F.SilkS)
    (effects (font (size 1 1) (thickness 0.15)))
  )
  (fp_text value TerminalBlock--P0.325--8.25mm (at 2.54 5.08) (layer F.Fab)
    (effects (font (size 1 1) (thickness 0.15)))
  )
  (fp_line (start 10.2 7.2) (end -10.2 7.2) (layer F.CrtYd) (width 0.05))
  (fp_line (start 10.2 7.2) (end 10.2 -7.2) (layer F.CrtYd) (width 0.05))
  (fp_line (start -10.2 7.2) (end -10.2 -7.2) (layer F.CrtYd) (width 0.05))
  (fp_line (start -10.2 -7.2) (end 10.2 -7.2) (layer F.CrtYd) (width 0.05))
  (fp_line (start 10 7) (end -10 7) (layer F.SilkS) (width 0.12))
  (fp_line (start -10 -7) (end -10 7) (layer F.SilkS) (width 0.12))
  (fp_line (start -10 -7) (end 10 -7) (layer F.SilkS) (width 0.12))
  (fp_line (start 10 -7) (end 10 7) (layer F.SilkS) (width 0.12))
  (fp_text user %R (at 2.54 0) (layer F.Fab)
    (effects (font (size 1 1) (thickness 0.15)))
  )
  (pad 2 thru_hole roundrect (at 4.1275 0) (size 3.65 3.65) (drill 1.65) (layers *.Cu *.Mask) (roundrect_rratio 0.25))
  (pad 1 thru_hole roundrect (at -4.1275 0) (size 3.65 3.65) (drill 1.65) (layers *.Cu *.Mask) (roundrect_rratio 0.25))
  (model /home/cal-linux/KiCAD_libraries/3Dmodels/Barrier-block-2pin-0.325.step
    (at (xyz 0 0 0))
    (scale (xyz 1 1 1))
    (rotate (xyz -90 0 0))
  )

Notice, the above is the model with the original 3D model — which was already a slightly modified version of the one from Molex (to change the color of the plastic surfaces to near-black).

Ok.

Do keep in mind that, as stated in my initial post, I have very little experience with 3D CAD software or file formats. When opening the model in FreeCAD, it did look like all I had access to were surfaces (I assume that this is related to the way I’m using the software, presumably not the right/optimal way).

In any case, it does look like I will definitely want to look at kicad-stepup, which hopefully will make it easier to do 3D CAD manipulations while producing KiCAD-friendly files.

Thanks!

1 Like

Turns out I could fix it with plain FreeCAD (the same 0.16 I have) based on this observation above.

The way I see it (and this is just inference on my side), the model is just a bunch of surfaces; the inside of the model is just empty space. The solid-vs-non-solid aspect seems to be given by whether or not the surfaces completely cover the internal volume (mathematically, the way to express this would be: the surfaces completely cover the internal volume if ∄ a continuous line that connects a point in the inside volume with a point outside the volume without intersecting any of the surfaces — in any case, this statement works for “simple” solids where no two surfaces intersect).

The bottom surface had two holes in it, which were covered by the two pins; when I move the two pins, then the “solid” now has holes and stops being a solid.

The fix was: I added a box (Create a cube solid toolbar button in FreeCAD), and move it until it aligns with the bottom surface; resize it and move it so that the two holes get covered; I think I split the box into its sub-components (the surfaces) attempting to merge the two surfaces, but FC does not allow to do that with surfaces (only works with two solids). But still, I then just selected all surfaces and went File → Export and saved as .step — now it works in KiCAD!

Thanks for all the comments/discussion and suggestions! (now I’m not sure whether I will want to go the stepup route, but at least I will keep it in mind for future instances!)