-
Hi, from build123d import *
from ocp_vscode import *
with BuildPart() as ex1:
Cylinder(radius=10, height=3)
with BuildSketch(ex1.faces().sort_by(Axis.Z)[-1]):
RegularPolygon(radius=7, side_count=6)
Circle(radius=4, mode=Mode.SUBTRACT)
extrude(amount=-2, mode=Mode.SUBTRACT)
show(ex1) I can select the face I want the sketch to be added to by passing it in via the BuildSketch constructor. But lets say I want to define the sketch before the part from build123d import *
from ocp_vscode import *
with BuildSketch() as sketch1:
RegularPolygon(radius=7, side_count=6)
Circle(radius=4, mode=Mode.SUBTRACT)
with BuildPart() as ex1:
Cylinder(radius=10, height=3)
ex1.faces().sort_by(Axis.Z)[-1]
# How to specify the face to add it to here?
# ex1.faces().sort_by(Axis.Z)[-1]
add(sketch1)
extrude(amount=-2, mode=Mode.SUBTRACT)
show(ex1) How do I specify which face to add the sketch to without passing it into the BuildSketch constructor? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Ok I've just discovered this works, although maybe there's a better way from build123d import *
from ocp_vscode import *
with BuildSketch() as sketch1:
RegularPolygon(radius=7, side_count=6)
Circle(radius=4, mode=Mode.SUBTRACT)
with BuildPart() as ex1:
Cylinder(radius=10, height=3)
ex1.faces().sort_by(Axis.Z)[-1]
with BuildSketch(ex1.faces().sort_by(Axis.Z)[-1]) as sketch2:
add(sketch1)
extrude(amount=-2, mode=Mode.SUBTRACT)
show(ex1) |
Beta Was this translation helpful? Give feedback.
-
Use with BuildPart() as ex1:
Cylinder(radius=10, height=3)
with Locations(ex1.faces().sort_by(Axis.Z)[-1]):
add(sketch1)
extrude(amount=-2, mode=Mode.SUBTRACT) |
Beta Was this translation helpful? Give feedback.
-
right thanks |
Beta Was this translation helpful? Give feedback.
Use
Locations
,GridLocations
, etc. (see https://build123d.readthedocs.io/en/latest/key_concepts.html#locations-context) to position objects within Builders as follows: