gumyr / cq_warehouse

A cadquery parametric part collection
Apache License 2.0
107 stars 23 forks source link

Shape.copy() changes breaks Assembly.solve() #67

Closed gumyr closed 1 year ago

gumyr commented 1 year ago

import cq_warehouse.extensions breaks the following:

import cadquery as cq

asm = (
    cq.Assembly()
    .add(cq.Solid.makeBox(1, 1, 1), name='b1', color=cq.Color('yellow'))
    .add(cq.Solid.makeBox(1, 1, 1), name='b2', color=cq.Color('red'))
    .constrain('b1@faces@<Z', 'b2@faces@<Z', 'Plane')
)
asm.solve()
show_object(asm)

with the following error:

>>> cq.Face.makePlane(3,4).copy()._geomAdaptor()
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/peter/cadquery/cadquery/occ_impl/shapes.py", line 2206, in _geomAdaptor
    return BRep_Tool.Surface_s(self.wrapped)
TypeError: Surface_s(): incompatible function arguments. The following argument types are supported:
    1. (F: OCP.TopoDS.TopoDS_Face, L: OCP.TopLoc.TopLoc_Location) -> OCP.Geom.Geom_Surface
    2. (F: OCP.TopoDS.TopoDS_Face) -> OCP.Geom.Geom_Surface

Invoked with: <OCP.TopoDS.TopoDS_Shape object at 0x7f1dc0ad2730>
>>> 
gumyr commented 1 year ago

Adding a downcast fixes the problem:

    memo = {id(self.wrapped): downcast(BRepBuilderAPI_Copy(self.wrapped).Shape())}