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

Error more gracefully in set operations #145

Open
andrewkrippner opened this issue Mar 1, 2024 · 1 comment
Open

Error more gracefully in set operations #145

andrewkrippner opened this issue Mar 1, 2024 · 1 comment

Comments

@andrewkrippner
Copy link

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.

@andrewkrippner
Copy link
Author

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
}

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

No branches or pull requests

1 participant