Open marcus7070 opened 4 years ago
^ GitHub is being silly, that's not this issue.
An idea:
Store a "feature" in an attribute of the CQ
object every time a solid is created. Selectors can operate on a "feature" instead of the context solid.
part = (
cq.Workplane("XY")
.box(5, 5, 5)
.box(1, 1, 10).tag("foo")
.sphere(5)
.faces(">X", tag="foo", feature=True)
)
^ will return the face of the tall thin box. feature=False
would return the face of the first cube. Omitting the tag would select nothing, because it's looking for faces on the sphere.
feature=True
could also be used without the tag
argument, which would search the parent chain for the nearest .feature
attribute, like how CQ already searches for the first solid to use and the context solid.
Rewrite all Boolean operators to include a call to CQ.create_feature()
. .create_feature()
takes a solid. For example, if the operation is a subtract then .create_feature()
should be called with the solid to subtract.
CQ-editor could use feature tree display, where highlighting an item in the feature tree shows CQ.feature
rather than CQ.objects
.
log_feature
might be a better name than create_feature
, since no solids are created during this call.
Could do some fancy CQ.__getattribute__
stuff to log each method called on a CQ object, so that calls could be associated with CQ
objects in the parent chain, or collected for features.
This would allow pretty icons next to each feature in the feature tree. Not too sure what else I could do with it.
At the occ_impl
layer, write a decorator that appends the returned object to occ_impl.feature
stack. At the fluent API level, CQ.newObject
pops the whole occ.impl.feature
stack and saves it.
I like storing the feature tree in CQ objects as part of the parent chain, because that enables garbage collection tied to the CQ object.
References
Taken from here:
Taken from cadquery/cadquery issue number 50 (not linking properly because I don't want to ping that issue with a link to this shitty draft):
Taken from cadquery/cadquery issue number 49: