Ich versuche, ein CAD-Modell eines Bolzens zu erstellen, aber ich kann nicht herausfinden, wie ich die Spitze der Ecken oben am Kopf in einem 45-Grad-Winkel abschneiden kann. Dies: < /p>
import cadquery as cq
from math import sqrt, tan, radians
head_diameter = 10.0
head_height = 5.0
shaft_diameter = 5.0
shaft_length = 20.0
R = head_diameter / 2
r = R * sqrt(3)/2
chamfer_size = (R - r) / tan(45)
bolt_head = (
cq.Workplane("XY")
.polygon(6, 2*R)
.extrude(head_height)
.translate((0, 0, -1 * (head_height/2)))
)
bolt_head = bolt_head.edges("Z").chamfer(1)
bolt_shaft = (
cq.Workplane("XY")
.circle(shaft_diameter/2)
.extrude(-shaft_length)
)
bolt = bolt_head.union(bolt_shaft)
< /code>
Dieser Code generiert den folgenden CAD:
Bildbeschreibung hier eingeben < /p>
Dann: < /p>
import cadquery as cq
from math import sqrt, tan, radians
HEAD_DIAMETER = 20.0
HEAD_HEIGHT = 10.0
CUT_ANGLE = 45.0
SHAFT_DIAMETER = 8.0
SHAFT_LENGTH = 30.0
R = HEAD_DIAMETER / 2
r = R * sqrt(3)/2
cut_depth = (R - r) / tan(radians(CUT_ANGLE))
hexagon = (
cq.Workplane("XY")
.polygon(6, HEAD_DIAMETER)
.extrude(HEAD_HEIGHT + cut_depth)
)
cutter = (
cq.Workplane("XY")
.workplane(offset=HEAD_HEIGHT)
.circle(r)
.workplane(offset=cut_depth)
.circle(R * 1.1)
.loft(combine=True)
)
result = hexagon.cut(cutter)
result = (
result.faces(">Z")
.workplane(centerOption="CenterOfMass")
.circle(r)
.cutBlind(-cut_depth)
)
show_object(result)
< /code>
, aber es gibt einen Fehler aus: < /p>
ValueError: If multiple objects selected, they all must be planar faces.
< /code>
Dieser Code generiert den folgenden CAD:
Bildbeschreibung Eingabetaste hier < /p>
Weiß jemand>
Ich versuche, einen Bolzen in Cadquery Python zu modellieren ⇐ Python
-
- Similar Topics
- Replies
- Views
- Last post