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

Finding coplanar and concentric surfaces #1576

Open
mxmws opened this issue Apr 29, 2024 · 5 comments
Open

Finding coplanar and concentric surfaces #1576

mxmws opened this issue Apr 29, 2024 · 5 comments
Labels
question Further information is requested

Comments

@mxmws
Copy link

mxmws commented Apr 29, 2024

I imported a 3D part from a step file. Addionally I have parameters for the following surfaces:

  1. a plane defined by a directional vector and an offset
  2. a cylinder surface defined by a positional vector, a directional vector and a radius

I would like to find all faces in my part that are either coplanar to my plane or concentric and equal in radius to my cylinder surface.

My idea was to iterate over all faces and compare their parameters with the plane/cylinder I have.
Is there a better way to do this and if no, how do I iterate over the faces of my part?

@mxmws mxmws added the question Further information is requested label Apr 29, 2024
@bragostin
Copy link
Contributor

Personally I use BoxSelector, like this

faces = cq_object.faces(cq.selectors.BoxSelector(corner0, corner1, boundingbox=True))

to select objects having the same, or contained in, bounding boxes.

@mxmws
Copy link
Author

mxmws commented May 2, 2024

Personally I use BoxSelector, like this

faces = cq_object.faces(cq.selectors.BoxSelector(corner0, corner1, boundingbox=True))

to select objects having the same, or contained in, bounding boxes.

Thank you, this is helpful! Do you have any idea how I could do the same for cylinders?

@bragostin
Copy link
Contributor

Maybe comparing areas and centers with

center = face.val().Center().toTuple()
area = face.val().Area()

@mxmws
Copy link
Author

mxmws commented May 6, 2024

Personally I use BoxSelector, like this

faces = cq_object.faces(cq.selectors.BoxSelector(corner0, corner1, boundingbox=True))

to select objects having the same, or contained in, bounding boxes.

Thank you again, this works. But how can I select the remaining surfaces? "not" doesn't work. Basically I want to show all surfaces but color the selected ones.

@bragostin
Copy link
Contributor

You could get a list of all surfaces with faces = cq_object.faces().vals() and then remove from this list the selected ones. That would leave you with a list of not selected surfaces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants