I created a new KiCAD 3D viewer specific VRML exporter for Blender


#1

Hi,

recently i used Blender to create a few 3D models for KiCAD and was unsatisfied with the workflow. I tried different ways to get my models from Blender to KiCAD which all had some minor problems.

  1. Blenders internal VRML 2.0 exporter doesn’t use all material properties why exported models look not very good in KiCAD.
  2. Blenders internal X3D exporter works fine with all material properties and the models look good in KiCAD, which can also read X3D models. But when exporting the whole board in pcbnew as VRML all X3D models were missing, which was a problem when importing the whole board back into Blender.
  3. For me the only working way so far was to export the models from Blender as OBJ or 3DS files and import them in Wings3D. Then i had to export them in Wings3D to the VRML format and can use them in KiCAD with no restrictions. Sadly i found no commandline mode in Wings3D which makes the extra step a bit annoying when converting multiple 3D models.

So i thought that i create a modified VRML 2.0 exporter for Blender which incorporates all relevant material properties. Than i could just use the new exporter and didn’t have to use the extra step with Wings3D in-between.

I used the existing VRML 2.0 exporter from Blender as basis and removed all unnecessary parts (like textures, etc) and added the missing material properties. Now it’s easy to create KiCAD 3D models with Blender in just one step and another good thing is that Blenders VRML models are only about 20-25% the size of the Wings3D exported files because i removed some parts which are not used in the 3D viewer (like Normals).

So if anybody wants to try the Blender addon it could be downloaded from this dropbox link
http://pastebin.com/tAvy8qNn

To install just download the file from pastebin, go to Blender “User preferences->addons->Install from file” and select the Python file. After that activate it in the addon list (categorie TESTING) and you have a new export option available named “VRML2 to KiCAD (.wrl)”.

The default options work for me if you use 1 blender unit as 1mm while modeling. Therefor the default scaling is set to 1/2.54=0.39 to correct the dimension when exporting. When you work with inches you have to change the scaling in the export window.

Suggestions and bugfixes are welcome here in the thread or as private message to me.

Ciao,
Rainer


3D viewer not rendering x3d files correctly
#2

Thanks again Rainer. This works great.

A related question - have you seen any video/documentation on best practice for choices when colouring the models so they look the best (or at least don’t stand out terribly versus the standard ones)? Tips and tricks like how to create a pin 1 dot that looks realistic,

Thanks, Geoff


#3

Hi Geoff,

to be honest i didn’t search for this. I model and add materials in Blender the way i want them. The OpenGL real-time preview in Blender looks nearly the same as the 3d viewer in KiCAD, so i can get a good estimation of the final looks. For coloring in Blender only use colors and no textures because they are not supported in KiCAD.

Ciao,
Rainer


#4

So far I’ve done okay, however that pin 1 dot thing is still eluding me. I used a boolean intersection with a 1x1x1mm cylinder half embedded in the top, and then deleting the top faces, only for some reason in KiCad the top of the model then turns white.


#5

Normally it is no good idea to delete faces from objects. Because without face you can look to the inner side of the object which is not visible because the normals of the faces point outwards.
You can upload your Blender model somewhere and i can take a look if i see your problem.


#6

I sorted it by restarting over. Rather than have the pin 1 marker recessed into the model I just had a pure black circle mesh 0.1mm above the component. It seems to work out okay that way. Do you have a better way?

I did remove the faces under the body of the component that are unseen.


#7

If you just use VRML models within KiCAD and don’t use them for MCAD collaboration (in the STEP format) this should be fine (if KiCAD is able to show them).
But I had trouble with single sided planes in FreeCAD or KiCAD in the past… can’t remember.
Was a huge thread about all sorts of this 3D model stuff with @maui and @kammutierspule where I tried to get a MELF housing with transparent glass body and pin marker done…
I don’t know where that compatibility is at right now as KiCAD can show STEP now in the nightly version and we dropped that problem.
Anyhow, since that time I use recessed protruding pin markers on the model housings (+ some special low-res text to make them look more nice) that are part of the mesh. No single faced hovering planes.


#8

[quote=“Joan_Sparky, post:7, topic:2874”]
Anyhow, since that time I use recessed pin markers on the model housings (+ some special low-res text to make them look more nice) that are part of the mesh.
[/quote]Nice one. Well with that news, I’ll go back to trying that. The mesh circle looks fine, but it’s a kludge and in future versions of KiCad it might become obviously so.


#9

That’s what I use:

works fine in either VRML or STEP.


#10

I didn’t understood the issue, but I believe it should be the same :slight_smile: … nothing changed.
I think I remember we discuss something on that MELF, it was about “3D surfaces” (instead of 3D solids) but that was just as a matter of optimization. (And it may was because also the transparent ring of the MELF and its transparency rendering on Raytracing… that it would look better if it was just one surface instead of solid… but its just related with otimization and to the nature of the render)