Closed Yarkane closed 2 years ago
Hello @Yarkane and welcome there !
What version of pymadcad are you working with ? (there was a bug remaning in the boolean operations before v0.12) Could you send me the mesh files causing the error, so I can investigate on my side ?
Also did you already tries the slight shift trick ? performing the boolean operation after translating one of the meshes from almost nothing (that's a good trick to check if the probleme comes from an intersection/numeric-precision issue) like this:
madcad.union( a, b.transform(vec3(1e-4)) ) # the current translation direction could be tuned, and its length also in term of the mesh size
I was recently notified by a friend that there is still a bug occuring in those boolean operations even after v0.12, so this could be the same cause here ;)
Looks like it works quite well on my side, but I'm generating the parts using pymadcad, not importing them ... so I might not have the same placements, dimensions and mesh triangulations ...
p3 = difference(
icosphere(O, 1),
union(cylinder(-2*X, 2*X, 0.6), cylinder(-2*Z, 2*Z, 0.6)),
)
p4 = union(p3, cylinder(-2*X-0.6*Z, 2*X-0.6*Z, 0.7))
Hi there ! Thank you for your quick answer !
I can't give you stl files right now, but I know that we may usse pymadcad v0.11 . I'll keep you in touch, thanks for your help !
Hi there, sorry for the long week between the two messages.
The project was using pymadcad 0.11. Updating it to 0.12 resolved a lot of issues including the one I presented as an example that works well now.
We still have problems when faces are overlapping but as I see on the github, this is a common issue and for now we will have to deal with small translations tricks. We're going to work on it but I hope you will find a way to solve this issue too !
Thanks for your help :) Have a good day !
Nice it solved it, good luck for your project !
Also don't hesitate to come back if you have new bugs ;)
Hello to Jimy and the community, thank you for the hard work !
For a project, we need to compute the union of n Meshes. The user can select 2 meshes or more and we need to "merge" them in only one Mesh. These meshes are imported via an STL file. We use madcad.read() to import them in the scene :
We are then using the function madcad.union() to achieve this fusion, in this way :
In some cases, it does work pretty well : when the shapes are simple especially. It is, for example, easy to compute these unions of meshes to achieve this "complex" mesh :
For this mesh, we used a tube and a sphere.
But now let's use a slightly more complex shape to replace the sphere.
When trying to compute the fusion with a tube... (Moving the new shape to have an intersection, unless it simply doesn't work)
We get an error :
I guess this is because boolean operations are very sensible, and the meshes too complex. Is there at least a way to "simplify" the mesh ? For example, we also got TriangulationErrors when trying to extrude from polygons that were quite "complex", and we managed to fix the issue by calling an opencv function to "smooth" the polygon. Maybe there is a way for this 3D operation to smooth the meshes ?
Anyway, we will continue to dig on this topic. Thanks for the hard work and all the help you could give ! :)