Skip to content

moved() and offset2D() bug. Different result when applying to different wire shape. #1840

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
garywill opened this issue May 14, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@garywill
Copy link

garywill commented May 14, 2025

Image

Bug 1: When moved and offset2D applied to different shapes (circle or non-circle) , they result in different distance. (See screenshot. The wires group on top has larger distance)

Bug 2: A circle wire made by section() applied to middle of a circle-extruded solid fails to apply moved and offset2D

To Reproduce

import cadquery as cq
import traceback
print("=============================================")
solid = (
    cq.Workplane()
    .rect(1, 1)
    .extrude(2)
    .faces('>Z')
    .circle(0.5)
    .extrude(2)
)
show_object(solid)
r=0.2

arrz = [0, 1, 2, 3, 4]
for z in arrz:
    try:
        print(f'in loop {z=}')
        wire0 = (cq.Workplane()
            .add(solid).toPending()
            .section(z)
            .wires()
            .val()
        )
        show_object(wire0, name=f'{z=} wire0')

        wire_u = wire0.moved(cq.Vector(0, 0,  r       )).offset2D(0.1)
        show_object(wire_u, name=f'{z=} wire_u')

        wire_m1= wire0.moved(cq.Vector(0, 0,  (1/3)*r )).offset2D(r)
        show_object(wire_m1, name=f'{z=} wire_m1')

        wire_m2= wire0.moved(cq.Vector(0, 0, -(1/3)*r )).offset2D(r)
        show_object(wire_m2, name=f'{z=} wire_m2')

        wire_d = wire0.moved(cq.Vector(0, 0, -r       )).offset2D(0.1)
        show_object(wire_d, name=f'{z=} wire_d')

    except Exception as err:
        traceback.print_exception(err)

Backtrace

=============================================
in loop z=0
in loop z=1
in loop z=2
in loop z=3
Traceback (most recent call last):
  File "<cq_editor-string>", line 27, in <module>
  File "/home/username/.local/lib/python3.11/site-packages/cadquery/occ_impl/shapes.py", line 2682, in offset2D
    obj = downcast(offset.Shape())
          ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/username/.local/lib/python3.11/site-packages/cadquery/occ_impl/shapes.py", line 374, in downcast
    f_downcast: Any = downcast_LUT[shapetype(obj)]
                                   ^^^^^^^^^^^^^^
  File "/home/username/.local/lib/python3.11/site-packages/cadquery/occ_impl/shapes.py", line 364, in shapetype
    raise ValueError("Null TopoDS_Shape object")
ValueError: Null TopoDS_Shape object
in loop z=4

Environment

OS:

$ pip3.11 list |grep -i -E "cq-editor|cadquery"
cadquery                      2.5.2
cadquery-ocp                  7.7.2
CQ-editor                     0.5.0

Using:
CQ-Editor

@garywill garywill added the bug Something isn't working label May 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant