Merge branch 'master' of ssh://free-cad.git.sourceforge.net/gitroot/free-cad/free-cad
This commit is contained in:
commit
0d3689380c
|
@ -170,9 +170,14 @@ MARK_AS_ADVANCED(FORCE FREECAD_LIBPACK_CHECKFILE6X FREECAD_LIBPACK_CHECKFILE7X)
|
||||||
# -------------------------------- Python --------------------------------
|
# -------------------------------- Python --------------------------------
|
||||||
|
|
||||||
|
|
||||||
|
#http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=677598
|
||||||
set(Python_ADDITIONAL_VERSIONS "2.3" "2.4" "2.5" "2.6" "2.7" "2.8" "2.9")
|
set(Python_ADDITIONAL_VERSIONS "2.3" "2.4" "2.5" "2.6" "2.7" "2.8" "2.9")
|
||||||
find_package(PythonLibs REQUIRED)
|
|
||||||
find_package(PythonInterp REQUIRED)
|
find_package(PythonInterp REQUIRED)
|
||||||
|
IF (NOT DEFINED PYTHON_VERSION_STRING)
|
||||||
|
find_package(PythonLibs REQUIRED)
|
||||||
|
ELSE (NOT DEFINED PYTHON_VERSION_STRING)
|
||||||
|
find_package(PythonLibs ${PYTHON_VERSION_STRING} EXACT)
|
||||||
|
ENDIF(NOT DEFINED PYTHON_VERSION_STRING)
|
||||||
|
|
||||||
IF(NOT PYTHONLIBS_FOUND)
|
IF(NOT PYTHONLIBS_FOUND)
|
||||||
MESSAGE("Python not found, install python!")
|
MESSAGE("Python not found, install python!")
|
||||||
|
|
|
@ -38,6 +38,7 @@ else: gui = True
|
||||||
|
|
||||||
#***************************************************************************
|
#***************************************************************************
|
||||||
# Tailor following to your requirements ( Should all be strings ) *
|
# Tailor following to your requirements ( Should all be strings ) *
|
||||||
|
global fafs
|
||||||
#fafs = '$fa = 12, $fs = 2'
|
#fafs = '$fa = 12, $fs = 2'
|
||||||
#convexity = 'convexity = 10'
|
#convexity = 'convexity = 10'
|
||||||
params = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/OpenSCAD")
|
params = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/OpenSCAD")
|
||||||
|
@ -106,7 +107,6 @@ def process_object(csg,ob):
|
||||||
if ob.Type == "Part::Sphere" :
|
if ob.Type == "Part::Sphere" :
|
||||||
print "Sphere Radius : "+str(ob.Radius)
|
print "Sphere Radius : "+str(ob.Radius)
|
||||||
check_multmatrix(csg,ob,0,0,0)
|
check_multmatrix(csg,ob,0,0,0)
|
||||||
global fafs
|
|
||||||
csg.write("sphere($fn = 0, "+fafs+", r = "+str(ob.Radius)+");\n")
|
csg.write("sphere($fn = 0, "+fafs+", r = "+str(ob.Radius)+");\n")
|
||||||
|
|
||||||
elif ob.Type == "Part::Box" :
|
elif ob.Type == "Part::Box" :
|
||||||
|
@ -118,7 +118,6 @@ def process_object(csg,ob):
|
||||||
elif ob.Type == "Part::Cylinder" :
|
elif ob.Type == "Part::Cylinder" :
|
||||||
print "cylinder : Height "+str(ob.Height)+ " Radius "+str(ob.Radius)
|
print "cylinder : Height "+str(ob.Height)+ " Radius "+str(ob.Radius)
|
||||||
mm = check_multmatrix(csg,ob,0,0,-ob.Height/2)
|
mm = check_multmatrix(csg,ob,0,0,-ob.Height/2)
|
||||||
global fafs
|
|
||||||
csg.write("cylinder($fn = 0, "+fafs+", h = "+str(ob.Height)+ ", r1 = "+str(ob.Radius)+\
|
csg.write("cylinder($fn = 0, "+fafs+", h = "+str(ob.Height)+ ", r1 = "+str(ob.Radius)+\
|
||||||
", r2 = " + str(ob.Radius) + ", center = "+center(mm)+");\n")
|
", r2 = " + str(ob.Radius) + ", center = "+center(mm)+");\n")
|
||||||
if mm == 1 : csg.write("}\n")
|
if mm == 1 : csg.write("}\n")
|
||||||
|
@ -126,7 +125,6 @@ def process_object(csg,ob):
|
||||||
elif ob.Type == "Part::Cone" :
|
elif ob.Type == "Part::Cone" :
|
||||||
print "cone : Height "+str(ob.Height)+ " Radius1 "+str(ob.Radius1)+" Radius2 "+str(ob.Radius2)
|
print "cone : Height "+str(ob.Height)+ " Radius1 "+str(ob.Radius1)+" Radius2 "+str(ob.Radius2)
|
||||||
mm = check_multmatrix(csg,ob,0,0,-ob.Height/2)
|
mm = check_multmatrix(csg,ob,0,0,-ob.Height/2)
|
||||||
global fafs
|
|
||||||
csg.write("cylinder($fn = 0, "+fafs+", h = "+str(ob.Height)+ ", r1 = "+str(ob.Radius1)+\
|
csg.write("cylinder($fn = 0, "+fafs+", h = "+str(ob.Height)+ ", r1 = "+str(ob.Radius1)+\
|
||||||
", r2 = "+str(ob.Radius2)+", center = "+center(mm)+");\n")
|
", r2 = "+str(ob.Radius2)+", center = "+center(mm)+");\n")
|
||||||
if mm == 1 : csg.write("}\n")
|
if mm == 1 : csg.write("}\n")
|
||||||
|
@ -137,7 +135,6 @@ def process_object(csg,ob):
|
||||||
print ob.Radius2
|
print ob.Radius2
|
||||||
if ob.Angle3 == 360.00 :
|
if ob.Angle3 == 360.00 :
|
||||||
mm = check_multmatrix(csg,ob,0,0,0)
|
mm = check_multmatrix(csg,ob,0,0,0)
|
||||||
global fafs
|
|
||||||
csg.write("rotate_extrude("+convexity+", $fn = 0, "+fafs+")\n")
|
csg.write("rotate_extrude("+convexity+", $fn = 0, "+fafs+")\n")
|
||||||
csg.write("multmatrix([[1, 0, 0, "+str(ob.Radius1)+"], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]])\n")
|
csg.write("multmatrix([[1, 0, 0, "+str(ob.Radius1)+"], [0, 1, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]])\n")
|
||||||
csg.write("circle($fn = 0, "+fafs+", r = "+str(ob.Radius2)+");\n")
|
csg.write("circle($fn = 0, "+fafs+", r = "+str(ob.Radius2)+");\n")
|
||||||
|
@ -150,7 +147,7 @@ def process_object(csg,ob):
|
||||||
print ob.Base
|
print ob.Base
|
||||||
print ob.Base.Name
|
print ob.Base.Name
|
||||||
#if ( ob.Base == "Part::FeaturePython" and ob.Base.Name == "Polygon") :
|
#if ( ob.Base == "Part::FeaturePython" and ob.Base.Name == "Polygon") :
|
||||||
if ob.Base.Name == "Polygon" :
|
if ob.Base.Name.startswith("Polygon") :
|
||||||
f = str(ob.Base.FacesNumber)
|
f = str(ob.Base.FacesNumber)
|
||||||
r = str(ob.Base.Radius)
|
r = str(ob.Base.Radius)
|
||||||
h = str(ob.Dir[2])
|
h = str(ob.Dir[2])
|
||||||
|
@ -158,34 +155,30 @@ def process_object(csg,ob):
|
||||||
print "Radius : " + r
|
print "Radius : " + r
|
||||||
print "Height : " + h
|
print "Height : " + h
|
||||||
mm = check_multmatrix(csg,ob,0,0,-float(h)/2)
|
mm = check_multmatrix(csg,ob,0,0,-float(h)/2)
|
||||||
global fafs
|
|
||||||
csg.write("cylinder($fn = "+f+", "+fafs+", h = "+h+", r1 = "+r+\
|
csg.write("cylinder($fn = "+f+", "+fafs+", h = "+h+", r1 = "+r+\
|
||||||
", r2 = "+r+", center = "+center(mm)+");\n")
|
", r2 = "+r+", center = "+center(mm)+");\n")
|
||||||
if mm == 1: csg.write("}\n")
|
if mm == 1: csg.write("}\n")
|
||||||
|
|
||||||
elif ob.Base.Name == "circle" :
|
elif ob.Base.Name.startswith("circle") :
|
||||||
r = str(ob.Base.Radius)
|
r = str(ob.Base.Radius)
|
||||||
h = str(ob.Dir[2])
|
h = str(ob.Dir[2])
|
||||||
print "Radius : " + r
|
print "Radius : " + r
|
||||||
print "Height : " + h
|
print "Height : " + h
|
||||||
mm = check_multmatrix(csg,ob,0,0,-float(h)/2)
|
mm = check_multmatrix(csg,ob,0,0,-float(h)/2)
|
||||||
global fafs
|
|
||||||
csg.write("cylinder($fn = 0, "+fafs+", h = "+h+", r1 = "+r+\
|
csg.write("cylinder($fn = 0, "+fafs+", h = "+h+", r1 = "+r+\
|
||||||
", r2 = "+r+", center = "+center(mm)+");\n")
|
", r2 = "+r+", center = "+center(mm)+");\n")
|
||||||
if mm == 1: csg.write("}\n")
|
if mm == 1: csg.write("}\n")
|
||||||
|
|
||||||
elif ob.Base.Name == "Wire" :
|
elif ob.Base.Name.startswith("Wire") :
|
||||||
print "Wire extrusion"
|
print "Wire extrusion"
|
||||||
print ob.Base
|
print ob.Base
|
||||||
mm = check_multmatrix(csg,ob,0,0,0)
|
mm = check_multmatrix(csg,ob,0,0,0)
|
||||||
global fafs
|
|
||||||
csg.write("linear_extrude(height = "+str(ob.Dir[2])+", center = "+center(mm)+", "+convexity+", twist = 0, slices = 2, $fn = 0, "+fafs+")\n{\n")
|
csg.write("linear_extrude(height = "+str(ob.Dir[2])+", center = "+center(mm)+", "+convexity+", twist = 0, slices = 2, $fn = 0, "+fafs+")\n{\n")
|
||||||
csg.write(vertexs2polygon(ob.Base.Shape.Vertexes))
|
csg.write(vertexs2polygon(ob.Base.Shape.Vertexes))
|
||||||
if mm == 1: csg.write("}\n")
|
if mm == 1: csg.write("}\n")
|
||||||
|
|
||||||
elif ob.Base.Name == "square" :
|
elif ob.Base.Name.startswith("square") :
|
||||||
mm = check_multmatrix(csg,ob,0,0,0)
|
mm = check_multmatrix(csg,ob,0,0,0)
|
||||||
global fafs
|
|
||||||
csg.write("linear_extrude(height = "+str(ob.Dir[2])+", center = true, "+convexity+", twist = 0, slices = 2, $fn = 0, "+fafs+")\n{\n")
|
csg.write("linear_extrude(height = "+str(ob.Dir[2])+", center = true, "+convexity+", twist = 0, slices = 2, $fn = 0, "+fafs+")\n{\n")
|
||||||
csg.write("square (size = ["+str(ob.Base.Length)+", "+str(ob.Base.Width)+"],center = "+center(mm)+";\n}\n")
|
csg.write("square (size = ["+str(ob.Base.Length)+", "+str(ob.Base.Width)+"],center = "+center(mm)+";\n}\n")
|
||||||
if mm == 1: csg.write("}\n")
|
if mm == 1: csg.write("}\n")
|
||||||
|
|
|
@ -61,6 +61,7 @@ from tokrules import tokens
|
||||||
dxfcache = {}
|
dxfcache = {}
|
||||||
def translate(context,text):
|
def translate(context,text):
|
||||||
"convenience function for Qt translator"
|
"convenience function for Qt translator"
|
||||||
|
from PyQt4 import QtGui
|
||||||
return QtGui.QApplication.translate(context, text, None, \
|
return QtGui.QApplication.translate(context, text, None, \
|
||||||
QtGui.QApplication.UnicodeUTF8)
|
QtGui.QApplication.UnicodeUTF8)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user