I created a new kicad3Dmodels library

Yeah, it would be nice but too much effort or no really need for that.

Are you experiencing the new 3D Viewer (openGL mode) slower than the old one? I expect that it is much more faster (faster load and rendering) and some users (from this forum and launchpad) are reporting that it renders faster too.
Raytracing render mode is another subject - it is expected to be very slow by nature.

I use to put the unique reference of the part in Manufacturer Part Number (there is a lot of discussion on this forum too) and a value in Value
I think the MPN field in library would be a plus

I do use also external sw (Blender) for improving the 3D rendering, but the translation from the KiCAD board and Blender model is much easier if the 3D parts come with material properties and in a format that Blender can easily manage/integrate ā€¦
(STEP model does not allow any kind of material properties) I hate duplicate my effortā€¦

Moreover, I would like to thank you, Mario, for your nice and useful work in 3D refactoring that you have done! I find 3D viewer much faster and usable than before and a lot of 3D mechanical integration in KiCAD would not be here without your job. :smiley:
Maurice

3 Likes

Any VRML implementation out there is quirky. I can improve on the VRML2 support but (a) it already works much better than the old parser and (b) it has no value to me for mechanical checks. But out of curiosity, what quirky things donā€™t you like about the new parser? :stuck_out_tongue:

I occasionally lurk here and I had an idea about these problems, but I was kind of reluctant to come with a proposal about these problems, since I canā€™t code well in c++ and devs have more important work to doā€¦ But I see here other people and devs are interested in a 3d eye candy, tooā€¦ So Iā€™ll biteā€¦

Quite some time ago I was thinking how nice itā€™d be, if looks could be improved, but not at the cost of the kicad 3d performance and without objections of nay-sayers :slight_smile:
One interesting solution would be the comments in the model files since STEP and VRML can have comments. They could be used similar to #pragma directive in C/C++. They could be ignored or processed according to settings.

So one would add comments to a model file with relevant information - material names, properties, additional information for Blender files etc (used with a custom importer for the Blender), STEP files could point to their VRML counterparts etcā€¦ With these comments models would have to render same as they render now.

Then one would have to have a filter in a form of python script or dll/so library, which would pipeline file before importing it through the relevant model plugin. Model file would include a name of that filter plugin which would be called with some/all parameters from footprint (name, value, custom) and would tune model file accordingly (set colors and other material propeties, duplicate geometry, generate model on-fly, set some state of model like switch position etc.) Model cache would contain those parameters as well to diferentiate cached models.
No filter installed would simply mean a fallback - models would look exactly same as they do now.

Best part: since all information is contained in comments, there would be nearly zero performance impact and no ā€œbloatā€, since filters would be completely optional. People who like nice renderings would just enable/install appropriate filters.

There would be other benefits as well, like materials could also then be standardized across render platforms.

The Kicad vrml export could be just appended with comment containing model parameters for the Blender or other program to render appropriately. Different versions of model would just include original model.

Thoughts?

Hi Ales,
I didnā€™t understood the thing.

I believe at this moment STEP and VRML support on KiCad already support comments, so you can add whatever you want there.

VRML files already have Material information that will be useful if you render on other sw (eg: blender).
Other more complex things, as you said, it will need customizationā€¦ and will need someone that will develop that customization.

In any case, what you describe, I think if that would be something useful for you, you will need to implement it yourself :wink: Or find someone with the same need that want to implement it.

So let me explain what i will use this for

Iā€™m trying to make a true replica of a C64 board. I have most of the 3d shapes in place but iā€™m missing a few

All the resistors are just boring beige ones and i want to make them look better. its just eyecandy but still

Iā€™m not a programmer or anything and learning Kicad has been hard enough. So a small windows tool where i could enter a resistor value and get an wrl file would be the optimal

i tried to look for pre generated ones but so far i could only find teh color rings and a resistorā€¦ not any premade like a 330 ohm resistor or 470 ohm

At this moment there are pre-generated ā€œFilm Carbon 1/4W 5%ā€ and Chip ā€œEIA 0603 METRIC 1608ā€ ā€œEIA 0805 METRIC 2012ā€ ā€œEIA 1206 METRIC 3216ā€

The pre-generated files are in the zip files here:

For example. for the Film Carbon you will find in this zip:
https://github.com/KammutierSpule/kicad3Dmodels/blob/master/generated/Resistors/kicad3Dmodels-Resistors-Film_Carbon-v0.1.1.zip
Press Download to get the file.

Once you unzip the file you will find the 330 ohm and 470 ohm resistors in the folder:
Film_Carbon/Film_Carbon_5TOL_4B_025W/R331.wrl
Film_Carbon/Film_Carbon_5TOL_4B_025W/R471.wrl

Mind that this only works with KiCad 5 and you need to keep the contents of Film_Carbon folder where are the main needed files.

that is why i wanted to generate 1 single wrl file so its not dependent on kicad 5 but can be used in 4.0.7

dinner time

It was not the goal of this project to generate single files, as it will generate huge amount of disk space if you have lots of resistor values.

You can still use the resistor and ring WRL blocks but you will need to learn how to change it in WRL, adding manually the contents of the rings to the right places.
In practice you will need to change ā€œInline { url ā€œā€¦/ring_0.wrlā€ }ā€ and ā€œInline { url ā€œā€¦/RESAD780W55L630D240B.wrlā€ }ā€ with the contents (in such a way that ā€œit worksā€) of the WRL files.

view3Dscene is a good tool to debug WRL files:
https://castle-engine.io/view3dscene.php

With some copy and paste I created a single file (just one ring so far):

I guess I should fork your repo and add scripts to keep the licensing square.

IT ALREADY LOOKS GREAT!!!

Better than that ā€¦ - only if the values are automatic adjustedā€¦

Just for fun comparison works OUT OF THE BOXā€¦

Paul

Lol, shouty bragging guy is everywhere :slight_smile: Any relation to Donald Trump?

i guess that assumes Kicad 5 ?

do we know how far out version 5 is? if its arround the corner i could install it but i guess it will update files so i no longer can use them in 4.0.7

I just made a SYNCH in my GIT clone this week ā€¦
The version seems good enough for regular use

But pretty sure some issue appears here and there
so far none

Paul

Here is the easy part, this script generates standalone WRL files for a specified value, it needs the 13 ā€œseedā€ files from Kicad3dmodels. It needs some work, but seems to generate files ok.

#!/usr/bin/env python

# -*- coding: utf-8 -*-

import shutil
import os

class ModelGenerator:

    def __init__(self):
        self.source_folder = 'C:/github/kicad3Dmodels/generated/Resistors/Film_Carbon'

    def generate_model (self, value):

        dest_name = 'res_%d.wrl' % value


        # copy the resistor model
        res_body_filename = 'RESAD780W55L630D240B.wrl'
        shutil.copy (os.path.join(self.source_folder, res_body_filename), dest_name)


        # copy the rings
        outf = open (dest_name, "a")

        transforms = []
        transforms.append ("translation -.90 0 .51 scale .55 1.22 1.22")
        transforms.append ("translation -.53 0 .51 scale .55 1.04 1.04")
        transforms.append ("translation -.18 0 .51 scale .55 1.03 1.03")
        transforms.append ("translation 0.80 0 .51 scale .55 1.22 1.22") # tolerance

        mag = 0
        while value > 100:
            value /= 10
            mag += 1

        # 4 band code
        digits = []
        digits.append ((value / 10) % 10)
        digits.append (value % 10)
        digits.append (mag)

        # 10 is gold, 11 is silver
        digits.append (10)

        for j in range (0,4):
            digit  = digits [j]

            source_filename = os.path.join(self.source_folder, 'ring_%d.wrl' % digit)

            with open(source_filename) as file:
                ring_data = [line.rstrip() for line in file]

            seen_start = False
            for line in ring_data:
                if "geometry" in line and not seen_start:
                    outf.write ("Transform { %s children [ \n" % transforms[j])
                    seen_start = True

                outf.write (line + '\n')

            outf.write (" ] }")

        #
        outf.close()

# main

model_gen = ModelGenerator ()
model_gen.generate_model (1)
model_gen.generate_model (12)
model_gen.generate_model (120)
model_gen.generate_model (1200)  #1k2
model_gen.generate_model (12000) # 12k
1 Like

i guess i can just put the values i need in to the end of the file?

i only need to do this once, but lets think of others too and maybe have this as a tool in kicad

i ended up with this list of values:

model_gen.generate_model (3300)
model_gen.generate_model (470)
model_gen.generate_model (1500)
model_gen.generate_model (1000000)
model_gen.generate_model (1000)
model_gen.generate_model (6800)
model_gen.generate_model (47000)
model_gen.generate_model (470000)
model_gen.generate_model (10000)
model_gen.generate_model (2100)
model_gen.generate_model (390)
model_gen.generate_model (75)
model_gen.generate_model (120)
model_gen.generate_model (100)
model_gen.generate_model (4700)
model_gen.generate_model (230)
model_gen.generate_model (15000)
model_gen.generate_model (1200)
model_gen.generate_model (0)

the 0 value came out as only black stripes and the 3.3K came out as orange stripes only. Maybe i did something wrong? used the latest python for windows

that is the 3.3K oneā€¦ looks ok-ish but sure there is a small mistake somewher

think i figured it but will need to test

first ring is orange and uses this:

USE RES-RING-COLOR

3rd ring is red but uses the same so it will come out as orangeā€¦

will try and hand edit it and see if the right colors come up

yepā€¦ worked

file now looks like this: https://pastebin.com/mMe4UwAS