Edge selector help, please

25 views
Skip to first unread message

neri-engineering

unread,
Oct 30, 2024, 5:38:58 AM10/30/24
to CadQuery
I am requesting help with the built-in edge selectors.  I think I know how to do this by defining my own edge selector function (I've done it before, thanks to PR 1514 made by Lorenz I believe?).  However I'd like to avoid extra complexity in my code; I would like to use some of the built-in edge selector capabilities advertised here: https://cadquery.readthedocs.io/en/latest/classreference.html#cadquery.StringSyntaxSelector

However in my previous attempts to combine "and", "not", "or", and "and", I failed miserably.  I was only ever able to get the simplest type of edge selector to work.  Perhaps my CadQuery is out of date?  But I reinstalled it just a couple of months ago.

Let's nail my question down more concretely.  I have a specific code snippet like so:


import cadquery
def mating_polyhedron():
    n_faces = 6
    mm_enclosing_diameter = 5.0
    base = cadquery.Workplane("YZ")
    base = base.polygon(nSides= n_faces, diameter= mm_enclosing_diameter,
                        circumscribed= False)
    base = base.extrude(until= 6.0, taper= 10.0)
    fillet_r = 0.5
    edge_selector = ""
    base = base.edges(edge_selector).fillet(fillet_r)
    return base
show_object(mating_polyhedron())


... which you can save and run as-is.  The code above would generate a solid that looks like so:

polyhedron.png


However I would like to modify the value of 'edge_selector' such that only the "oblique" edges are selected.  More specifically, I want to select ALL EDGES WHICH HAVE A DELTA X IN THEIR ENDPOINTS.  I WANT ALL EDGES NOT LYING ON A PLANE WHICH IS PARALLEL TO THE YZ PLANE.  I have just spelled it out, but using symbols such as '|', '#', 'YZ', etc., after some amount of frustration and testing I was not able to bear fruit.  Again, I want to keep the code concise by using the built-in edge selector, instead of writing my own selector function.  Up until now I have struggled immensely with this selector syntax, only ever able to get only the simplest types of examples to work, and having to work around my lack of ability in this subject matter.


That aside, here is something completely unrelated.  It's not a question.  It's just some eye candy.


eyelet.png

I was able to get the fillets to line up with some tricky math.  By avoiding mathematical landmines I was able to determine the fillet radii to line up, by solving quadratic formulas.  Had I not avoided these mathematical landmines I would have had to solve quartic equations, I think.  It goes without saying that I find CadQuery to be extremely useful and powerful, esp. for defining systems of parts where a distance on one part affects the distance on another part, and where many distances and offsets are computed as functions which depend on other values, some of those values being "leaf nodes" and others being outputs of functions themselves.  This programmatic, parameterized way of defining systems of parts is much superior.


Sent with Proton Mail secure email.

Lorenz

unread,
Oct 30, 2024, 10:55:39 PM10/30/24
to CadQuery
If I understand correctly, you are looking for:

    edge_selector = "not(#X)"

This filters out edges perpendicular to X.

PR 1514 introduced the filter method and additional special methods.  It was the work of voneiden and AU.

Nice progress on the other design.

neri-engineering

unread,
Oct 31, 2024, 3:50:54 AM10/31/24
to Lorenz, CadQuery
Indeed that solved my problem.  Thanks for the reply.

Sent with Proton Mail secure email.

--
cadquery home: https://github.com/CadQuery/cadquery
post issues at https://github.com/CadQuery/cadquery/issues
run it at home at : https://github.com/CadQuery/CQ-editor
---
You received this message because you are subscribed to the Google Groups "CadQuery" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cadquery+u...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/cadquery/ca109f9a-8a4e-43f4-94c9-10545390fa22n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages