The DraftAngle
can be used to apply an angle to specific faces of a shape. Specify the angle
and faces
to perform the draft angle on. It will use the position
and direction
to define the neutral plane. If more control is needed, an operations
list can be provided with a face, direction, angle, and neutral plane for each face.
Like Fillet and Chamfer, the disabled
flag can be used to disable the operation for debugging.
# Created in DeclaraCAD
from math import radians
from declaracad.occ.api import *
from declaracad.parts.display import Axis
enamldef Assembly(Part):
Axis:
pass
DraftAngle:
transparency = 0.5
angle = radians(15)
position = (0, 0, box.dz)
faces = [self.children[0].topology.faces[0]]
Fillet:
radius = 1
operations = [
e for i, e in enumerate(box.topology.edges)
if i in (4, 6)
]
Box: box:
dx = 10
dy = 12
dz = 10
Note: The algorithm will select adjacent faces automatically when fillets are present.
Another example demonstrating how to easily add an angled pitch to walls using draft angle which may be of use for making molds or castings.
# Created in DeclaraCAD
from math import radians
from declaracad.occ.api import *
from declaracad.parts.display import Axis
enamldef Assembly(Part):
Axis:
pass
DraftAngle:
angle = radians(-10)
faces = self.children[0].topology.faces[0:4]
ThickSolid:
offset = -1
faces = [box.topology.faces[5]]
Box: box:
position = (-dx/2, -dy/2)
dx = 10
dy = 20
dz = 5
To specify multiple different angles use the operations
and include a DraftAngle.Parameters
instance in each item.
# Created in DeclaraCAD
from math import radians
from declaracad.occ.api import *
enamldef Assembly(Part):
Axis:
pass
attr thickness = 12
DraftAngle:
transparency = 0.5
operations = [
# Add a 10 degree angle to all except the top and bottom faces
DraftAngle.Parameters(
angle=radians(10),
face=self.children[0].topology.faces[i],
neutral_plane=(Point(0,0,box.dz), Direction(0, 0, 1))
)
for i in (0, 5, 6, 9)
] + [
# Add a 5 degree angle to the top face
DraftAngle.Parameters(
angle=radians(5),
face=self.children[0].topology.faces[1],
direction = Direction(0, 1, 0),
neutral_plane=(Point(box.dy,0,0), Direction(0, 1, 0))
)
]
Chamfer:
operations = [
(10, box.topology.edges[2]),
(10, box.topology.edges[6]),
(5, box.topology.edges[0]),
(5, box.topology.edges[4]),
]
Box: box:
position = (-dx/2, 0)
dx = 70 + 2*thickness
dy = 100
dz = 30