cadquery icon indicating copy to clipboard operation
cadquery copied to clipboard

Asymmetric Chamfer Error

Open gumyr opened this issue 3 years ago • 6 comments

Asymmetric chamfer is not applied consistently. The chamfers on the top of this ring look correct; however, the inner chamfer on the bottom is reversed. chamferBug

Error found on cadquery master.

import cadquery as cq

chamferBody = (
    cq.Workplane("XY")
    .circle(8)
    .circle(4)
    .extrude(4)
    .faces(">Z").chamfer(0.5,1.5)
    .faces("<Z").chamfer(0.5,1.5)
)
if "show_object" in locals():
    show_object(chamferBody,name="chamferBody")

gumyr avatar Jun 09 '21 17:06 gumyr

The order of the asymmetric chamfer is not well defined in general (I think that it depends on the orientation of the underlying wires).

adam-urbanczyk avatar Jun 09 '21 20:06 adam-urbanczyk

I wondered if the cause of this issue was due to the difference in direction of the circular wires of the top and bottom of the doughnut hole. Is there anyway to make the result more predictable?

gumyr avatar Jun 09 '21 22:06 gumyr

Not that I know at the moment.

adam-urbanczyk avatar Jun 10 '21 06:06 adam-urbanczyk

I think I encountered the same issue on other simple example.

    cq.Workplane()
    .box(10,10,10)
    .faces("<Z")
    .workplane()
    .rect(20,1)
    .cutThruAll()
    .faces("<Z")
    .chamfer(1.5,0.5)

chamfer_on_splitted_box

ksuszka avatar Mar 25 '23 21:03 ksuszka

One more example:

from cadquery import Workplane

for i, query in enumerate(["<X", ">X", "<Y", ">Y", "<Z", ">Z"]):
    result = Workplane(origin=(i*15.0,0,0)).box(10,10,10).faces(query).chamfer(2,1)
    show_object(result)

image

kolod avatar Apr 28 '24 14:04 kolod

I think the problem in edge normals.

from cadquery import Workplane
from typing import List, cast
from cadquery.occ_impl.shapes import Edge, Face

c1 = Workplane().box(10, 10, 10).faces("<Y")
print(cast(Face, c1.vals()[0]).normalAt())
for x in cast(List[Edge], c1.faces("<Y").edges().vals()):
    print(x.normal())
Vector: (-0.0, -1.0, -0.0) # Face
Vector: (-0.0, 1.0, 0.0)
Vector: (1.0, 0.0, -0.0)
Vector: (-0.0, 1.0, 0.0)
Vector: (1.0, 0.0, -0.0)

And if add wire() nothing changes.

c2 = Workplane().box(10, 10, 10).faces("<Y")
for x in cast(List[Edge], c2.faces("<Y").edges().wire().vals()):
    print(x.normal())

kolod avatar Apr 28 '24 19:04 kolod