-
Notifications
You must be signed in to change notification settings - Fork 300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added AreaNthSelector #688
Conversation
Added AreaNthSelector that is useful for nested features selection. Especially to select one of coplanar nested wires for subsequent extrusion, cutting or filleting.
Unit tests for Solids and Shells are a bit contrived. Is there a way to get more than one Solid or Shell to select from while using Workplane? Or maybe using this selector for Solids and Shells makes no sense and support for them should be removed? |
Codecov Report
@@ Coverage Diff @@
## master #688 +/- ##
==========================================
+ Coverage 94.33% 94.41% +0.08%
==========================================
Files 31 31
Lines 6810 6909 +99
Branches 732 740 +8
==========================================
+ Hits 6424 6523 +99
Misses 252 252
Partials 134 134
Continue to review full report at Codecov.
|
Black is complaining about formatting. IMHO it makes the code less readable by merging long sequences of fluent API calls that I format as one call per line into long lines with too many calls. But if that is the accepted formatting style of the project I will implement black's recommendations |
Yes please @fedorkotov. I know black isn't perfect, but it's much easier to read one consistent style. |
Two questions
Or is it better to keep things separated and both of these additional features should have their separate pull requests? |
I was thinking the same thing so I actually did #646 earlier today, thinking that the process would help me review this PR. I just put up the code as #690.
In this case I think we should do another PR, because we can roll area, length and radius selectors into one review. |
Ok. I will include LengthNthSelector into my pull request.
Ok. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.rect(20, 20) | ||
.extrude(10) # solid 20x20x10 box |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Usually I would insist these lines be changed to .box(20, 20, 10, centered=(True, True, False))
but this hangs the kernel in the final cutBlind
step, and I can't work around it either! So it will have to stay as this rect
version until that bug is fixed. No change required here, this is just a comment.
Something like shell = (
cq.Workplane()
.box(1, 1, 1)
.faces(">Z")
.shell(0.1)
.val()
)
workplane_shells = (
cq.Workplane()
.rarray(2, 2, 3, 4)
.eachpoint(lambda loc: shell.located(loc))
) edit: the above code produces a Workplane with 12 solids, not shells, which was a confusing example for me to choose, sorry. You can also union different sized shells/solids, which would give you more variety to test an area selector on.
Solids and shells have clearly defined areas, so I support this selector working on them. |
If you check https://raw.githubusercontent.com/CadQuery/cadquery/master/doc/classreference.rst you'll see where we need to add |
- Switched Shape.ShapeType() to isinstance to determine what kind of Shape was passed into _NthSelector.key(..) implementation in AreaNthSelector for consistency with other selectors based on _NthSelector - Added LengthNthSelector developed by @marcus7070 in CadQuery#690 with somewhat modified unit tests - Added new selector references to documentation - Black compatible code examples in AreaNthSelector docstring - Explicitly marked _NthSelector class and _NthSelector.key(..) method as abstract using standard abc package
Can't figure out what caused Windows pipelines to fail. Don't have access to Windows machine right now. The log says
But which module and which dll? And why? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think all our Windows CI are failing, it's not due to your code. Once we get that fixed and can see all the tests pass I think this looks good to merge.
Thanks for doing this @fedorkotov, there is a lot of work here especially the tests.
AreaNthSelector.key raises ValueError if temporary face creation fails for a wire for any reason (non-planar, non-closed). That causes _NthSelector that it inherits to ignore such wires. Done so for consistency with RadiusNthSelector that ignores anything it can not get radius from.
Forgot to check for non-planar or non-closed wires. Fixed. |
@fedorkotov I propose to leave the catch as-is for now. Thanks for all the hard work! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch with that non-planar wire test.
Thanks @fedorkotov! |
Added AreaNthSelector that is useful for nested features selection. Especially to select one of coplanar nested wires for subsequent extrusion, cutting or filleting.
This selector was developed as a result of discussion in #684