Created
January 6, 2018 22:00
-
-
Save rnagasam/d830e649c3f088119dbfdad4acbde596 to your computer and use it in GitHub Desktop.
FreeCAD scripting -- create a mesh using GMSH from within FreeCAD
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Use GMSH from within FreeCAD | |
# useful for performing any | |
# kind of scripting with the | |
# FEM module | |
# Require : FreeCAD > 0.17 | |
# : GMSH | |
# Required imports | |
import FreeCAD | |
import Part | |
import ObjectsFem | |
from femmesh import gmshtools # <FreeCAD_src>/Mod/Fem/femmesh/gmshtools.py | |
# create the document | |
doc = App.newDocument() | |
# add a box to the document | |
doc.addObject("Part::Feature","Shape") | |
doc.Shape.Shape = Part.makeBox(1,1,1) | |
# setup | |
ObjectsFem.makeMeshGmsh(doc, "Mesh") | |
doc.Mesh.Part = doc.Shape | |
# create the mesh; using gmshtools lets | |
# you do all of this without having to | |
# open FreeCAD | |
g = gmshtools.GmshTools(doc.Mesh) | |
g.create_mesh() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment