gumyr / cq_warehouse

A cadquery parametric part collection
Apache License 2.0
106 stars 22 forks source link

Screws with threads don't seem to work #87

Open smurfix opened 3 months ago

smurfix commented 3 months ago

This three-liner should work, according to the docs …

import cadquery as cq
import cq_warehouse.fastener as f
ss=f.SetScrew("M6-1",10,"iso4026", simple=False)

… but it doesn't:

File "/tmp/tt.py", line 3, in <module>
    ss=f.SetScrew("M6-1",10,"iso4026", simple=False)
       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/CQ-Editor/lib/python3.11/site-packages/cq_warehouse/fastener.py", line 1502, in __init__
    cq_object = self.custom_make()
                ^^^^^^^^^^^^^^^^^^
  File "/opt/CQ-Editor/lib/python3.11/site-packages/cq_warehouse/fastener.py", line 2064, in custom_make
    return self.make_setscrew()
           ^^^^^^^^^^^^^^^^^^^^
  File "/opt/CQ-Editor/lib/python3.11/site-packages/cq_warehouse/fastener.py", line 2096, in make_setscrew
    ret = core.union(thread.translate((0, 0, -thread.length)))
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/CQ-Editor/lib/python3.11/site-packages/cadquery/occ_impl/shapes.py", line 935, in translate
    return self._apply_transform(T)
           ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/CQ-Editor/lib/python3.11/site-packages/cadquery/occ_impl/shapes.py", line 895, in _apply_transform
    return self.__class__(BRepBuilderAPI_Transform(self.wrapped, Tr, True).Shape())
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: IsoThread.__init__() missing 2 required positional arguments: 'pitch' and 'length'

Tested on main branch, cadquery 2.4.0

gumyr commented 3 months ago

This is very strange. The failure happens on this line:

ret = core.union(thread.translate((0, 0, -thread.length)))

where thread.length=10 and the objects look like this at this point: image i.e. the thread is going to be positioned to match the core. Has translate changed?

smurfix commented 3 months ago

Has translate changed?

The problem exists since at least cadquery 2.2 (January 2023). I couldn't test older versions due to various incompatibilities.

gumyr commented 2 months ago

I've ported the fastener library to build123d & bd_warehouse and verified that all of the minimum size of all of the SetScrews can be created as shown here: Screenshot from 2024-04-13 11-00-42 I don't work with CadQuery anymore so fixing the cq_warehouse version is problematic.