Skip to content

Commit 3f53d5b

Browse files
finished pruning autopep8 changes to my mercurial satisfaction
1 parent 818d13a commit 3f53d5b

File tree

7 files changed

+148
-135
lines changed

7 files changed

+148
-135
lines changed

solid/examples/animation_example.py

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,33 @@
11
#! /usr/bin/env python
22
# -*- coding: UTF-8 -*-
33
from __future__ import division
4-
import os, sys, re
4+
import os
5+
import sys
6+
import re
57

68
from solid import *
79
from solid.utils import *
810

11+
912
def my_animate(_time=0):
1013
# _time will range from 0 to 1, not including 1
1114
rads = _time * 2 * 3.1416
1215
rad = 15
13-
c = translate( [rad*cos(rads), rad*sin(rads)])(square(10))
14-
16+
c = translate([rad * cos(rads), rad * sin(rads)])(square(10))
17+
1518
return c
1619

1720
if __name__ == '__main__':
1821
out_dir = sys.argv[1] if len(sys.argv) > 1 else os.curdir
1922
file_out = os.path.join(out_dir, 'animation_example.scad')
20-
21-
print("%(__file__)s: SCAD file written to: \n%(file_out)s"%vars())
22-
23-
# To animate in OpenSCAD:
23+
24+
print("%(__file__)s: SCAD file written to: \n%(file_out)s" % vars())
25+
26+
# To animate in OpenSCAD:
2427
# - Run this program to generate a SCAD file.
2528
# - Open the generated SCAD file in OpenSCAD
26-
# - Choose "View -> Animate"
27-
# - Enter FPS (frames per second) and Steps in the fields
29+
# - Choose "View -> Animate"
30+
# - Enter FPS (frames per second) and Steps in the fields
2831
# at the bottom of the OpenSCAD window
2932
# - FPS & Steps are flexible. For a start, set both to 20
3033
# play around from there
Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,29 @@
11
#! /usr/bin/env python
22
# -*- coding: UTF-8 -*-
3-
import os, sys
3+
import os
4+
import sys
45

56
from solid import *
67
from solid.utils import *
78

89
SEGMENTS = 48
910

11+
1012
def show_appended_python_code():
1113
a = cylinder(r=10, h=10, center=True) + up(5)(cylinder(r1=10, r2=0, h=10))
12-
14+
1315
return a
1416

15-
if __name__ == '__main__':
17+
if __name__ == '__main__':
1618
out_dir = sys.argv[1] if len(sys.argv) > 1 else os.curdir
1719
file_out = os.path.join(out_dir, 'append_solidpython_code.scad')
18-
20+
1921
a = show_appended_python_code()
20-
21-
print("%(__file__)s: SCAD file written to: \n%(file_out)s"%vars())
22+
23+
print("%(__file__)s: SCAD file written to: \n%(file_out)s" % vars())
2224
# ================================================================
2325
# = include_orig_code appends all python code as comments to the
2426
# = bottom of the generated OpenSCAD code, so the final document
2527
# = contains the easy-to-read python code as well as the SCAD.
26-
# = ------------------------------------------------------------ =
27-
scad_render_to_file(a, file_out, include_orig_code=True)
28-
28+
# = ------------------------------------------------------------ =
29+
scad_render_to_file(a, file_out, include_orig_code=True)

solid/examples/basic_geometry.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,22 @@
11
#! /usr/bin/env python
22
# -*- coding: UTF-8 -*-
33
from __future__ import division
4-
import os, sys, re
4+
import os
5+
import sys
6+
import re
57

68
from solid import *
79
from solid.utils import *
810

911
SEGMENTS = 48
1012

