CadQuery / cadquery

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

Problem scaling an object #1507

Open smurfix opened 9 months ago

smurfix commented 9 months ago

I want to scale a wire so I can do a loft() to a shrunken copy of itself (like OpenSCAD's linear_extrude with scale != 1). So the first step should be to shrink a (2d) object … right?

f = 0.5
m = cq.Matrix([[f,0,0,0],[0,f,0,0],[0,0,f,0]])
ws = cq.Workplane("XY").rect(5,5)  # simple example
s = ws.objects[0].transformShape(m)

Unfortunately this attempt results in

File "/opt/CQ-Editor/lib/python3.11/site-packages/cadquery/occ_impl/shapes.py", line 967, intransformShape
    BRepBuilderAPI_Transform(self.wrapped, tMatrix.wrapped.Trsf()).Shape()
                                           ^^^^^^^^^^^^^^^^^^^^^^
OCP.Standard.Standard_ConstructionError: gp_GTrsf::Trsf() - non-orthogonal GTrsf

I have no idea why this matrix is considered to be non-orthogonal, nor how to fix this.

NB, the same thing happens when I try to scale a 3D shape.

lorenzncode commented 9 months ago

There is transformGeometry, see https://github.com/CadQuery/cadquery/issues/638#issuecomment-778790445