3D new library for Mechanical CAD exporting and enclosure design

Well STEP is the undisputed king of standards specification complexity. With the plugin system I am working on it should be possible for KiCad to directly support STEP via OpenCascade but of course that’s a matter of someone doing the actual coding. Maurice’s scripts have pushed the priority of such coding down the list somewhat since the devs are all busy with so many things and the scripts are a good compromise. In the long term I’d like kicad to have its own minimal engine for displaying and producing STEP assembly models (and IGES as well - so far I can produce IGES but can’t display it) but that’s looking like a 2-year full-time job to me, which means I can probably finish the task in 10 years. The only objection some devs (including me) have to OpenCascade is that it’s a huge library - that’s inevitable since it is a 3D MCAD geometry kernel. However, kicad only needs extremely basic geometry support to be able to create a PCB solid model (as demonstrated in my libIGES project) and to add other models to an assembly model. At any rate my new plugin system allows us to make OpenCascade an optional requirement which can be installed separately - this arrangement keeps all devs happy while not eliminating the possibility of native STEP support via a custom lib in the future.

2 Likes

With all this great work on modelling SMD components, are there any THT components like resistors?
I’ve generated and used cbernardo’s resistors as WRML files, but would like to use Maurice’s script to model my enclosure with the multiple PCBs inside. However, it’s all through-hole stuff and I’m having difficulty finding appropriate resistors…

I noticed another thread which allows parametric creation of various components. Is there one like Cyril did in WRML that would generate STEP models?

you can always try to download some TH models in STEP format at 3dcontentcentral o grabcad
then you can align the footprint with


and export with kicad SteUp tool to vrml aligned to your footprint
Maurice
PS feel free to ask for support if needed in using my MCAD script :smile:

2 Likes

Thanks Maurice. I’ve had a look, but all seem to be horizontal TH models, none of them are vertical. I’ve tried taking one and then modifying it in my CAD (we use Creo / ProE), but no real luck…

The great thing with @cbernardo’s scripts for VRML is that I was able to modify a few parameters such as the pitch so I could get them perfectly matching my PCB design.

I did see a guide somewhere to convert VRML models to STEP but it was rather convoluted and involved using many different programs (Blender, FreeCAD, etc) so seems a rather tedious step if I have many components to convert.

It might be easier for me to make one from scratch if I can’t find something suitable already out there :smile:

@xavierw
if you like to code a bit, have a look at


this are some script to generate STEP and VRML models starting from a parametric table as in component’s data sheet
If you would like to play with the code, cadquery is a nice framework to let you generate parts with parametric scripts in python
here is a very simple example for a smd chip cap

may be you can have a look and create some script to generate TH resistors, than the other users could have a benefit :slight_smile:
I found that, after playing a bit with cadquery, for me it is easier to create parts in python than manually :smiley:
PS use cadquery-freecad-module 2.0

Ahh, damn, just noticed your reply.
In the end, I drew my own up…

However, I’ll have a look at that. It would be quicker than manually selecting each of the colour rings to generate a series of values. :slight_smile:

3 Likes

@xavierw
good-o :smile:
please keep me informed about the conversion with my StepUp script :slight_smile:

Holy cow that resistor looks awsome! What did you use to draw it?

from an earlier post of @xavierw:

I’d say it’s what you get inside ProE when you render the model, won’t look as nice in KiCAD or FreeCAD, but maybe in blender after you played with the materials a bit after using @maui’s StepUp tool to get the pcb assembly over there.

@xavierw
You don’t want each value on those, unless you’re insane or a genius. :wink:
What is the STEP file size for that resistor btw? Looks marvelous… I wage a guess, the VRML file will come in at 800kB+ unless you find a way to control the amount of segments being used for round surface approximation - I had no luck so far :worried:
Doesn’t ProE have some kind of facility where you can code behaviors of model parameters according to some table? I know it exits in Inventor… never used it though.

The footprints are generic and there currently is no way of transferring values from the symbols over to the 3D models in an automated fashion in KiCAD… which means you’d need one resistor symbol, footprint and model per value… which E-series do you had in mind? :open_mouth:

Not even this is possible in KiCAD for now, which is way simpler:

@SBW
I cheated a bit: the photo attached was actually from a Keyshot render.
In Creo, it looks fine, just not as realistic as it’s just the model, not the render.

In FreeCAD, the STEP model is ok:

BTW, the STEP file is 120KB in size. Not too large, but not practical if you have several different values.
In all fairness, I went to model something that looks realistic rather than simple: the colour rings are actually a “thickness” so emulate a band of paint on top of the actual resistor rather than just changing the colour of a section of the resistor’s body.

@Joan_Sparky
I need to investigate what scripting / lookup is possible with Creo. If I could assign a text file and associate that with different colours, I could then write a simple macro to generate a list of values, much like @cbernardo has done with VRML. Alternatively, I’ll try to get my head around Python (I’ve never done that, my last scripting goes back to Turbo Pascal when I was a university!) and see if I can generate a script with @maui’s FreeCAD scripting stuff.

Zip file of step model attached.
res.zip (20.0 KB)