13+
1114
def basic_geometry():
12-
# SolidPython code can look a lot like OpenSCAD code. It also has
15+
# SolidPython code can look a lot like OpenSCAD code. It also has
1316
# some syntactic sugar built in that can make it look more pythonic.
1417
# Here are two identical pieces of geometry, one left and one right.
15-
16-
# left_piece uses standard OpenSCAD grammar (note the commas between
18+
19+
# left_piece uses standard OpenSCAD grammar (note the commas between
1720
# block elements; OpenSCAD doesn't require this)
1821
left_piece = union()(
1922
translate([-15, 0, 0])(
@@ -32,21 +35,21 @@ def basic_geometry():
3235
# solid.utils also defines up(), down(), left(), right(), forward(), and back()
3336
# for common transforms.
3437
right_piece = right(15)(cube([10, 5, 3], center=True))
35-
cyl = cylinder(r=5, h=15, center=True) - cylinder(r=4, h=16, center=True)
38+
cyl = cylinder(r=5, h=15, center=True) - cylinder(r=4, h=16, center=True)
3639
right_piece += right(10)(cyl)
37-
40+
3841
return union()(left_piece, right_piece)
3942

40-
if __name__ == '__main__':
43+
if __name__ == '__main__':
4144
out_dir = sys.argv[1] if len(sys.argv) > 1 else os.curdir
4245
file_out = os.path.join(out_dir, 'basic_geometry.scad')
43-
46+
4447
a = basic_geometry()
45-
46-
print("%(__file__)s: SCAD file written to: \n%(file_out)s"%vars())
47-
48+
49+
print("%(__file__)s: SCAD file written to: \n%(file_out)s" % vars())
50+
4851
# Adding the file_header argument as shown allows you to change
49-
# the detail of arcs by changing the SEGMENTS variable. This can
52+
# the detail of arcs by changing the SEGMENTS variable. This can
5053
# be expensive when making lots of small curves, but is otherwise
5154
# useful.
52-
scad_render_to_file(a, file_out, file_header='$fn = %s;'%SEGMENTS)
55+
scad_render_to_file(a, file_out, file_header='$fn = %s;' % SEGMENTS)
Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
11
#! /usr/bin/env python
22
# -*- coding: utf-8 -*-
3-
import sys, os
3+
import sys
4+
import os
45

56
from solid import *
67

78
# Import OpenSCAD code and call it from Python code.
8-
# The path given to use() (or include()) must be absolute or findable in sys.path
9+
# The path given to use() (or include()) must be absolute or findable in
10+
# sys.path
11+
12+
913
def demo_scad_include():
1014
# scad_to_include.scad includes a module called steps()
1115
scad_path = os.path.join(os.path.dirname(__file__), "scad_to_include.scad")
12-
use(scad_path) # could also use 'include', but that has side-effects;
13-
# 'use' just imports without executing any of the imported code
16+
use(scad_path) # could also use 'include', but that has side-effects;
17+
# 'use' just imports without executing any of the imported code
1418
return steps(5)
1519

1620

17-
if __name__ == '__main__':
21+
if __name__ == '__main__':
1822
out_dir = sys.argv[1] if len(sys.argv) > 1 else os.curdir
1923
file_out = os.path.join(out_dir, 'scad_include_example.scad')
20-
24+
2125
a = demo_scad_include()
22-
23-
print("%(__file__)s: SCAD file written to: \n%(file_out)s"%vars())
24-
25-
scad_render_to_file(a, file_out)
26+
27+
print("%(__file__)s: SCAD file written to: \n%(file_out)s" % vars())
28+
29+
scad_render_to_file(a, file_out)

solid/examples/bom_scad.py

Lines changed: 50 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
#! /usr/bin/env python
22
# -*- coding: utf-8 -*-
33

4-
# Basic shape with several repeated parts, demonstrating the use of
5-
# solid.utils.bill_of_materials()
4+
# Basic shape with several repeated parts, demonstrating the use of
5+
# solid.utils.bill_of_materials()
66
#
7-
# Basically:
7+
# Basically:
88
# -- Define every part you want in the Bill of Materials in a function
99
# -- Use the 'bom_part' decorator ahead of the definition of each part's function
10-
# e.g.:
11-
# @bom_part()
12-
# def my_part():
13-
# pass
14-
# -- Optionally, you can add a description and a per-unit cost to the
15-
# decorator invocations.
10+
# e.g.:
11+
# @bom_part()
12+
# def my_part():
13+
# pass
14+
# -- Optionally, you can add a description and a per-unit cost to the
15+
# decorator invocations.
1616
#
1717
# -- To generate the bill of materials, call solid.utils.bill_of_materials()
1818
#
1919
# -ETJ 08 Mar 2011
2020

21-
import os, sys
21+
import os
22+
import sys
2223

2324
from solid import *
2425
from solid.utils import *
@@ -33,82 +34,83 @@
3334

3435
doohickey_h = 5
3536

37+
3638
def head():
37-
return cylinder(h=head_height, r =head_rad)
39+
return cylinder(h=head_height, r=head_rad)
3840

3941

4042
@bom_part("M3x16 Bolt", 0.12, currency="€")
4143
def m3_16(a=3):
4244
bolt_height = 16
4345
m = union()(
44-
head(),
45-
translate( [0,0, -bolt_height])(
46-
cylinder(r=m3_rad, h=bolt_height)
47-
)
46+
head(),
47+
translate([0, 0, -bolt_height])(
48+
cylinder(r=m3_rad, h=bolt_height)
4849
)
50+
)
4951
return m
5052

5153

5254
@bom_part("M3x12 Bolt", 0.09)
5355
def m3_12():
5456
bolt_height = 12
5557
m = union()(
56-
head(),
57-
translate( [ 0, 0, -bolt_height])(
58-
cylinder(r=m3_rad, h=bolt_height)
59-
)
58+
head(),
59+
translate([0, 0, -bolt_height])(
60+
cylinder(r=m3_rad, h=bolt_height)
6061
)
62+
)
6163
return m
6264

6365

6466
@bom_part("M3 Nut", 0.04, currency="R$")
6567
def m3_nut():
6668
hx = cylinder(r=nut_rad, h=nut_height)
67-
hx.add_param('$fn', 6) # make the nut hexagonal
69+
hx.add_param('$fn', 6) # make the nut hexagonal
6870
n = difference()(
69-
hx,
70-
translate([0,0,-EPSILON])(
71-
cylinder(r=m3_rad, h=nut_height+2*EPSILON )
72-
)
71+
hx,
72+
translate([0, 0, -EPSILON])(
73+
cylinder(r=m3_rad, h=nut_height + 2 * EPSILON)
7374
)
75+
)
7476
return n
7577

7678

7779
@bom_part()
7880
def doohickey():
79-
hole_cyl = translate([0,0,-EPSILON])(
80-
cylinder(r=m3_rad, h=doohickey_h+2*EPSILON )
81-
)
81+
hole_cyl = translate([0, 0, -EPSILON])(
82+
cylinder(r=m3_rad, h=doohickey_h + 2 * EPSILON)
83+
)
8284
d = difference()(
83-
cube([30, 10, doohickey_h], center=True),
84-
translate([-10, 0,0])(hole_cyl),
85-
hole_cyl,
86-
translate([10,0,0])(hole_cyl)
87-
)
85+
cube([30, 10, doohickey_h], center=True),
86+
translate([-10, 0, 0])(hole_cyl),
87+
hole_cyl,
88+
translate([10, 0, 0])(hole_cyl)
89+
)
8890
return d
8991

9092

9193
def assemble():
9294
return union()(
93-
doohickey(),
94-
translate( [-10, 0, doohickey_h/2])( m3_12()),
95-
translate( [ 0, 0, doohickey_h/2])( m3_16()),
96-
translate( [10, 0, doohickey_h/2])( m3_12()),
97-
# Nuts
98-
translate( [-10, 0, -nut_height-doohickey_h/2])( m3_nut()),
99-
translate( [ 0, 0, -nut_height-doohickey_h/2])( m3_nut()),
100-
translate( [10, 0, -nut_height-doohickey_h/2])( m3_nut()),
101-
)
102-
103-
if __name__ == '__main__':
95+
doohickey(),
96+
translate([-10, 0, doohickey_h / 2])(m3_12()),
97+
translate([ 0, 0, doohickey_h / 2])(m3_16()),
98+
translate([ 10, 0, doohickey_h / 2])(m3_12()),
99+
# Nuts
100+
translate([-10, 0, -nut_height - doohickey_h / 2])(m3_nut()),
101+
translate([ 0, 0, -nut_height - doohickey_h / 2])(m3_nut()),
102+
translate([ 10, 0, -nut_height - doohickey_h / 2])(m3_nut()),
103+
)
104+
105+
if __name__ == '__main__':
104106
out_dir = sys.argv[1] if len(sys.argv) > 1 else os.curdir
105107
file_out = os.path.join(out_dir, 'BOM_example.scad')
106-
108+
107109
a = assemble()
108-
110+
109111
bom = bill_of_materials()
110-
111-
print("%(__file__)s: SCAD file written to: \n%(file_out)s"%vars())
112+
113+
print("%(__file__)s: SCAD file written to: \n%(file_out)s" % vars())
112114
print(bom)
113-
115+
114116
scad_render_to_file(a, file_out)

0 commit comments

Comments
 (0)