How to reuse existing edge in combination with new geometry? #1688
-
Say I've got some solid with a complex shape, for example:
I want to use the outer edge combined with some other shape (say, a circle) and extrude that. In this example the outer edge is just a square and I can easily just draw it again:
But what if it's actually a complex shape and I really don't want to re-define it? I know how to select the outer edge, by finding the longest one:
but when I try to use that in place of the
If I remove the call to How do I reuse this existing edge in combination with other new geometry? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Here are a few ideas. You were close with (1).
# this matches the desired shape
myShape2 = (
box.faces(">Z")
.wires()
.sort(lambda wire: wire.Length() * -1)
.first()
.toPending()
.circle(4)
.extrude(0.5, combine=False)
)
import cadquery as cq
sk1 = cq.Sketch().rect(10, 10)
sk2 = sk1.copy().rarray(3, 3, 2, 2).circle(0.5, mode="s")
box1 = cq.Workplane().placeSketch(sk2).extrude(1)
# for comparison with myShape
desiredShape = box1.faces(">Z").rect(10, 10).circle(4).extrude(0.5, combine=False)
myShape = (
box1.faces(">Z")
.placeSketch(sk1.copy().circle(4, mode="s"))
.extrude(0.5, combine=False)
)
import cadquery as cq
from cadquery.occ_impl.shapes import *
# name the box as box1 so it does not conflict with box() func
box1 = (
cq.Workplane("XY")
.box(10, 10, 1)
.faces(">Z")
.rect(3, 3, forConstruction=True)
.vertices()
.hole(1)
)
# for comparison with myShape
desiredShape = box1.faces(">Z").rect(10, 10).circle(4).extrude(0.5, combine=False)
wire1 = box1.faces(">Z").wires().sort(lambda wire: wire.Length() * -1).first().val()
wire2 = box1.faces(">Z").circle(4).val() # new circle
face1 = face(wire1) - face(wire2) # new face for desired shape
myShape = extrude(face1, (0, 0, 0.5)) # the desired shape edit - remove issue link |
Beta Was this translation helpful? Give feedback.
Here are a few ideas. You were close with (1).