CadQuery / CadQuery/cadquery

Strange offset2D result

Open
#1,057 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
5.8k
Forks
541
Avg merge
3d 2h
Merged PRs (30d)
5

Description

Any idea why offset2D gives different results for these two test blocks?

```
import cadquery as cq

test1 = (cq.Workplane()
.box(25,25,1)
.faces(">Z").workplane()
.moveTo(7.825,-3.155)
.circle(3.15/2).cutThruAll()
.moveTo(-7.825,-3.155)
.circle(3.15/2).cutThruAll()
.moveTo(-7.825,3.155)
.circle(3.15/2).cutThruAll()
.moveTo(7.825,3.155)
.circle(3.15/2).cutThruAll()
)

test2 = (cq.Workplane()
.box(25,25,1)
.faces(">Z").workplane()
.rect(2*7.825,2*3.155,forConstruction=True)
.vertices().circle(3.15/2).cutThruAll()
)

circles1 = test1.faces(">Z").edges("%CIRCLE")
small_circles1 = circles1.toPending().offset2D(-0.5)
# same as test1, but shifted up by 2 for viewing
circles2 = test2.translate([0,0,2]).faces(">Z").edges("%CIRCLE")
small_circles2 = circles2.toPending().offset2D(-0.5)

show_object(circles1,options={"color":"blue"})
show_object(small_circles1,options={"color":"red"})

show_object(circles2,options={"color":"orange"})
show_object(small_circles2,options={"color":"yellow"})

```
![Screenshot from 2022-04-20 23-47-04](https://user-images.githubusercontent.com/19427111/164271020-53b5e9e8-cd4b-4c6d-8539-56133982fb2e.png)

For test1 (red/blue) the offset is correct for the circle at the last 'moveTo' position (shuffle the order of the moveTo lines and the last one will have the proper offset)..

I also saw a case where the circles were sized properly, but their locations were shifted in X, Y and Z from where they were expected. There are two other issues ( [#896](https://github.com/CadQuery/cadquery/issues/896) and [#753](https://github.com/CadQuery/cadquery/issues/753)) already open that sounded like they are related to that issue.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.