A python script to construct a simple skin around a wire frame mesh in Blender.
+-----+ #=====# (My ASCII art sucks,
| | => || || but you get the picture)
+-----+ #=====#
Non-ASCII version:
This software works with Blender 2.8 and earlier versions too.
Check out the repository and look in the demo directory.
This software may also be installed via pip:
python3 -m pip install wire_skin
or
pip3 install wire_skin
Blender has a skin modifier that does great things for a lot of meshes. It doesn't seem to do the right thing for some of the sorts of meshes I want 3D printed (usually the caps where the vertices are have an asymmetry that is displeasing to me). The meshes I am trying to create are typically geometric cages for presenting other 3D objects.
This script is meant to address this for me. It certainly isn't a general purpose skinning script, and doesn't pretend to be -- it will likely fail if your input mesh doesn't match a use case similar to mine. I hope the script is useful to you, but really the Blender skin modifier should be more than adequate for most purposes.
Play around with the demo blend file before adapting the script (imported as a module) into your project.
We break the problem down into two parts: calculating "VertCaps" for each vertex in the input mesh, and joining the VertCaps using profile connectors.
Each VertCap can be decomposed further. The vertices that are needed to make a VertCap are comprised of a couple of "poles" that stradle either side of the concavity of the vertex, and some profile shapes (at this stage of development, rectangles) that go around each edge connected to the vertex.
Next, faces connect these vertices. These are broken into two groups: the faces (triangles) that connect the profiles to a pole, and strips of faces that run between the profiles that connect the pole (a triangle, a quad, and another triangle).
At this point, the VertCap is complete.
Quads connect the VertCaps together along edges, and this is pretty straight forward.
Well, take a look at the demo file. The WireSkin
object generates a mesh when it's create_mesh()
method is called. The object is initialized with a mesh as input, and a number of keyword arguments:
dist
: distance between each vertex in the input mesh and the profile vertices described above.width
: the width of the rectangular profiles.height
: the height of the rectangular profiles.outside_radius
: the distance between a vertex in the base mesh and a outside pole vertex in a VertCapinside_radius
: the distance between a vertex in the base mesh and a inside pole vertex in a VertCap.
A couple of cryptic illustrations should make this clear:
But wait, there's more! ...
crease
: this sets the subsurf edge creases for edges that surround the holes in the output mesh. Set this to a float between0.0
and1.0
orNone
.
displace
: this float value moves each vert cap in the direction of the outside pole.
proportional_scale
: This is a boolean option. When this option is selected, the various length settings become proportions of the edge lengths near the vert cap:- pole measurements
inside_radius
andoutside_radius
are proportial to the average length of the incoming edges to a vertex; - profile measurements
dist
,width
, andheight
are proportial to the edge that the profile is on.
- pole measurements
Now how much would you pay? But wait:
edges_without_poles
: This is a boolean option. When this option is selected, the vertices that are connected to two edges (basically a bisected edge) do not have a full VertCap on them -- just a profile is produced at the vertex, not poles. This allows the user some control of the curvature on edges without. Take a look at the demo file.
The demo file (wire_skin_demo.blend) had five examples on layers 1 - 5. The script in the text window generates all of the examples (alt-P to run when your mouse is in the text window).
Just a cube-ish shape with some sharp corners:
An example using creasing:
A spikey thingy:
Using the same wire frame to generate a few intersecting objects with different parameters:
Generating multiple creased objects from the same wireframe, but using a boolean difference with the displace option to make some interesting shapes:
A honeycomb torus thingy:
A honeycomb torus thingy, but using the proportional scale option:
Demo of the "Edges without poles" feature:
I primarily use wire_skin to create objects for 3D printing (on Shapeways). I tag my models with the keyword wire_skin
. If you also use Shapeways to print models made with wire_skin, feel free to use this tag -- I'd be very interested to see what you make!