1 Like

ran the STEP model through my FreeCAD/python script to get the VRML model: 2.8 MB
You really don’t want to make every value… a couple different ones of these on a single board and the 3D viewer will have a stroke :smile:

Resistor_0.25W_TH.wrl.zip (346.6 KB)

Can you tell Creo how many segments per 360deg it uses for the surfaces?
I can’t find any settings for this in Autodesk Inventor, nor in FreeCAD (after importing the STEP model)… but maybe your CAD has got an option for that to get the file size down?

One more thing, you might want to realign your modeling planes to fit KiCADs world (Z-axis is away from pcb, Y upward) as otherwise you have to realign every single one of them models (and you really don’t want that):

2 Likes

Thanks.
Regarding segments, the one I posted earlier has 24 - I just counted them in FreeCAD. Maybe there’s the option to make less. I think the added complication comes from making it look nice. If I were to simplify, the STEP version ends up being around 60KB and resulting conversion to VRML would be a lot smaller too I guess.

You can trial&error yourself as you got freecad already… just load the python script from github that is linked in my last post and open it in freecad (edit scripts button), modify some bits and then run it (run button).
This way you get scaled components for KiCAD from STEP files by clicking on a button in FreeCAD only - couldn’t get it to work outside of FreeCAD unfortunately…
You can change the license text to any other if you want, shouldn’t fault if you stick to the layout that is there. The license will be added to both the VRML and the STEP file, as both are needed for StepUp.

1 Like

I (nor anyone else I guess) really need the VRML version of TH resistors (as well as other TH components) as they’re already available from @cbernardo’s scripts - I’ve generated all the various components and they work fine with the built-in 3D viewer in KiCAD.

I really wanted to have a STEP version of the models so I can use the new scripts allowing 3D modelling outside of KiCAD. The examples here use FreeCAD, but of course you can use any other 3D CAD/CAM package that can read STEP files.

With a 3D model of the PCB in STEP, I can then do my case design and ensure everything fits as well as generating any marketing material :slight_smile:

Ah, didn’t see/read that… understandable.

At least you got me to write some doc for the script and some pitfalls, in case others go down that path. :blush:

OK, I’ve made some good progress with my antiquated use of PTH components :stuck_out_tongue:

However, I have two points I think worth making out, although they are only relevant to PTH usage:

Following a lengthy discussion last night on IRC, as far as I can tell (and from much virtual head banging in the chat room LOL), there’s a lot of confusion regarding positioning of components and the alignment between footprint in pcbnew, VRML and STEP files.

From the [KiCAD rules][1], all SMDs are placed with the centre of component as origin. See 3.3 and 6.4. This makes it easy to line up the footprint with the VRML model in KiCAD 3D Viewer and a STEP model for exporting to MCAD using the FC macros.

But for PTH stuff, 6.3 ruins it all suggesting use pin 1 as origin.

@Joan_Sparky, I’ve tried using your scripts to creat some clean STEP models from existing VRML models, but I do have a problem with the logging stating:

>  Traceback (most recent call last):
>   File "C:/Users/Xavier/AppData/Roaming/FreeCAD/kicad_StepUp_vrml_export.FCMacro", line 58, in <module>
>     fileName=sys.argv[1][:-4]
> <type 'exceptions.IndexError'>: list index out of range

Any idea where to look?

One day I hope to contribute more than ask questions, but I really appreciate the effort everyone’s putting into this, so thank you all :smile:
[1]: https://github.com/KiCad/kicad-library/blob/master/KiCad_Library_Convention.txt

the Joan’s script exports STEP file to scaled VRML; the opposite way is unfortunately not viable for mechanical purposes…
(it is a pity because all the kicad mesh models out there are useless for MCAD world)
that is why I started this topic and the 3D MCAD library of STEP models

1 Like

What @maui said… the workflow for me is Inventor > STEP > VRML and the script automates that + adds license info to the files.

I just tried the opposite, importing a VRML into FreeCAD 0.16 and exporting it as STEP… looks really broken. Whatever comes out of that is just some sort of metadata, no geometry data inside.

I ignore that as it’s not logical :wink:
All models I create are centered… may whoever thought it should be different piiiieep

@maui, @Joan_Sparky,
Sorry, I did mean going from STEP to VRML!
I have converted other STEP models to VRML using various 3D packages, but they all seem to make a real mess of it, hence why I’d like to try using Joan’s scripts :smile:
Do you have some instructions on setting it up? Is it just a case of having your Python script loaded and editing only the paths and creator lines in your screenshot above? Any other dependencies I might have missed causing the problem?

@xavierw
if you have downloaded kicad StepUp, inside there is a small script with bat/bash file

launch-kicad_StepUp-step-to-vrml-example.bat

launch-kicad_StepUp-step-to-vrml-example.sh

and the python file is

kicad_StepUp_vrml_export.FCMacro

just edit the batch with the step model you need and launch the batch
e.g.

cd %~p0
start "" "%PROGRAMFILES%\FreeCAD 0.15\bin\freecad" shapes/sod80.step kicad_StepUp_vrml_export.FCMacro