On Wednesday 31 July 2013 16:45:20 Kemal wrote:

Hey Guys,
I've no experience with any CAD program but I've to Programming something cause my new project.
My Project which is given me from my university as my Bachelor thesis and it demands from me to programming a python script which has to creates a Draft BSpline with given Vectors and converts it to a 3D model and finally export it as a Step file.

This is the code, I could create a cube and export it but when I try to import Draft, I get an Error
"File "/usr/lib/freecad/Mod/Draft/Draft.py", line 76, in <module>
    import FreeCAD, FreeCADGui, Part, math, sys, os, Image, Drawing, WorkingPlane
ImportError: No module named FreeCADGui"

freePath  ='/usr/lib/freecad/lib'
import sys
from FreeCAD import *
import Part
from PyQt4 import QtGui
import Part
def main() :
    mycube = Part.makeBox(20,2,20)
    mycube = Part.cast_to_shape(mycube)
    __objs__ = []

    __objs__.append( App.ActiveDocument.getObject("Box"))

if __name__ == '__main__':

I hope one of you can help me a little.

Hello Kemal,


you can't use any gui when using FreeCAD as python module, and GUI code would not make sense as there is no gui :)


Which version are you using? I'm running development, and here it draft import works with this warning:


FreeCAD 0.14, Libs: 0.14R2365 (Git)

FreeCAD Gui not present. Draft module will have some features disabled.


If you are on 0.13 stable you should stay there as 0.14dev will become unstable soon. Maybe check Draft.py and replace the module load code at the top with something like this (copyed from 0.14):


# import FreeCAD modules

import FreeCAD, math, sys, os, DraftVecUtils, Draft_rc

from FreeCAD import Vector


if FreeCAD.GuiUp:

import FreeCADGui, WorkingPlane

gui = True


print "FreeCAD Gui not present. Draft module will have some features disabled."

gui = False