CadQuery / CadQuery/cadquery

scaling shapes

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

Description

There is `Workplane.rotate` and `Workplane.translate` but not `Workplane.scale`.
There doesn't seem to be an easy way to scale shapes so I came up with this. Perhaps it should be part of the core API?
```python
def scale(workplane: cq.Workplane, x: float, y: Optional[float] = None, z: Optional[float] = None) -> cq.Workplane:
y = y if y is not None else x
z = z if z is not None else x
t = cq.Matrix([
[x, 0, 0, 0],
[0, y, 0, 0],
[0, 0, z, 0],
[0, 0, 0, 1]
])
return workplane.newObject([
o.transformGeometry(t) if isinstance(o, cq.Shape) else o
for o in workplane.objects
])
```
perhaps a generic `Workplane.transform(cq.Matrix)` would also be useful?

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.