CadQuery / CadQuery/cadquery

Operation along a rounded box

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

Description

Hey, I have a box which is rounded, now I want to select the upper edge (all around) and want to apply an operation every e.g. 2cm. Like in this picture:
image
How can I perform this operation? I have already:

```python
length = 180
width = 100
height= 80
wall = 0.4*2
topOffset = 5

part = (
cq.Workplane("XY")
.rect(width, length)
.workplane(offset=height)
.rect(width + topOffset, length + topOffset)
.loft(ruled=True)
.edges("not(|X)").edges("not(|Y)")
.fillet(3)
)

braceWidth = wall
braceDistanceAbsolute = 20

brace = (
cq.Workplane("XZ")
.lineTo(0, -height)
.lineTo(-topOffset, -height)
.close()
.extrude(wall)
)

circlePath = part.edges(">Z and >X").val()
print(circlePath.Length())

braceDistance = (braceWidth + braceDistanceAbsolute) / circlePath.Length()
braceCount = floor(circlePath.Length()/(braceDistanceAbsolute+braceDistance))

print(braceDistance)
print(braceCount)

for i in range(braceCount):
relative_position_on_path = i*braceDistance
wire_tangent = circlePath.tangentAt(relative_position_on_path)
wire_angle = degrees(atan2(wire_tangent.y, wire_tangent.x))
part = part.union(brace.rotate((0,0,0),(0,0,1), wire_angle-90).translate(circlePath.positionAt(relative_position_on_path)))

```
only issue is, that `circlePath` is not the full loop, but only one side 🤔

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.