Scripts:
-- Campbell Barton updated some of his contributions, thanks!
This commit is contained in:
@@ -4,7 +4,7 @@
|
|||||||
Name: 'Batch Object Name Edit'
|
Name: 'Batch Object Name Edit'
|
||||||
Blender: 232
|
Blender: 232
|
||||||
Group: 'Object'
|
Group: 'Object'
|
||||||
Tooltip: 'Apply the chosen rule to rename all selected objects at once'
|
Tooltip: 'Apply the chosen rule to rename all selected objects at once.'
|
||||||
"""
|
"""
|
||||||
|
|
||||||
__author__ = "Campbell Barton"
|
__author__ = "Campbell Barton"
|
||||||
@@ -23,6 +23,7 @@ Select the objects to be renamed and run this script from the Object->Scripts
|
|||||||
menu of the 3d View.
|
menu of the 3d View.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
# $Id$
|
# $Id$
|
||||||
#
|
#
|
||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
@@ -49,6 +50,12 @@ menu of the 3d View.
|
|||||||
|
|
||||||
from Blender import *
|
from Blender import *
|
||||||
|
|
||||||
|
def new():
|
||||||
|
newname = Draw.PupStrInput('Name: ', '', 32)
|
||||||
|
if newname == None: return
|
||||||
|
for ob in Object.GetSelected():
|
||||||
|
ob.name = newname
|
||||||
|
|
||||||
def replace():
|
def replace():
|
||||||
replace = Draw.PupStrInput('Replace: ', '', 32)
|
replace = Draw.PupStrInput('Replace: ', '', 32)
|
||||||
if replace == None: return
|
if replace == None: return
|
||||||
@@ -96,20 +103,21 @@ def truncate_end():
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
name = "Selected Object Names%t|Replace Text|Add Prefix|Add Suffix|Truncate Start|Truncate End"
|
name = "Selected Object Names%t|New Name|Replace Text|Add Prefix|Add Suffix|Truncate Start|Truncate End"
|
||||||
result = Draw.PupMenu(name)
|
result = Draw.PupMenu(name)
|
||||||
|
|
||||||
if result == -1:
|
if result == -1:
|
||||||
pass
|
pass
|
||||||
elif result == 1:
|
elif result == 1:
|
||||||
replace()
|
new()
|
||||||
elif result == 2:
|
elif result == 2:
|
||||||
prefix()
|
replace()
|
||||||
elif result == 3:
|
elif result == 3:
|
||||||
suffix()
|
prefix()
|
||||||
elif result == 4:
|
elif result == 4:
|
||||||
truncate_start()
|
suffix()
|
||||||
elif result == 5:
|
elif result == 5:
|
||||||
|
truncate_start()
|
||||||
|
elif result == 6:
|
||||||
truncate_end()
|
truncate_end()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
#!BPY
|
#!BPY
|
||||||
|
|
||||||
"""
|
"""
|
||||||
Name: 'Cleanup Meshes'
|
Name: 'Clean Mesh'
|
||||||
Blender: 234
|
Blender: 234
|
||||||
Group: 'Mesh'
|
Group: 'Mesh'
|
||||||
Tooltip: 'Clean unused data from all selected meshes'
|
Tooltip: 'Clean unused data from all selected meshes'
|
||||||
@@ -9,7 +9,7 @@ Tooltip: 'Clean unused data from all selected meshes'
|
|||||||
|
|
||||||
__author__ = "Campbell Barton"
|
__author__ = "Campbell Barton"
|
||||||
__url__ = ("blender", "elysiun")
|
__url__ = ("blender", "elysiun")
|
||||||
__version__ = "1.0 04/25/04"
|
__version__ = "1.1 04/25/04"
|
||||||
|
|
||||||
__bpydoc__ = """\
|
__bpydoc__ = """\
|
||||||
This script cleans specific data from all selected meshes.
|
This script cleans specific data from all selected meshes.
|
||||||
@@ -29,6 +29,7 @@ After choosing one of the above alternatives, if your choice requires a
|
|||||||
threshold value you'll be prompted with a number pop-up to set it.
|
threshold value you'll be prompted with a number pop-up to set it.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
|
|
||||||
# $Id$
|
# $Id$
|
||||||
#
|
#
|
||||||
# --------------------------------------------------------------------------
|
# --------------------------------------------------------------------------
|
||||||
@@ -60,6 +61,8 @@ import Blender
|
|||||||
from Blender import *
|
from Blender import *
|
||||||
from math import sqrt
|
from math import sqrt
|
||||||
|
|
||||||
|
time1 = Blender.sys.time()
|
||||||
|
|
||||||
VRemNum = ERemNum = FRemNum = 0 # Remember for statistics
|
VRemNum = ERemNum = FRemNum = 0 # Remember for statistics
|
||||||
|
|
||||||
|
|
||||||
@@ -112,7 +115,7 @@ def delFreeVert(mesh):
|
|||||||
vIdx = 0
|
vIdx = 0
|
||||||
for bool in usedList:
|
for bool in usedList:
|
||||||
if bool == False:
|
if bool == False:
|
||||||
mesh.verts.remove(mesh.verts[vIdx])
|
mesh.verts.pop(vIdx)
|
||||||
vIdx -= 1
|
vIdx -= 1
|
||||||
VRemNum += 1
|
VRemNum += 1
|
||||||
vIdx += 1
|
vIdx += 1
|
||||||
@@ -124,7 +127,7 @@ def delEdge(mesh):
|
|||||||
fIdx = 0
|
fIdx = 0
|
||||||
while fIdx < len(mesh.faces):
|
while fIdx < len(mesh.faces):
|
||||||
if len(mesh.faces[fIdx].v) == 2:
|
if len(mesh.faces[fIdx].v) == 2:
|
||||||
mesh.faces.remove(mesh.faces[fIdx])
|
mesh.faces.pop(fIdx)
|
||||||
ERemNum += 1
|
ERemNum += 1
|
||||||
fIdx -= 1
|
fIdx -= 1
|
||||||
fIdx +=1
|
fIdx +=1
|
||||||
@@ -136,7 +139,7 @@ def delEdgeLen(mesh, limit):
|
|||||||
while fIdx < len(mesh.faces):
|
while fIdx < len(mesh.faces):
|
||||||
if len(mesh.faces[fIdx].v) == 2:
|
if len(mesh.faces[fIdx].v) == 2:
|
||||||
if measure(mesh.faces[fIdx].v[0].co, mesh.faces[fIdx].v[1].co) <= limit:
|
if measure(mesh.faces[fIdx].v[0].co, mesh.faces[fIdx].v[1].co) <= limit:
|
||||||
mesh.faces.remove(mesh.faces[fIdx])
|
mesh.faces(fIdx)
|
||||||
ERemNum += 1
|
ERemNum += 1
|
||||||
fIdx -= 1
|
fIdx -= 1
|
||||||
fIdx +=1
|
fIdx +=1
|
||||||
@@ -148,7 +151,7 @@ def delFaceArea(mesh, limit):
|
|||||||
while fIdx < len(mesh.faces):
|
while fIdx < len(mesh.faces):
|
||||||
if len(mesh.faces[fIdx].v) > 2:
|
if len(mesh.faces[fIdx].v) > 2:
|
||||||
if faceArea(mesh.faces[fIdx]) <= limit:
|
if faceArea(mesh.faces[fIdx]) <= limit:
|
||||||
mesh.faces.remove(mesh.faces[fIdx])
|
mesh.faces.pop(fIdx)
|
||||||
FRemNum += 1
|
FRemNum += 1
|
||||||
fIdx -= 1
|
fIdx -= 1
|
||||||
fIdx +=1
|
fIdx +=1
|
||||||
@@ -203,7 +206,7 @@ else:
|
|||||||
|
|
||||||
mesh.update(0)
|
mesh.update(0)
|
||||||
Redraw()
|
Redraw()
|
||||||
|
print 'mesh cleanup time',Blender.sys.time() - time1
|
||||||
if is_editmode: Window.EditMode(1)
|
if is_editmode: Window.EditMode(1)
|
||||||
|
|
||||||
if method != -1:
|
if method != -1:
|
||||||
|
|||||||
@@ -135,7 +135,7 @@ def save_obj(filename):
|
|||||||
# modify the open file.
|
# modify the open file.
|
||||||
for f in m.faces:
|
for f in m.faces:
|
||||||
if len(f.v) < 3:
|
if len(f.v) < 3:
|
||||||
mesh.faces.remove(f)
|
m.faces.remove(f)
|
||||||
|
|
||||||
if len(m.faces) == 0: # Make sure there is somthing to write.
|
if len(m.faces) == 0: # Make sure there is somthing to write.
|
||||||
continue #dont bother with this mesh.
|
continue #dont bother with this mesh.
|
||||||
|
|||||||
@@ -497,14 +497,13 @@ def load_obj(file):
|
|||||||
|
|
||||||
Window.FileSelector(load_obj, 'Import Wavefront OBJ')
|
Window.FileSelector(load_obj, 'Import Wavefront OBJ')
|
||||||
|
|
||||||
'''
|
|
||||||
# For testing compatability
|
# For testing compatibility
|
||||||
import os
|
#import os
|
||||||
for obj in os.listdir('/obj/'):
|
#for obj in os.listdir('/obj/'):
|
||||||
if obj[-3:] == 'obj':
|
# if obj[-3:] == 'obj':
|
||||||
print obj
|
# print obj
|
||||||
newScn = Scene.New(obj)
|
# newScn = Scene.New(obj)
|
||||||
newScn.makeCurrent()
|
# newScn.makeCurrent()
|
||||||
load_obj('/obj/' + obj)
|
# load_obj('/obj/' + obj)
|
||||||
|
|
||||||
'''
|
|
||||||
|
|||||||
Reference in New Issue
Block a user