jimy-byerley / pymadcad

Simple yet powerful CAD (Computer Aided Design) library, written with Python.
https://madcad.netlify.app/
GNU Lesser General Public License v3.0
205 stars 15 forks source link

Is it possible to round the "unknown" sharp offset (thicken) edges with pymadcad? #92

Closed 1939938853 closed 9 months ago

1939938853 commented 9 months ago

Hello,

Is it possible to round the "unknown" sharp offset (thicken) edges with pymadcad? Perhaps need to extract all original edge points first and then apply pymadcad Bevel operation?

jimy-byerley commented 9 months ago

Hello What are these "unknown" edges ? As the documentations says, it is indeed needed to provide the set of edges you want to bevel. Do you mean you don't know how to extract such a set of the edges you want to bevel ?

1939938853 commented 9 months ago

Hello Jimy,

Yes. Is there any function in pymadcad that can be used to extract edges, like the one in pyvista?

sphx_glr_extract-edges_001

jimy-byerley commented 9 months ago

Yes there is in fact 2 steps for doing so:

Note that the first step is in case you do not have surface grouping at all, if your mesh comes from madcad.extrusion(), it has already groups defined

Option 1 could look like this:

raw_part = ...  # mesh without group informations
part = mc.reverse.segmentation(raw_part)
# suppose we want to select the edges arround the top face and a side face
edges = part.frontiers(
    part.groupnear(vec3(0,0,1)),   # assuming this point is somewhere above the mesh
    part.groupnear(vec3(2,0,0)),  # asuming this point is somewhere next to the mesh
    )
# then do whatever you want with these edges
bevel(part, edges, ('width', 0.1))
1939938853 commented 9 months ago

Hi,

In fact, I'm going to round/bevel a "free form" mesh boundary edges done by Madcad thicken, as shown below. It seems a little bit difficult either to group or to extract edges or to bevel.

image

jimy-byerley commented 9 months ago

Are you sure this mesh is an output from thinken on a madcad-generated mesh ? It looks like either - you are thinkening an imported soup of triangles (like a stl file) - or you used an other operation than thinkening

1939938853 commented 9 months ago

Hi Jimy,

It is true that the mesh is imported from a stl file. Can you give me some suggestions on how to make an organized mesh from soup triangles? Thank you!

jimy-byerley commented 9 months ago

Can you give me some suggestions on how to make an organized mesh from soup triangles?

In a stl file, the triangles points are supposed to coincide with neighboring triangles, so you just need to merge the close points together to obtain a connex mesh

part = read('myfile.stl')
part.mergeclose()

Then you can apply the operations you want, like any madcad-generated mesh. While thinkening, you will see that the border are much cleaner ;) Thinkening the triangle soup instead was extruding each triangle individually, resulting in what you got.