Close

Freecad mesh exporting

A project log for Silly software wishlist

Motivation to do some software projects by writing them down.

lion-mclionheadlion mclionhead 05/31/2018 at 09:410 Comments

Getting 4 grid fins in Freecad would take 4 gigs of RAM & many hours to calculate, so it was time to start tesselating objects.  The most intuitive method was file->export, but it's very slow to show the results.  The faster way was to load the Mesh Design workbench, but the tool isn't in the toolbar but in the menu bar under Meshes->"Create mesh from shape".  The 2 mane problems are it isn't smart enough to export only the visible objects, so you need to go to View->Visibility->Select visible objects first.  It then miscalculates the normals, so random triangles show up black.  

The more subtle problem is this

is converted to this:

You have to use standard tesselation &  LinearDeflection of 10mm to make it smarter.  

for i in srcObjects:

mesh = doc.addObject("Mesh::Feature","Mesh")

src = doc.getObject(i)
shape = src.Shape

mesh.Mesh = MeshPart.meshFromShape(Shape=shape,LinearDeflection=10, AngularDeflection=0.523599, Relative=False)

It still creates many unnecessary triangles but is acceptable.  Then either flip the normals in the black  meshes.

mesh.Mesh.flipNormals()

or set the double sided option 

mesh.ViewObject.Lighting=u"Two side"

but double sided meshes are slower to render.  Only use them if the object is only 1 surface.

Then collect all the meshes in a single part with its own transformation values.

part = App.activeDocument().addObject('App::Part','Part')
    part.Label = "Grow a mane"
    for i in meshes:
        part.addObject(i)

Creating a script to select the right polygons, tesselate, fix the normals, & group into parts was easier than feared, but would be a lot easier in a program that worked.

After neglecting many dropped parts, a rough idea of the complete model finally appeared.

The booster model made it clear that they're just whacking on the Falcon 9 grid fins without any changes.  

Discussions