FEM and Blender: Difference between revisions

From wikiluntti
Line 132: Line 132:
Cad canopy 2b gmsh.png|thumb|Gmsh can use the second part, also. Need to check if FreeCAD can read that file.
Cad canopy 2b gmsh.png|thumb|Gmsh can use the second part, also. Need to check if FreeCAD can read that file.
Cad canopy 2c FreeCADgmsh.png|thumb|FreeCAD has also Gmsh mesh generator. That will generate the mesh, but while solving gives an error: "Nodes, but no results found in frd file. It means there only is a mesh but no results in frd file. Usually this happens if CalculiX returned no results (happens on nonpositive jacobian determinant in at least one element)"
Cad canopy 2c FreeCADgmsh.png|thumb|FreeCAD has also Gmsh mesh generator. That will generate the mesh, but while solving gives an error: "Nodes, but no results found in frd file. It means there only is a mesh but no results in frd file. Usually this happens if CalculiX returned no results (happens on nonpositive jacobian determinant in at least one element)"
Cad canopy 2d FreeCADgmsh.png|thumb|By trying again, it works!
Cad canopy 2d FreeCADgmsh.png|thumb|By trying again, it works! Force is 10 N.
Cad canopy 2e FreeCADgmsh.png|thumb|Changed the Force to 100 N, and the maximum size of mesh to 10. The later increased the computation time a lot, the time being about 9 s.
</gallery>
</gallery>



Revision as of 00:26, 29 June 2025

Introduction

Blender and CAD

import bpy
import csv

def export_selected_mesh_dimensions_to_csv(filepath):
    """Export Parts
    Args:
        filepath (str): Le chemin du fichier CSV de sortie.
    """

    with open(filepath, 'w', newline='', encoding='utf-8') as csvfile:
        fieldnames = ['Part', 'Section X (mm)', 'Section Y (mm)', 'Length Z (mm)']
        writer = csv.DictWriter(csvfile, fieldnames=fieldnames)

        writer.writeheader()
        for obj in bpy.context.selected_objects:
            if obj.type == 'MESH':
                
                dimensions = obj.dimensions
                x = [0,0,0]
                x[0] = round(dimensions.x * 1000, 3)
                x[1] = round(dimensions.y * 1000, 3)
                x[2] = round(dimensions.z * 1000, 3)
                x.sort()

                writer.writerow({'Part': obj.name, 'X (mm)': x[0], 'Y (mm)': x[1], 'Z (mm)': x[2]})

filepath = "/home/user/Downloads/part_list.csv"  # Replace destination path

export_selected_mesh_dimensions_to_csv(filepath)

FreeCAD import

Steps:

  • Export from Blender. If exporting STL, scale on export 1000x. Problems with non-manifold geometry.
    • Use Boolean to make on mesh
    • Non-manifold: Select -> Select All by Trait -> Non Manifold, also the others from there. Remove the faces and then dissolve the edges (Limited Dissolve or X > Dissolve Edges).
      • (Select Similar). This is often useful to select vertices with only one connecting edge
      • (Select Linked)
      • W > Specials > Remove doubles Doubles,
    • Check the normals outward: Edit mode, Select All, Mesh -> Normals -> Outward (Shift + N)
    • Eliminate the bolts and some holes
  • FreeCAD
    • Part -> Create shape from mesh
    • Part -> MakeSolid


Some problems (see a Part check Geometry)

  • Geometry is a shell -- not a solid: a shell mesh on meshing
    • Check this by right clicking on the mesh and printing mesh informations (Tasks: Node count vs Triangle count vs Tetrahedron count)
  • Self intersections
    • Use Boolean in Blender for all parts (both, if two are overlapping)
    • Self intersecting meshes are considered dirty
    • Use Part -> View -> Transparency to see the intersection points, if they persist.
    • eg Netfabb cleans

FEM Calculations of the Door Canopy

Workflow and test examples

  1. Make the Blender mesh and export as .obj file
  2. Make the mesh using GMSH or FreeCAD, and use FreeCAD to FEM calculations

Simple Cube

Works OK with the FreeCAD, not with the Gmsh

OBJ

STL

Two Cubes

The Door Canopy

Make it step by step.

Gmsh

Theory

Frame formulas: https://structx.com/frames.html

References