Closed timacro closed 2 months ago
solved:
to_extrude
must be explicitly specified when invoking extrude
.
from build123d import *
from ocp_vscode import *
show_clear()
class BlockA(BasePartObject):
def __init__(self):
with BuildPart() as bp:
Box(20,20,10)
super().__init__(part=bp.part)
self.bp = bp
class BlockB(BlockA):
def __init__(self):
super().__init__()
with self.bp:
with BuildSketch(self.faces() >> Axis.Z) as sk:
Circle(5)
extrude(to_extrude=sk.sketch, amount=10)
BasePartObject.__init__(self, part=self.bp.part)
show(BlockB())
But don't know why Implicit Builder Instance Variable
fails here.
You're trying to re-use a BuildPart
instance created in BlockA
in BlockB
which is not supported. However, the Part
from BlockA
can be added to BlockB
like this:
class BlockB(BlockA):
def __init__(self):
super().__init__()
print(f"{self.bp=}")
with BuildPart() as blockb_builder:
add(self.bp.part)
with BuildSketch(blockb_builder.faces() >> Axis.Z):
Circle(5)
extrude(amount=10)
BasePartObject.__init__(self, part=blockb_builder.part)
There is an open Issue to add this functionality to a Builder: https://github.com/gumyr/build123d/issues/108
@gumyr Thanks! #108 is really helpful to me!
Hi,
I try to define a BlockA by inheriting BasePartObject, and then define BlockB by inheriting from BlockA, in order to continuing to build parts in BlockB, but I encounter the following error:
It seems
BuildSketch
doesn't pending a face created byCircle(5)
into a sketch, have no idea about that.Here is my code: