replicad
replicad copied to clipboard
Error more gracefully in set operations
In general, geometrical errors are very difficult to troubleshoot. Is there a way to throw more informative messages?
In addition, are there better ways to handle the cases where errors are thrown? For instance, I am trying to filter a set of edges together in:
body = body.fillet(0.5, (e) => e.inDirection('Z'))
This is erroring out I assume because some of my edges are already tangent on both sides, so there is no fillet that can be added. I would much prefer if that single edge error was caught and the rest of the operation was allowed to continue.
I was able to address this with a try-catch in a loop. It doesn't seem the most efficient but this does the job I needed.
export const safeFillet = (
body: Solid,
edgeFinder: EdgeFinder,
radius: number,
) => {
let newBody = body
edgeFinder.find(body).forEach((edge) => {
try {
newBody = newBody.fillet((r) => {
if (r.isEqual(edge)) {
return radius
}
return 0
})
} catch {}
})
return newBody
}