cadquery
cadquery copied to clipboard
Workplane() resets currently selected objects
The following code does not work
import cadquery as cq
result = cq.Workplane("XY").rect(10.0,10.0).extrude(10).faces("<Y")\
.workplane().vertices('<XZ').circle(1).extrude(10)
I think it should -- it is quite clear what the intent if the user is here. This is also related to #24
We agree that the expected behaviour would be equal to this :
import cadquery as cq
result = cq.Workplane("XY").rect(10.0,10.0).extrude(10).faces("<Y")\
.workplane().end(1).vertices('<XZ').circle(1).extrude(10)
I have been bothered several time by this and while the end
method solves the problem, it's super unnatural and definitely not novice friendly.
If this is still expected to be solved I will try to bring a PR
EDIT : Looking at the source code for workplane
since it expects faces or wires on the stack shouldn't we just pass the objects of the parent obj to the child ?
# make the new workplane
plane = Plane(offsetCenter, xDir, normal)
s = self.__class__(plane)
s.parent = self
s.objects = self.objects # we would just add this ?
s.ctx = self.ctx
Of course I need to make sure it doesn't make the tests fail but it seems it would be what's expected ?
I think, that's it indeed.
Or maybe:
s.objects = self.objects[:]
I have tried my solution, it breaks some tests, I have quickly looked, some tests could be rewritten, some need a bit more investigation why they break.
Feel free to open a WIP PR and we can take a look together.