forked from SolidCode/SolidPython
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added ImplicitCAD support (SolidCode#134)
- Loading branch information
Showing
6 changed files
with
116 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
module sphere(r=default, d=default, $fn=default); | ||
module cube(size=default, center=default, r=default); | ||
module square(size=default, center=default, r=default); | ||
module cylinder(r=default, h=default, r1=default, r2=default, | ||
$fn=default, center=default); | ||
module circle(r=default, $fn=default); | ||
module polygon(points, paths=default, r=default); | ||
|
||
module union(r=default); | ||
module difference(r=default); | ||
module intersection(r=default); | ||
|
||
module translate(v); | ||
module scale(v); | ||
module rotate(a=default, v=default); | ||
|
||
module linear_extrude(height=default, | ||
center=default, | ||
twist=default, | ||
scale=default, | ||
translate=default, | ||
r=default); | ||
|
||
module pack(size, sep=default); | ||
module shell(w); | ||
|
||
module rotate_extrude(angle=default, | ||
r=default, | ||
translate=default, | ||
rotate=default); | ||
|
||
module unit(unit); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# ====================================================== | ||
# = add relative path to the solid package to sys.path = | ||
# ====================================================== | ||
import sys | ||
from pathlib import Path | ||
solidPath = Path(__file__).absolute().parent.parent.parent.as_posix() | ||
sys.path.append(solidPath) | ||
#================================================== | ||
|
||
# run extopenscad with -r 2 to get proper results: | ||
# extopenscad -r 2 examples/14-implicitCAD.scad | ||
|
||
# this is the same example as 06-functions.py but with nice smooth implicitCAD | ||
# roundings.... | ||
|
||
# this is how you activate the "implicit mode" of ExpSolid | ||
# I couldn't figure out a nicer way to set a parameter which can be accessed | ||
# during the import routine of exp_solid | ||
# | ||
# alternatively you can call the whole script with the --implicit parameter: | ||
# python3 examples/14-implicitCAD.py --implicit | ||
|
||
import sys | ||
sys.argv.append("--implicit") | ||
|
||
from solid import * | ||
|
||
def wheel(): | ||
return cylinder(r=35, h=15, center=True).rotate(0, 90, 0) | ||
|
||
def axle(): | ||
a = cylinder(r=10, h=130, center=True).\ | ||
rotate(0, 90, 0) | ||
|
||
w1 = wheel().left(67) | ||
w2 = wheel().right(67) | ||
|
||
return w1 + w2 + a | ||
|
||
def torso(): | ||
bottom = cube(100, 250, 50, center=True, r=10) | ||
top = cube(80, 100, 60, center=True, r=10) | ||
|
||
window_cube = cube(200, 55 ,50, center=True, r=10).down(10) | ||
top = difference(r=10) ( | ||
top, | ||
(union(r=10) (window_cube, window_cube.rotate(0, 0, 90))) | ||
) | ||
|
||
return union(r=10)(bottom, top.up(50)) | ||
|
||
def car(): | ||
t = torso() | ||
|
||
front_axle = axle().down(20).back(80) | ||
|
||
rear_axle = front_axle.forward(160) | ||
|
||
return union(r=3)(t, front_axle, rear_axle) | ||
|
||
car().save_as_scad() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters