gumyr / cq_warehouse

A cadquery parametric part collection

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error running brad_tee_and_heatset_nuts.py: AttributeError: 'Assembly' object has no attribute 'metadata'

SeanDS opened this issue · comments

I'm using the current cq_warehouse repository HEAD (cc694aa), and the latest published cadquery (2.1) and cq-editor (0.3.0dev) packages from conda, and running the brad_tee_and_heatset_nuts.py example I'm getting the following error:

Traceback (most recent call last):
  File "/home/sean/Workspace/Repositories/cq_warehouse/examples/brad_tee_and_heatset_nuts.py", line 54, in <module>
    cq.Workplane("XY")
  File "/home/sean/Workspace/Repositories/cq_warehouse/src/cq_warehouse/extensions.py", line 944, in _clearanceHole
    return self.fastenerHole(
  File "/home/sean/Workspace/Repositories/cq_warehouse/src/cq_warehouse/extensions.py", line 876, in _fastenerHole
    baseAssembly.metadata[baseAssembly.children[-1].name] = fastener
AttributeError: 'Assembly' object has no attribute 'metadata'

This happens on some of the others as well.

Thanks, that worked. I thought I had made sure I had the latest versions of all of the packages but it seems I didn't get conda to update correctly. Reinstalling worked.

There are still a bunch of errors running some of the examples - but not from lack of metadata - are these already known or should I submit new reports for these?

getting these errors running the cq_warehouse examples?

Yes. Using cadquery master (via conda) and cq-warehouse master (via git clone), both installed in a clean environment today, with Python 3.10. I ran pip install -e . on a local clone of cq-warehouse to get the latest.

The following three examples fail. The rest are fine.

(cadquery)  $ python brad_tee_and_heatset_nuts.py 
Traceback (most recent call last):
  File "/home/sean/Workspace/Repositories/cq_warehouse/examples/brad_tee_and_heatset_nuts.py", line 43, in <module>
    heatset = HeatSetNut(
  File "/home/sean/Workspace/Repositories/cq_warehouse/src/cq_warehouse/fastener.py", line 559, in __init__
    self._cq_object = self.make_nut().val()
  File "/home/sean/Workspace/Repositories/cq_warehouse/src/cq_warehouse/fastener.py", line 983, in make_nut
    lower_knurl_faces = HeatSetNut.knurled_cylinder_faces(
  File "/home/sean/Workspace/Repositories/cq_warehouse/src/cq_warehouse/fastener.py", line 907, in knurled_cylinder_faces
    bottom_face = cq.Face.makeFromWires(
  File "/home/sean/Workspace/env/conda/envs/cadquery/lib/python3.10/site-packages/cadquery/occ_impl/shapes.py", line 2268, in makeFromWires
    raise ValueError("Cannot build face(s): outer wire is not closed")
ValueError: Cannot build face(s): outer wire is not closed
(cadquery)  $ python drafting_examples.py 
/home/sean/Workspace/env/conda/envs/cadquery/lib/python3.10/site-packages/cadquery/utils.py:65: FutureWarning: Kwarg <cut> will be removed. Plase use <combine='cut'>
  warn(
Traceback (most recent call last):
  File "/home/sean/Workspace/Repositories/cq_warehouse/examples/drafting_examples.py", line 82, in <module>
    length_dimension_line = metric_drawing.extension_line(
  File "/home/sean/Workspace/Repositories/cq_warehouse/src/cq_warehouse/drafting.py", line 597, in extension_line
    d_line = self.dimension_line(
  File "/home/sean/Workspace/Repositories/cq_warehouse/src/cq_warehouse/drafting.py", line 460, in dimension_line
    line_wire = Draft._path_to_wire(path)
  File "/home/sean/Workspace/Repositories/cq_warehouse/src/cq_warehouse/drafting.py", line 262, in _path_to_wire
    path_as_wire = Wire.assembleEdges([path])
  File "/home/sean/Workspace/env/conda/envs/cadquery/lib/python3.10/site-packages/cadquery/occ_impl/shapes.py", line 1905, in assembleEdges
    wire_builder.Add(occ_edges_list)
OCP.Standard.Standard_TypeMismatch: TopoDS::Edge
(cadquery)  $ python flag_of_Ukraine.py 
Traceback (most recent call last):
  File "/home/sean/Workspace/Repositories/cq_warehouse/examples/flag_of_Ukraine.py", line 43, in <module>
    projected_top_face = top_face.projectToShape(the_wind, direction=cq.Vector(0, 0, -1))[0]
  File "/home/sean/Workspace/Repositories/cq_warehouse/src/cq_warehouse/extensions.py", line 1348, in _face_projectToShape
    projected_faces = [
  File "/home/sean/Workspace/Repositories/cq_warehouse/src/cq_warehouse/extensions.py", line 1349, in <listcomp>
    ow.makeNonPlanarFace(
  File "/home/sean/Workspace/Repositories/cq_warehouse/src/cq_warehouse/extensions.py", line 1623, in _wire_makeNonPlanarFace
    return makeNonPlanarFace(self, surfacePoints, interiorWires)
  File "/home/sean/Workspace/Repositories/cq_warehouse/src/cq_warehouse/extensions.py", line 1593, in makeNonPlanarFace
    raise RuntimeError("non planar face is invalid")
RuntimeError: non planar face is invalid

Thanks Sean. I'll try to recreate the problems you're seeing. I didn't know cadquery supported Python 3.10 yet so there are definitively some things to look into.

It looks like at least some of the issues are related to makeNSidedSurface. I raised an issue here: CadQuery/cadquery#1030 I did my development with a version of cadquery from around the beginning of the year but I don't know if that's helpful as there hasn't been a release in a year.

Looks like the version of OCP changed on Jan 13 (7.5.2 -> 7.5.3): CadQuery/cadquery#956 ... could be a nasty one.

Fixed drafting with 4c81538 A non backwards compatible change was made to assembleEdges which required a minor fix.

Should all work now after #30 Thanks for raising the issue.

Works, thanks!