2D Rotational Pattern

45 views
Skip to first unread message

TJ Neyman

unread,
May 16, 2024, 4:42:47 PMMay 16
to CadQuery
I'm looking to generate a sketch from a set of points, mirror it, and then create a rotated pattern with multiple instances of this object. It's a common CAD sketching feature, but I can't figure out the best way to do it and extrude the result.

I begin by importing a set of points and using Workplane.polyline() to generate the half profile

Screenshot 2024-05-16 153837.png

Then I mirror that about the x-axis to create one segment
Screenshot 2024-05-16 153930.png

And this is where i'm not sure the best option--I began by rotating and placing more sketches to complete the shape, which seems to produce exactly what I'm looking for:
Screenshot 2024-05-16 154133.png
When I try to extrude this shape it gives errors and I haven't able to resolve them. I imagine I am missing some step to resolve the sketch geometry, or I am going about it an overly complicated way.

Any advice?

Lorenz

unread,
May 16, 2024, 7:09:51 PMMay 16
to CadQuery

With the latest (unreleased) changes on github it's possible to use eachpoint like this:

import cadquery as cq

pts = [
    (10, 0),
    (10, 2),
    (4, 2),
    (3, 3),
]

# Workplane object with edges
wp_edges = cq.Workplane().polyline(pts).mirrorX()

res = (
    cq.Workplane()
    .polarArray(0, 0, 360, 4)
    .eachpoint(wp_edges)
    .consolidateWires()
    .extrude(2)
)

Adam Urbanczyk

unread,
May 17, 2024, 1:48:05 AMMay 17
to CadQuery
I'd use sketch in a different way:

w = 10
h = 1
r =2
rc = 0.2

s = (
    cq.Sketch()
    .circle(r)
    .rect(w,h)
    .rect(w,h,angle=90)
    .clean()
    .vertices()
    .fillet(rc)
)

show_object(s)

If you array has more instances than 2 use `.parray(...).rect(w,h)`:

w = 10
h = 1
r =2
rc = 0.2

s = (
    cq.Sketch()
    .circle(r)
    .parray(0,0,180,4)
    .rect(w,h)
    .clean()
    .reset()
    .vertices()
    .fillet(rc)
)

show_object(s)

Note additional `.reset()` call for resetting selection
Message has been deleted

TJ Neyman

unread,
May 21, 2024, 5:20:45 PMMay 21
to CadQuery
Thank you, that makes sense!

I'm working with the sketch approach now, and was able to combine your solution with my point inputs by using them with polygon().

If you have time and wouldn't mind sharing, what are some of the benefits/differences between using the cq.Sketch() approach and using the 2D cq.Workplane() methods?

Adam Urbanczyk

unread,
May 23, 2024, 2:00:06 AMMay 23
to CadQuery
I'd use cq.Workplane only for very simple 2D operations and cq.Sketch for everything else. Workplane has a more complicate API and you are more likely to code yourself into a corner.
Reply all
Reply to author
Forward
0 new messages