Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save igmit/c09025216b277dc577e83d3d52e5668c to your computer and use it in GitHub Desktop.
Save igmit/c09025216b277dc577e83d3d52e5668c to your computer and use it in GitHub Desktop.
I had to generate set of spheres that had to be placed within cylinder to simulate some CFD. The algorithm was quite easy, but it was tricky to convert the resulting scene into one of the popular CAD formats. Ansys Fluent could eat *.step file, so here we go!
# FreeCAD_dir/bin/python.exe -m pip install pyinstaller
# FreeCAD_dir/bin/python.exe -m pip install pywin32
Now we have to go to "FreeCAD_dir/bin/" dir
# \Scripts\pyinstaller.exe file.py -p "FreeCAD_dir\Mod" -p "FreeCAD_dir\lib" -p "FreeCAD_dir\bin" -F
"file.exe" will be generated in dist folder.
An example of file.py
import FreeCAD
import Part
import pkgutil
import importlib
import platform
#adding one sphere
sphere0 = Part.makeSphere(2);
sphere0.translate(FreeCAD.Vector(float(0), float(0), float(-50 )));
Part.show(sphere0);
#generate *.step file to use it later on in CFD software
__objs__=[]
__objs__.append(FreeCAD.getDocument("Unnamed").getObject("Shape"))
Part.export(__objs__, u"667.step")
del __objs__
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment