Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save igmit/c09025216b277dc577e83d3d52e5668c to your computer and use it in GitHub Desktop.

Select an option

Save igmit/c09025216b277dc577e83d3d52e5668c to your computer and use it in GitHub Desktop.

Revisions

  1. igmit created this gist May 25, 2018.
    29 changes: 29 additions & 0 deletions FreeCAD - compile python script to exe on Win
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,29 @@
    # 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__