Chamfering a single vertex?

174 views
Skip to first unread message

Alasdair McAndrew

unread,
Dec 3, 2020, 7:44:08 PM12/3/20
to CadQuery
This would appear to be a simple task: chopping off a single vertex.   But I can't see how to make it work.

For example

    cq.Workplane("front").box(10,10,10).edges(">X and >Y").chamfer(5)

chamfers the upper xz edge.  But

    cq.Workplane("front").box(10,10,10).edges(">X and >Y and >Z").chamfer(5)  

returns an error.  Maybe chamfer doesn't work on individual vertices - in which case what method should I be using?

I know I can slice through my cube with an appropriate plane and choose one side of that cut, but chamfering seems conceptually easier.  Anyway, if it can be done I'd be delighted to be told how - or pointed towards the correct place in the docs (which I've been hunting through with no success so far).

Thanks,
Alasdair

Jeremy Wright

unread,
Dec 3, 2020, 8:52:32 PM12/3/20
to CadQuery
You can use vertices() with a selector to get a vertex(ices), but chamfer will give you an error if you're not calling it on an edge(s).

cq.Workplane("front").box(10,10,10).faces(">X").edges(">Y").vertices().chamfer(5)

Results in: "ValueError: Chamfer requires that edges be selected"

Alasdair McAndrew

unread,
Dec 3, 2020, 10:52:13 PM12/3/20
to CadQuery
Thank you very much.  Well, this seems to work:

box1 = cq.Workplane("front").box(10,10,10)
box1 = box1.workplane().transformed(offset=(10,10,10),rotate=(45,35,0)).split(keepBottom=True)

but it's a pain.  And I'm not quite sure how best to set a (work)plane with specified normal and origin.  Say if I wanted to cut my box by the plane given as x - y + z =10.  

Jeremy Wright

unread,
Dec 4, 2020, 11:53:45 AM12/4/20
to CadQuery

You can pass a Plane object to a Workplane (capital W) and specify the "origin" and "normal".

cq.Workplane(cq.Plane(origin=(0,0,0), xDir=(1,0,0), normal=(0,0,1)))

Unfortunately, workplane (lower case w) doesn't accept the "normal" argument. This gets you close, but is still clunky.

import cadquery as cq

result = (cq.Workplane().box(10, 10, 10)
            .faces(">Z").edges(">Y").vertices(">X").first()
            .workplane(offset=-2.0).transformed(rotate=(-45, 45, 0)).rect(10, 10).cutBlind(5))

If you plan to use this feature a lot, you could encapsulate the logic in a plugin.

Alasdair McAndrew

unread,
Dec 4, 2020, 10:58:42 PM12/4/20
to CadQuery
Thanks again!

I could probably write a tiny script: basically to find angles s and t so that  a plane can be expressed as

x.cos(s).sin(t) + y.sin(s).sin(t) + z.cos(t) = r

Then s and t give the angles needed to point the normal in the correct direction.  That is why my angles were 45 = arctan(1)  and 35.26 = arctan(1/sqrt(2)).  The only slight concern would be to ensure that the angles are those used  by the system - there are a few different conventions on their definitions.

Reply all
Reply to author
Forward
0 new messages