3D new library for Mechanical CAD exporting and enclosure design


#141

Yeah, no that’s not what I meant.
My script will do the following:

  1. load STEP file list from given folder
  2. check hashfile if any file needs conversion
  3. load the STEP file
  4. modify scale of part, change lines to shaded
  5. safe as VRML
  6. new: create preview with povray
  7. modify STEP file preamble and add license
  8. modify VRML file preamble and add license
  9. repeat 3. for any other file not done yet
  10. write new hash file

So once I scaled and saved the part as VRML I then scale it again and create a povray scene, which is then rendered (directly) or I do that afterwards… depends on how I go.
Anyhow, once I found a camera position and relative part size that works and gives nice results I just scale the part and don’t mess with the camera anymore… should be easier that way, no?


#142

I have updated the step files within my repo.
I’m currently implementing the better vrml export.
@maui: I think i will write a separate file with the color definitions and maybe even a handler class. This should make it a bit easier to manage colors. Would this be ok for you?


#143

that sounds perfect :smiley:


#144

this is done importing the VRML file generated by kicad StepUp script exporter with material properties, and importing directly the materials in Blender :smiley:


#145

Good and similar results!


#146

@Joan_Sparky, with the new exporting routines you will not need scaling in FC anymore
Draft.scale(part, delta=App.Vector(0.3937,0.3937,0.3937), center=App.Vector(0,0,0), legacy=True)
the scaling is done numerically on coordinates …
that is avoiding size increasing that would be done by a new tessellation factor because of the scaling…


#147

Yeah, I dropped that part of my old code and used the scale ‘input’ of your export function like this:

export(__objs__,(PATH_toVrmlFiles + FNME_vrmlfile), 0.3937)

Is that correct?

I also got marmnis code working (exports with colored faces as expected, pretty neat and how it should be), just fiddling with the camera and light at the moment as the settings that come out of that macro are not useful.
Also his tessellation setting was at 1, the 0.03 you suggested is better.

Made me a 10x10x10 mm test object for this…

Do you know how to get surface smoothing for the renderer set up?
One can still see the edges of the faces on that sphere…

[Edit]
Think I found it: http://www.povray.org/documentation/3.7.0/r3_4.html#r3_4_5_2_4_1

You can specify both flat and smooth triangles in the same mesh. To do this, specify the smooth triangles first in the face_indices section, followed by the flat triangles. Then, specify normal indices (in the normal_indices section) for only the smooth triangles. Any remaining triangles that do not have normal indices associated with them will be assumed to be flat triangles.

Looks like it needs to be done in that FCmacro, that builds the povray file… but I have no clue how.


#148

Hi @everyone
I just want to share some other nice parametric generated models coming from FreeCAD CadQuery scripts
https://github.com/SchrodingersGat/kicad-packages3d/tree/master/Pin_Headers.3dshapes



many thanx to @SchrodingersGat to develop and share them! :smiley:
the MCAD 3D library is growing :wink:
we would need to build a common repo I think…

Just an info… is there anyone that has developed SUB-D connectors like DB9, DB15, DB25 etc?
Maurice


#149

I just did a design that used a NorComp DE9 connector. Their models are available here.


#150

@maui: I started the implementation of the new vrml export routine.
I just need to test the changes. Then I will extract the export part from the Freecad Macro file, and use it as import for the cadquery script. (I try to have this functionality only at one place.)
Do you have some test parts, which i can use?
Plans for the next days (I plan to be finished by Sunday):
Testing, exporting of my xh connectors with this script (extraction from Macro file), merge with master (if necessary) and pull request.

If this all works, i will extract the color part and implement it similar to http://pyopengl.sourceforge.net/pydoc/vrml.csscolors.html (I will use a dict for the color definitions. Unique name as key. Content: a new class for the management of colors.)

Should we open another communication channel for future questions regarding this script? (If yes: how can i reach you?)


#151

I think I am cooking…

So yeah, pretty straight forward…
Once I exported the VRML I grab the mesh-pieces again, get their boundingbox, calculate center and max dimension, then adjust position to get the mesh-center to <0,0,0> and scale it, so it’s longest dimension is 10mm and then it goes into a pov ray scene that has a camera and 2 lights set up (one yellowish camera light, one blueish backlight), to take a nice shot of a 10x10x10 mm big something.

Things that would be pretty cool:

  • material setup to have bells and whistles (I think I leave this to @maui :slight_smile: )
  • automate povray rendering (I’ll do that)
  • mesh triangle smoothing (no idea, do you think marmni could lend a helping hand there?)

@maui, I never want to see those ugly FreeCAD overview previews again :stuck_out_tongue_winking_eye:


#152

you can test on QFP or QFN models here
https://github.com/easyw/kicad-3d-models-in-freecad/tree/master/cadquery/FCAD_script_generator/generated_gw/qfp
https://github.com/easyw/kicad-3d-models-in-freecad/tree/master/cadquery/FCAD_script_generator/generated_qfn

that’s fine … I would start with a small dictionary adding colors that have already material properties as i.e. the list
material_properties_names=["as is","metal grey pins","gold pins","black body","resistor black body","grey body","dark grey body","brown body","light brown body","blue body","green body","orange body","red_body","pink body","yellow body","white body","light brown label","led red","led green","led blue", "led white"]
detailed at the beginning of the exportPartToVRMLwMaterials.FCMacro
those materials have been generated following Mario Guidelines doc…

I sent you a PM with my mail …
Maurice


#153

@Andy_P do you know where I could find also sub-D footprints?
thanx
Maurice


#154

I got a DB9-angled here:
Conn_DB9-angle.kicad_mod (4.5 KB)

Sorry, no model so far :wink:


#155

:thumbsup:

Where did you render that?
When can I try that models on kicad?


#156

Most of the models are the ones I already share… and @maui should have some of them even refined with specularity/reflections…

I used the new script of @maui to upgrade my VRML exports, then he pointed me to a script from some bloke on FreeCAD forums that can export FreeCAD meshes to povray with colors (not materials or surface smoothing unfortunately) and now I’ve got povray rendering automated:

I could do this all day :laughing:

I’ll upload the script next so you can have a play with it.
The models I need to go over again, as some of them have legacy issues.


Looking for good libraries examples or/and policies
#157

I played a bit with Blender scripting

thanks to @Joan_Sparky to point out the smoothing part of the rendering :smiley:

just an info: FreeCAD 0.16 stable has been released :wink:


Export to VRML, Holes and VIAs become hexagon, and pads lost
#158

script is on github:

works for me with:

  • FreeCAD 0.16 latest nightly
  • POVray 3.7
  • KiCAD latest nightly

#159

If you don’t mind, i will use the license adding stuff from this script within the step and wrl export features for the scripted 3d parts. I should be finished by later today.


#160

@Rene_Poschl @Joan_Sparky
if it is fine for both of you, I would add to the module 3D license something like gEDA:

As a special exception, if you create a design which uses this symbol, and embed this symbol or unaltered portions of this symbol into the design, this symbol does not by itself cause the resulting design to be covered by the GNU General Public License. This exception does not however invalidate any other reasons why the design itself might be covered by the GNU General Public License. If you modify this symbol, you may extend this exception to your version of the symbol, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version

This is also in planning to be done for KiCad libraries too…
Maurice


Contributing to update of VRML librarys to STEP?