Is there any possibility to export geometry to STL file with names of some surfaces - for a cylinder (bottom-->inlet, top-->outlet)? And how to add this into a such script?
import FreeCAD
import Part
from FreeCAD import Base
cylinder = Part.makeCylinder(1.0,6.0,Base.Vector(0,0,0),Base.Vector(1,0,0))
cylinder.exportStl("/home/cylinder.stl")
Yes, it is possible, but my problem is I don't know how to create a STL file that contains only surface, like a circle or a rectangular. The STL is saved in this way:
Geometry created in Sketcher contains only edges, there is no face to export to STL. You need to convert the sketcher geometry to faces. Then it will work.
Edges are curves and faces are surfaces. Thus it's not possible to create a valid mesh from your model because you would create degenerated triangles which is treated as an error by most applications.
This post addresses a very important topic for people using FreeCAD for engineering simulation, specifically computational fluid dynamics (CFD) with OpenFOAM.
CFD requires a computational mesh. The mesh can be generated within OpenFOAM using snappyHexMesh. snappyHexMesh uses geometry input in the form of triangulated surface files in either STL or OBJ format. Ascii STL and OBJ support "regions", or "patches". Call it what you like, it just means that triangles can be collected together under a particular name.
In the cylinder example, the triangles that make up one circular end could be labelled "inlet", the other circular end could be "outlet", and the curved part of the cylinder could be "wall". When the inside of this surface is meshed with snappyHexMesh, the resulting mesh will have boundary patches "inlet", "outlet" and "wall" on which flow boundary conditions can be applied for a CFD simulation of flow along a cylinder (pipe).
So the piece of functionality in FreeCAD that would be hugely beneficial to CFD/OpenFOAM users would be the ability to name regions of part surfaces, and the inclusion of those names with triangulated surface export. It is the ONE piece of functionality that today (Jan 2015) would make FreeCAD very attractive as a geometry generator for CFD with OpenFOAM. It would be much appreciated if the FreeCAD developers could comment on the viability/ease of such a development. (The functionality already seems to exist to highlight geometry faces, e.g. 1 of 6 faces of a box, in the GUI)
jrt wrote:I agree 100% with cfdfoundation. Anything new on this?
I guess not much. One can make face from sketch - there is an entry for that in Part workbench menu.
STL format looks easy enough to make a macro to export an STL in custom manner (that is, write your own STL as a raw file, via python). (but don't take this as a promise I'm going to do that - that's unlikely)
The FreeCAD developers are very few, and they work freely in their spare time. Consequently they mostly work on things that interest them. Currently there is much work on FEM. Most of FreeCAD's focus is on mechanical and architectural design.
Quite frankly, unless a new developer with interest in CFD comes in and starts contributing to FreeCAD, nothing will change.