Hi
Update! Combined both old scripts in one .Also changed/improved some code.And added new script which uses meta capsules for wire mesh creation .
Use and Purpose:
If run on mesh object this script makes Wire like mesh out of wireframe of mesh and if run on curve it makes a closed wire mesh out of it.
Input fields
Thickness=0.05 # Wire Thickness
Resolution=4 # Wire resolution. 0 to 32
# WireFrameMesh Script for blender 2.6x
# This script makes WireMesh from Wireframe of solid Meshes and make closed
# tubular mesh from path/curve.
#
#
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#-------------------------Do Not Modify Anything Above This Line----------------------
Thickness=0.05 # Wire Thickness
Resolution=4 # Wire resolution. 0 to 32
#-------------------------------------------------------------------------------------
import bpy
from mathutils import Vector
def sealends(): # closes non-manifold tube ends
current_mode = bpy.context.active_object.mode
if current_mode == 'OBJECT' and bpy.context.active_object.type=='MESH':
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.select_all(action='DESELECT')
bpy.ops.wm.context_set_value(data_path="tool_settings.mesh_select_mode", value="(False, True, False)")
bpy.ops.mesh.select_non_manifold()
bpy.ops.mesh.extrude_region_move()
bpy.ops.mesh.merge(type='COLLAPSE', uvs=False)
bpy.ops.object.mode_set(mode=current_mode)
if bpy.context.active_object==None:pass
else:
if bpy.context.active_object.mode is not 'OBJECT':
bpy.ops.object.mode_set(mode='OBJECT')
if bpy.context.active_object.type=='MESH':
bpy.ops.object.duplicate()
bpy.ops.wm.context_set_value(data_path="tool_settings.mesh_select_mode", value="(False, True, False)")
obj = bpy.context.active_object
obj.select=True
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.delete(type='ONLY_FACE')
bpy.ops.object.mode_set(mode='OBJECT')
for indx in range(len(obj.data.edges)):
obj.data.edges[indx].select = True
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mesh.split()
bpy.ops.object.mode_set(mode='OBJECT')
obj.data.edges[indx].select = False
bpy.ops.object.convert(target='CURVE', keep_original=False)
obj.data.fill_mode='FULL'
obj.data.bevel_resolution=Resolution
obj.data.bevel_depth=Thickness
bpy.ops.object.convert(target='MESH', keep_original=False)
elif bpy.context.active_object.type=='CURVE':
obj=bpy.context.active_object
obj.select=True
def1=obj.data.fill_mode
def2=obj.data.bevel_resolution
def3=obj.data.bevel_depth
obj.data.fill_mode='FULL'
obj.data.bevel_resolution=Resolution
obj.data.bevel_depth=Thickness
bpy.ops.object.convert(target='MESH', keep_original=True)
obj.data.fill_mode=def1 #reverting
obj.data.bevel_resolution=def2
obj.data.bevel_depth=def3
sealends()
Above is Meta WireMesh preview! New script below
# WireFrame MetaMesh Script for blender 2.6x
# This script make wiremesh from Wireframe of solid Meshes and it uses
# MetaObject(Capsules) to do so.
#
#
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
#-------------------------Do Not Modify Anything Above This Line----------------------
Thickness = 0.05
Resolution = 1 #between 0.05 to 1 LOWER IS SLOWER
#---------------------------------------------------------------------------------------
import bpy
import math
import mathutils
from mathutils import Vector
def glb_co(localco,obj):
wmtx = obj.matrix_world
worldco = wmtx*localco
return worldco
def AlignX(v1,v2):
dvec=v2-v1
rotation_quat = dvec.to_track_quat('X', 'Y')
return rotation_quat
def dist3d(Vec1,Vec2):
dist = math.sqrt((Vec2.x-Vec1.x)**2 + (Vec2.y-Vec1.y)**2 + (Vec2.z-Vec1.z)**2)
return dist
def midpt3d(Vec1,Vec2):
mx=(Vec1.x+Vec2.x)/2
my=(Vec1.y+Vec2.y)/2
mz=(Vec1.z+Vec2.z)/2
return Vector((mx,my,mz))
if bpy.context.active_object==None:pass
else:
if bpy.context.active_object.mode is not 'OBJECT':
bpy.ops.object.mode_set(mode='OBJECT')
if bpy.context.active_object.type=='MESH':
ob_act=bpy.context.active_object
location=ob_act.location
scale =ob_act.scale
rotation=ob_act.rotation_euler
edgecount=len(ob_act.data.edges)
edge_mid=[]
edge_len=[]
edge_align=[]
#----------------------------------------------
for e in range(edgecount):
vert1=ob_act.data.edges[e].vertices[0]
vert2=ob_act.data.edges[e].vertices[1]
v_loc1=ob_act.data.vertices[vert1].co
v_loc2=ob_act.data.vertices[vert2].co
v_glb1=glb_co(v_loc1,ob_act)
v_glb2=glb_co(v_loc2,ob_act)
len=dist3d(v_glb1,v_glb2)
mid=midpt3d(v_glb1,v_glb2)
qua=AlignX(v_glb1,v_glb2)
edge_mid.append(mid)
edge_len.append(len)
edge_align.append(qua)
#---------------------------------------------
bpy.ops.object.metaball_add(type='CAPSULE', view_align=False, enter_editmode=False, location=location, rotation=(0.0, 0.0, 0.0), layers=(True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False))
obj=bpy.context.active_object
scl=Thickness
obj.scale=(scl,scl,scl)
obj.data.resolution=Resolution
obj.data.update_method='NEVER'
bpy.ops.object.mode_set(mode='EDIT')
bpy.ops.mball.delete_metaelems()
for i in range(edgecount):
bpy.ops.object.metaball_add(type='CAPSULE', view_align=False, enter_editmode=False, location=edge_mid[i], rotation=(0.0, 0.0, 0.0), layers=(True, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False, False))
rsize=(edge_len[i]/scl)/2
bpy.ops.transform.resize(value=(rsize,rsize,rsize), constraint_axis=(True, False, False))
obj.data.elements.active.rotation=edge_align[i]
bpy.ops.object.mode_set(mode='OBJECT')
obj.data.update_method='UPDATE_ALWAYS'