Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
FreeCAD
FreeCAD
Commits
0d368938
Commit
0d368938
authored
Dec 24, 2012
by
wmayer
Browse files
Merge branch 'master' of
ssh://free-cad.git.sourceforge.net/gitroot/free-cad/free-cad
parents
9548d347
5caf64e4
Changes
3
Hide whitespace changes
Inline
Side-by-side
CMakeLists.txt
View file @
0d368938
...
...
@@ -170,9 +170,14 @@ MARK_AS_ADVANCED(FORCE FREECAD_LIBPACK_CHECKFILE6X FREECAD_LIBPACK_CHECKFILE7X)
# -------------------------------- 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"
)
find_package
(
PythonLibs 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
)
MESSAGE
(
"Python not found, install python!"
)
...
...
src/Mod/OpenSCAD/exportCSG.py
View file @
0d368938
...
...
@@ -38,6 +38,7 @@ else: gui = True
#***************************************************************************
# Tailor following to your requirements ( Should all be strings ) *
global
fafs
#fafs = '$fa = 12, $fs = 2'
#convexity = 'convexity = 10'
params
=
FreeCAD
.
ParamGet
(
"User parameter:BaseApp/Preferences/Mod/OpenSCAD"
)
...
...
@@ -106,7 +107,6 @@ def process_object(csg,ob):
if
ob
.
Type
==
"Part::Sphere"
:
print
"Sphere Radius : "
+
str
(
ob
.
Radius
)
check_multmatrix
(
csg
,
ob
,
0
,
0
,
0
)
global
fafs
csg
.
write
(
"sphere($fn = 0, "
+
fafs
+
", r = "
+
str
(
ob
.
Radius
)
+
");
\n
"
)
elif
ob
.
Type
==
"Part::Box"
:
...
...
@@ -118,7 +118,6 @@ def process_object(csg,ob):
elif
ob
.
Type
==
"Part::Cylinder"
:
print
"cylinder : Height "
+
str
(
ob
.
Height
)
+
" Radius "
+
str
(
ob
.
Radius
)
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
)
+
\
", r2 = "
+
str
(
ob
.
Radius
)
+
", center = "
+
center
(
mm
)
+
");
\n
"
)
if
mm
==
1
:
csg
.
write
(
"}
\n
"
)
...
...
@@ -126,7 +125,6 @@ def process_object(csg,ob):
elif
ob
.
Type
==
"Part::Cone"
:
print
"cone : Height "
+
str
(
ob
.
Height
)
+
" Radius1 "
+
str
(
ob
.
Radius1
)
+
" Radius2 "
+
str
(
ob
.
Radius2
)
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
)
+
\
", r2 = "
+
str
(
ob
.
Radius2
)
+
", center = "
+
center
(
mm
)
+
");
\n
"
)
if
mm
==
1
:
csg
.
write
(
"}
\n
"
)
...
...
@@ -137,7 +135,6 @@ def process_object(csg,ob):
print
ob
.
Radius2
if
ob
.
Angle3
==
360.00
:
mm
=
check_multmatrix
(
csg
,
ob
,
0
,
0
,
0
)
global
fafs
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
(
"circle($fn = 0, "
+
fafs
+
", r = "
+
str
(
ob
.
Radius2
)
+
");
\n
"
)
...
...
@@ -150,7 +147,7 @@ def process_object(csg,ob):
print
ob
.
Base
print
ob
.
Base
.
Name
#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
)
r
=
str
(
ob
.
Base
.
Radius
)
h
=
str
(
ob
.
Dir
[
2
])
...
...
@@ -158,34 +155,30 @@ def process_object(csg,ob):
print
"Radius : "
+
r
print
"Height : "
+
h
mm
=
check_multmatrix
(
csg
,
ob
,
0
,
0
,
-
float
(
h
)
/
2
)
global
fafs
csg
.
write
(
"cylinder($fn = "
+
f
+
", "
+
fafs
+
", h = "
+
h
+
", r1 = "
+
r
+
\
", r2 = "
+
r
+
", center = "
+
center
(
mm
)
+
");
\n
"
)
if
mm
==
1
:
csg
.
write
(
"}
\n
"
)
elif
ob
.
Base
.
Name
==
"circle"
:
elif
ob
.
Base
.
Name
.
startswith
(
"circle"
)
:
r
=
str
(
ob
.
Base
.
Radius
)
h
=
str
(
ob
.
Dir
[
2
])
print
"Radius : "
+
r
print
"Height : "
+
h
mm
=
check_multmatrix
(
csg
,
ob
,
0
,
0
,
-
float
(
h
)
/
2
)
global
fafs
csg
.
write
(
"cylinder($fn = 0, "
+
fafs
+
", h = "
+
h
+
", r1 = "
+
r
+
\
", r2 = "
+
r
+
", center = "
+
center
(
mm
)
+
");
\n
"
)
if
mm
==
1
:
csg
.
write
(
"}
\n
"
)
elif
ob
.
Base
.
Name
==
"Wire"
:
elif
ob
.
Base
.
Name
.
startswith
(
"Wire"
)
:
print
"Wire extrusion"
print
ob
.
Base
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
(
vertexs2polygon
(
ob
.
Base
.
Shape
.
Vertexes
))
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
)
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
(
"square (size = ["
+
str
(
ob
.
Base
.
Length
)
+
", "
+
str
(
ob
.
Base
.
Width
)
+
"],center = "
+
center
(
mm
)
+
";
\n
}
\n
"
)
if
mm
==
1
:
csg
.
write
(
"}
\n
"
)
...
...
src/Mod/OpenSCAD/importCSG.py
View file @
0d368938
...
...
@@ -61,6 +61,7 @@ from tokrules import tokens
dxfcache
=
{}
def
translate
(
context
,
text
):
"convenience function for Qt translator"
from
PyQt4
import
QtGui
return
QtGui
.
QApplication
.
translate
(
context
,
text
,
None
,
\
QtGui
.
QApplication
.
UnicodeUTF8
)
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment