CadQuery / CadQuery/cadquery

Question: fitting a shape in a surface

Open
#191 19 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

Imagine I have a surface like this:

```python
box = cq.Workplane("XY").box(10, 10, 4) \
.faces(">Z").workplane().hole(3)
surface = box.faces(">Z")
surface
```

![Screenshot from 2019-09-15 22-27-35](https://user-images.githubusercontent.com/526577/64927211-0cf17700-d808-11e9-8ba5-9bdcf8c1137f.png)

Now I want to place a cylinder on top of it, at a "random" position, but only if the whole cylinder's base sits on top of the surface. In example, this would be valid:

```python
position = (-2, 3)
surface.center(*position).circle(1).extrude(2)
```

![Screenshot from 2019-09-15 22-31-48](https://user-images.githubusercontent.com/526577/64927259-a3259d00-d808-11e9-8918-45b19de509f6.png)

But this would not:

```python
position = (-1, 1)
surface.center(*position).circle(1).extrude(2)
```

![Screenshot from 2019-09-15 22-32-34](https://user-images.githubusercontent.com/526577/64927262-bf293e80-d808-11e9-93b3-179def00630b.png)

Is there a way to know if the circle (the cylinder's base) is fully contained in the surface?

The method should work for any surface shape (i.e.: not only for a perfectly squared surface with a perfect circle on the middle). The cylinder on top could also have a different shape in its base (like an irregular polygon).

I guess what I am looking for is a way to see if a face/polygon is contained in another face/polygon, right? The two faces/polygons are of course in the same plane.

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.