Skip to content
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

Selecting a face defined by Sketch on plane #1597

Closed
lorenzncode opened this issue May 28, 2024 · 3 comments
Closed

Selecting a face defined by Sketch on plane #1597

lorenzncode opened this issue May 28, 2024 · 3 comments
Labels
enhancement New feature or request free func

Comments

@lorenzncode
Copy link
Member

Say I'm working with the free func API to create a sweep. I'd like to create the wire to sweep with Sketch on a given plane (here using Workplane).
There is a private method to access the face. Is there a better way or could a public interface to select the face be provided?

import cadquery as cq
from cadquery.occ_impl.shapes import *

pts = [(10, 10, 0), (20, 10, 10), (30, 10, -10), (30, 0, 0)]

path = spline(pts)
plane = cq.Plane(origin=path.startPoint(), normal=path.tangentAt(0))

profile_sketch = cq.Sketch().regularPolygon(1, 3)

# free func sweep does not support multiple wires
#profile_sketch = cq.Sketch().push([(-4, 0), (4, 0)]).regularPolygon(1, 3)

wp = cq.Workplane(plane).placeSketch(profile_sketch)

# workarounds
# 1. iter
# wi = list(iter(wp.val()))[0].wires()
# 2. private _getFaces
wi = wp._getFaces()[0].wires()

sweep = sweep(wi, path, True)
@adam-urbanczyk
Copy link
Member

Good point, I think we should add cq.Sketch.val() to be consistent with cq.Workplane(). Also I think sweep could be extended to lower faces to wires (and check if they are planar).

@adam-urbanczyk
Copy link
Member

adam-urbanczyk commented Sep 25, 2024

@lorenzncode both cq.Sketch.val() and sweep with faces are supported now. Do you agree with closing of this issue?

sweep(cq.Sketch().circle(1).val(), segment((0,0,0),(0,1,1)))

@lorenzncode
Copy link
Member Author

@adam-urbanczyk Agreed. I forgot to revisit this issue after the enhancements.

While possible to create the face without Sketch it's nice to have this option to interface with the Free function API.

Going back to the first example - this works now:

pts = [(10, 10, 0), (20, 10, 10), (30, 10, -10), (30, 0, 0)]

path = spline(pts)
plane = cq.Plane(origin=path.startPoint(), normal=path.tangentAt(0))

profile_sketch = cq.Sketch().push([(-1, 0), (1, 0)]).regularPolygon(1, 3)

result = sweep(profile_sketch.moved(path.locationAt(0)).val(), path, True)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request free func
Projects
None yet
Development

No branches or pull requests

2 participants