Making 3D Models for KiCAD

Post Reply
parkview
Master Maker
Posts: 499
Joined: Tue Jun 24, 2014 8:25 pm
Location: Busselton
Contact:

Making 3D Models for KiCAD

Post by parkview » Mon Jun 01, 2020 7:34 pm

One thing I have done before in KiCAD was create a 3D model of a part so that it could be displayed in the 3D viewer. I quickly found this tutorial online: https://www.workshopshed.com/2019/04/cr ... for-kicad/ That didn't look too hard so I gave it a go.

I first sat down and measured all the components that I wanted to create:
parts_measurements.jpg
parts_measurements.jpg (57.98 KiB) Viewed 1232 times

I have been using DesignSpark Mechanical (DSM) as my main CAD package since 2013, so I quickly whipped up a 2.1mm Barrel Jack design, only to find that DSM doesn't allow you to export a STEP file. I did find that I could export an OBJ file and import the mesh file into Fusion 360 (yes, some people will say I should be using Fusion 360 be default and save my self the minor conversion pain). After importing (INSERT function) the OBJ mesh, I had to click on the lower right hand cog and select: 'Do Not Capture Design History', then I needed to convert the mesh into a true F360 body, by selecting all the components of the item and then: Modify | Mesh | Mesh to BRep. Note: the Mesh option wont show up unless you have removed the capture history. Nothing appears to happen.

I then select all the Mesh Bodies and delete them. This action doesn't delete them, but it does force the true F360 Bodies to appear, one per mesh.

Next, I give a material type to each of the bodies. I select all the new F360 Bodies of the part and select: Modify | Physical Material. I select the material/colour I want for each of the parts of the item from the extensive menu. I do this by dragging each material onto the surface of each of the parts of the 3D model. Here is an example of my 2.1mm Barrel Jack I created:
barrel-jack_2.1mm.jpg
barrel-jack_2.1mm.jpg (11.1 KiB) Viewed 1232 times

I save the part in native format, and then: File | Export the part as a STEP file. This file is then copied over to my personal KiCAD packages3d folder.
I can then add the 3D model to my part. Here is a sub-view of my UPS Monitoring and Distribution board with they circled new components:
3D_KiCAD_Parts_sml.jpg
3D_KiCAD_Parts_sml.jpg (55.58 KiB) Viewed 1232 times
This can be quite fiddly, especially for the USB socket. Some things are a bit out, but at least you get an overall view and appreciation of how it's all going to fit onto the PCB.

parkview
Master Maker
Posts: 499
Joined: Tue Jun 24, 2014 8:25 pm
Location: Busselton
Contact:

Re: Making 3D Models for KiCAD

Post by parkview » Mon May 03, 2021 9:26 pm

Ok, for this lot of KiCAD 3D models, I skipped F360, and figured out how to use FreeCAD to convert an OBJ file that I exported from Design Spark Mechanical (DSM), into a STEP file.

THE METHOD:
-----------------
In DSM, construct the KiCAD 3D model with separate part for each color material, ie: plastic, metal, pins etc.
Save the DSM model as a *.rsdoc, then save the model as an *.OBJ file.

In FreeCAD, Open the 'Parts' Workbench, create a new design and 'File | Import' in the OBJ file. I find that the Wavefront OBJ selection model imports the best. In the LH side, select all the imported mesh components of the model and from the top menu select 'Parts | Create Shape from Mesh'. Change the Sewing tolerance from 0.10, to 0.01 (you might have to delete the end 0 before it will let you insert a 0 in front of the 1).

You will see a block of new solids in the LH window. You can now delete the old Meshes if you like.
Select all the new 'Shapes' in the LH windows and from the top Menus select 'Parts | Convert to Solid'. Once this is done, you can delete the old Shapes if you like.

Congratulations, you now have a 3D object fully imported into FreeCAD as a solid.

To colorise each part, select all of the same color solids in the LH window, then right click and select 'Appearance'. A window will pop up underneath on the LH side. You can then change the 'Shape color'. You can do multiple items at the same time, ie: all black plastic, or gold pins etc.

Once the model has been coloriesed, you can then join all the parts together by selecting all the parts in the LH window and via the top Menu 'Parts | Boolean | Union'. This will condense the parts into a 'Fusion'.

Once done, save the project as a FreeCAD file, then select the 'Fusion' object in LH window and from menu 'File | Export' the object as a 'Step' file. KiCAD can then import the FreeCAD Step 3D model:
switch1-step.jpg
switch1-step.jpg (12.23 KiB) Viewed 172 times

Post Reply