cadquery icon indicating copy to clipboard operation
cadquery copied to clipboard

Finding coplanar and concentric surfaces

Open mxmws opened this issue 1 year ago • 5 comments

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 avatar Apr 29 '24 10:04 mxmws

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.

bragostin avatar May 02 '24 11:05 bragostin

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?

mxmws avatar May 02 '24 18:05 mxmws

Maybe comparing areas and centers with

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

bragostin avatar May 02 '24 19:05 bragostin

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.

mxmws avatar May 06 '24 19:05 mxmws

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.

bragostin avatar May 10 '24 06:05 bragostin