Hey, guys!
After many long days of coding, I've finally got my
Shapeways Tools script into working shape. The script file is attached and should be ready for use in the usual way. (If you don't know how to install Blender scripts, a quick web search will show you how.) Usable with Blender 2.49 and Python 2.6
only - Blender 2.50 will change the Python interface significantly. This is a merger of my own work into Loonsbury's excellent Shapeways Cost script (with Loonsbury's permission), updating and revising that script and adding all-new functionality.
In particular,
wall thickness checks. Fully automatic, you can present the script with your mesh and it will run through looking for wall thickness violations. Yes, it's really that simple.
It doesn't just deliver a "good" or "bad" message, though. You read the detailed results using Weight Paint mode; the script paints detailed output into three vertex groups in your Blender file. The primary one, "Wall Thickness," contains all points on your mesh which lie under, or close to (within 20% of), the wall thickness limit. Faces where the thickness is less than 80% of the limit are solid red (100% weight); then it shades to green (50% weight) for faces whose associated wall thickness are exactly on the threshold; then down to light blue (0% weight) as they hit 20% over.
This is intended to give you some warning, as well as flagging outright violations. The two other groups produced, "Wall Errors" and "Wall Warnings," are for your convenience... one contains only the points above 50%, the other only the points below that cutoff.
A few options have been added to help you customize this check:
-
"Check All" versus
"Check Selected" let you apply either the Manifold check or the Wall Thickness check to just a portion of your model instead of the whole thing.
- The
"Densify" option causes it to check each face against all other vertices and face centers. (Normally it just checks against each other vertex.) If you have some places where things look patchy, or if you want greater certainty about your results, enable this option - but it'll take about 3x as long as it will without Densify.
- The
"Curveoff" and
"Exact" options are not enabled yet; these will deal with some uncommon cases which can arise in the wall thickness math. For the most part, if your faces are generally smaller than your wall thickness, you shouldn't need these at all, even in theory.
- The
"Sample" option is great for cutting down the time required to check your mesh. It simply checks a random sample of the faces in your mesh (controlled by the number next to this option, where 0.50 = 50% of faces). As a first pass, don't bother spending tens of minutes running the full test, just check 10-15% of faces and you'll get a reasonably good idea of where any problems may lie.
- The
"Estimate Time" option does exactly that - it runs a short (under 15 seconds) simulation of the test you've currently specified, including all options as currently set, and extrapolates the time it'll take to do the whole thing. For meshes which have their faces all roughly the same size, the result tests out for me as quite accurate indeed.
This remains a beta version of this script. I'm certain that there are still bugs I haven't caught, and I suspect that there may also be meshes which will produce false positives and/or false negatives with it.
I invite you to try it out and share the results with the community. I'm very interested in getting this script working well, for the sake of the Shapeways folks more than anyone else, and will continue to actively improve it as comments come in.
It can handle multiple objects, but makes no accomodation for "walls" which aren't actually physical walls of the detected thickness because one too-thin mesh collides with another. So depending on your modeling technique, you may need to run some Booleans to get truly accurate results. It will also not detect walls between one Blender object and another; multiple objects just means check each one separately, not check them against each other. [If there's demand for it, I could probably rewrite it to handle multiple objects against each other, but it'd be a lot of work. Just merge the meshes and then check; you can always unmerge them later with Ctrl-L and Pkey in editmode.]
As an added bonus, the wall thickness test will pinpoint certain kinds of nonmanifold errors for you, since those show up as wall thickness violations. Look for small patches of full red in the midst of a sea of blue, and inspect the mesh there.
The algorithm it uses is the fastest one I could devise, out of at least a dozen completely different mathematical back-ends that I've tried. And it's by far the fastest of them.
But the time it takes still scales as the
square of the number of faces you're checking... on the laptop where I did the development for this, 10,000 tris (or 5,000 quads) take about thirty seconds to check, and then each time you double that number of polygons, you
quadruple the time it takes. There's a reason why I built in Sample mode and the Time Estimate button.
The algorithm is also
very picky. Basically it treats each face (actually each triangle, treating quads as two) as the front end of a kind of triangular 'rod' or truncated pyramid, with the edges of the rod defined by the vertex normals and the far end defined by the wall thickness limit. If any points of the mesh lie within that volume, it flags them. In practice, this means that I suspect there will exist designs which would
fail this test but which would print OK, if perhaps just barely. But I'm quite sure that, failing bugs or edge cases (such as faces noticeably bigger than the wall limit), any piece which passes the test as "Good" will be acceptable to Shapeways, per their published criteria, and will print OK.
Joris and gang, please do run this baby on lots of meshes that did print OK, and on lots that didn't, and work with me to refine the parameters inside the program until we get the best possible fit to what actually works and doesn't work in practice.
Consider this a tribute, to a most excellent company indeed.
Happy wall-banging!
- Eric Finley
(Update Jan 18/2010: A couple of bugfixes in the file, including the one referenced by esnoeijs below; if you downloaded it prior to now, you may wish to overwrite it with this version.)
(Update Jan 19/2010: Clarified multiple object usage.)