forked from tazjel/declaracad
-
Notifications
You must be signed in to change notification settings - Fork 0
/
operations.enaml
59 lines (52 loc) · 1.34 KB
/
operations.enaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import traceback
from declaracad.occ.api import (
Box, Cone, Cylinder, Sphere, Part,
Cut, Common, Fillet, ThickSolid, Chamfer
)
from OCC.BRep import BRep_Tool
from OCC._Geom import Handle_Geom_Plane_DownCast
def top_face(f):
""" Ugly way to sort faces..."""
s = BRep_Tool.Surface(f)
try:
p = Handle_Geom_Plane_DownCast(s).GetObject()
return -p.Location().Z()
except:
traceback.print_exc()
return 0
enamldef Assembly(Part):
name = "Shape Operations"
Cut:
Box: box1:
position = (-1/2.0, -1/2.0, 0)
dx = 1
dy = 1
dz = 1
Cylinder:
#position := box1.position
radius = 1/2.0
height = 1
Common:
Cylinder:
position = (4,4,0)
height = 4
Sphere:
position = (4,4,0)
radius = 2
Fillet:
radius = 0.1
Box:
position = (-4,-4,0)
dx = 2
dy = 2
dz = 2
Chamfer:
distance = 0.1
Cylinder:
position = (-4,4,0)
radius = 2
ThickSolid:
offset = 0.1
Box: box1:
position = (4,-4,0)
closing_faces << [sorted(box1.shape_faces,key=top_face)[0]] # Get top face