CadQuery / cadquery

A python parametric CAD scripting framework based on OCCT
https://cadquery.readthedocs.io
Other
3.27k stars 295 forks source link

Hole not at the current workplane #1709

Open davidedelvento opened 1 week ago

davidedelvento commented 1 week ago

The following

a = Workplane("XY")
a = a.box(9, 20, 4)
a = a.faces("<Y")
a = a.workplane()
a = a.rect(4,4).extrude(13)
a = a.faces(">X")
a = a.hole(2)

generates

image

in which the hole is rotated 90 degrees from the current workplane.

Is this a bug or am I doing something incorrect?

adam-urbanczyk commented 1 week ago

You changed the workplane here a = a.faces("<Y"). So the hole direction looks OK I think.

davidedelvento commented 1 week ago

You changed the workplane here a = a.faces("<Y"). So the hole direction looks OK I think.

Thanks, but I changed it back later with a.faces(">X")! Why does that change the position but not the orientation? Or rather how do I change also the orientation which is what I need?

adam-urbanczyk commented 1 week ago

Are you maybe confusing workplane and selection?

davidedelvento commented 1 week ago

Are you maybe confusing workplane and selection?

Possibly. But https://cadquery.readthedocs.io/en/latest/classreference.html#cadquery.Workplane.hole says

The surface of the hole is at the current workplane.

Arguably "the surface" is ambiguous but I understood it as the "surface" that one would drill through during the manufacturing.

Can you please clarify?

davidedelvento commented 1 week ago

Okay so adding a workplane fixes the issue, as below

a = Workplane("XY")
a = a.box(9, 20, 4)
a = a.faces("<Y")
a = a.workplane()
a = a.rect(4,4).extrude(13)
a = a.faces(">X").workplane()
a = a.hole(2)

I am probably still a bit confused between workplane and selection, but at least I can move forward and learn.