Skip to content

Sketch distribute on segment fails #1819

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

Closed
lorenzncode opened this issue Apr 25, 2025 · 1 comment · Fixed by #1826
Closed

Sketch distribute on segment fails #1819

lorenzncode opened this issue Apr 25, 2025 · 1 comment · Fixed by #1826
Labels
bug Something isn't working sketching

Comments

@lorenzncode
Copy link
Member

from cadquery import Sketch

s1 = Sketch().segment((0, 0),(10, 0)).edges().distribute(3).rect(1, 2)

results in:

Traceback (most recent call last):
  File "/var/home/lorenzn/test1.py", line 3, in <module>
    s1 = Sketch().segment((0, 0),(10, 0)).edges().distribute(3).rect(1, 2)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/micromamba/envs/cq/lib/python3.12/site-packages/cadquery/sketch.py", line 475, in distribute
    locs.extend(el.locations(params, planar=True,))
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/micromamba/envs/cq/lib/python3.12/site-packages/cadquery/occ_impl/shapes.py", line 2213, in locations
    return [self.locationAt(d, mode, frame, planar) for d in ds]
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/micromamba/envs/cq/lib/python3.12/site-packages/cadquery/occ_impl/shapes.py", line 2187, in locationAt
    gp_Ax3(pnt, gp_Dir(0, 0, 1), gp_Dir(normal.XYZ())), gp_Ax3()
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
OCP.Standard.Standard_ConstructionError: gp_Dir::CrossCross() - result vector has zero norm

This succeeds:

s2 = Sketch().segment((0, 0),(10, 0)).edges().distribute(3, rotate=False).rect(1, 2)
@adam-urbanczyk adam-urbanczyk added the bug Something isn't working label Apr 25, 2025
@adam-urbanczyk adam-urbanczyk linked a pull request Apr 25, 2025 that will close this issue
@lorenzncode
Copy link
Member Author

Change to this?

                gp_Ax3(
                    pnt,
                    gp_Dir(0, 0, 1),
                    gp_Dir(Vector(0, 0, 1).cross(Vector(tangent)).normalized().wrapped),
                ),

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working sketching
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants