This is a bulk select script I’ve knocked up. You can select by name (inl prefix and suffix) data name, data type and layer. It only works in blender 2.37.
I havent tested it heavily yet, so I would appreciate some feedback. If you find it useful, or want soem new features, left me know.
#!BPY
"""
Name: 'Batch select'
Blender: 237
Group: 'Object'
Tip: 'Apply the chosen rule to select multiple objects all at once.'
"""
__author__ = "Zenoscope"
__url__ = ("blender", "elysiun","www.animate.8k.com")
__version__ = "1.0"
__bpydoc__ = """\
This script is to select multiple objects by name,data name, layer or type (camera, light etc)
"""
# --------------------------------------------------------------------------
# Batch Select by Zenoscope ver 0.1
# --------------------------------------------------------------------------
# ***** BEGIN GPL LICENSE BLOCK *****
#
# 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 2
# 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, write to the Free Software Foundation,
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# ***** END GPL LICENCE BLOCK *****
# --------------------------------------------------------------------------
#ideas for 0.2
# change the behaviour so you can choose to over-write the old selection or keep it,
# maybe with an add to selection/don't menu item
# right now it just adds to the selection. Shouldn't be too hard to add this
from Blender import *
def selectLayer():
# select objects by layer
global gObjects
# make a menu for the layers.
# maybe hack this to show only layers with objects in it
layerStr=""
for layers in range(1,21):
layerStr = layerStr + "|Layer " + str(layers)
# this is the closest approximation to the blender layers menu I could get. 2 just isn't pretty.
result=Draw.PupMenu("Select A Layer%t" + layerStr,5)
if result == -1: # mouse out
pass
else:
for ob in gObjects:
if ob.layers[0] == result:
ob.sel=1
def selectType():
# select objects by type.
# the list only generates objects that are in the scene.
global gObjects
pupString = "select%t" # start bulting the menu
typeIndex = [] # index to store the object types in
for ob in gObjects:
#make list of the objects.
obStr=ob.getType()
# if the objectType isn't already recorded in the list(s) then add it, otherwise ignore it.
if pupString.find(obStr) == -1:
pupString = pupString + "|"+ obStr
typeIndex.append(obStr)
print typeIndex
# draw the menu
result = Draw.PupMenu(pupString)
if result == -1: # mouse out
pass
elif result > 0:
#loop through all of the objects, checking the types.
result=result - 1
for ob in gObjects:
#if the oject matches the type, then
if ob.getType() == typeIndex[result]:
# select that object
ob.select(1)
def selectObject(lookFor):
global gObjects
#wack up a popup to look for stuff.
findThis = Draw.PupStrInput("Object " + lookFor +":","",20)
if findThis == None: return # empty string
for ob in gObjects: #loop through all of the objects,
checkMe = ob.name # take down its name
if lookFor == "name":
# if the name contains findThis
if checkMe.find(findThis) == 0:
print "partial name found - " + checkMe
# select it.
ob.select(1)
elif lookFor == "suffix":
# i dunno, for some reason this only works right if it is != 0...?
# non-matches being -1
# if the name ends with findThis
if checkMe.endswith(findThis) != 0:
# select it.
ob.select(1)
elif lookFor == "prefix":
# if the name starts with findThis
if checkMe.startswith(findThis) != 0:
# select it.
ob.select(1)
def selectData(lookFor):
global gObjects
#wack up a popup to look for stuff.
findThis = Draw.PupStrInput("Data " + lookFor +":","",20)
if findThis == None: return # empty string
for ob in gObjects:
# get the name of the data block
checkMe = ob.getData(1)
# if its not an empty...
if str(type(checkMe)) != "<type 'NoneType'>":
#find it!
if lookFor == "name":
if checkMe.find(findThis) == 0:
print "partial name found - " + checkMe
ob.select(1)
elif lookFor == "suffix":
# i dunno, for some reason this only works right if it is != 0...?
# non-matches being -1
if checkMe.endswith(findThis) != 0:
ob.select(1)
elif lookFor == "prefix":
if checkMe.startswith(findThis) != 0:
ob.select(1)
# start of main code
global gObjects
# get the names of everything once.
gObjects=Object.Get()
name = "select%t|Object name contains|Object name prefix|Object name suffix|Data name contains|Data name prefix|Data name suffix|Layers|Object Types" #material names....
result = Draw.PupMenu(name)
if result == -1:
pass
elif result == 1:
selectObject("name")
elif result == 2:
selectObject("prefix")
elif result == 3:
selectObject("suffix")
elif result == 4:
selectData("name")
elif result == 5:
selectData("prefix")
elif result == 6:
selectData("suffix")
elif result == 7:
selectLayer()
elif result == 8:
selectType()