I’ve been using the script below in Blender 2.49. It was posted some time ago by some kind person, but I’m afraid I’ve forgotten where. What it does is allow you to select objects with the same material rgb colour. The problem I’ve got is that firstly even though I’ve put the script file in the scripts folder (C:\Users\XXX\AppData\Roaming\Blender Foundation\Blender\2.57\scripts\addons) I can’t see it in Blender when I go to User Preferences and look under Add-ons.
If I try to run the script under Text Editor then it highlights the line 'from Blender import Redraw ’ in red.
What do I need to change to get this script working?
I’m using Blender 2.57 and Windows 7.
Thanks in advance.
#!BPY
“”"
Name: ‘Select Colour’
Blender: 249
Group: ‘Add’
Tooltip: ‘Selects objects with the same RGB colour’
“”"
import bpy
from Blender import Redraw
from Blender.Draw import PupMenu as P
def main():
sce = bpy.data.scenes.active
ref_ob = sce.objects.active
if not ref_ob: P(“Error%t|No active object”);return
if ref_ob.type != “Mesh”: P(“Error%t|Active object is no mesh”);return
if len(sce.objects.selected)>1: P(“Error%t|More than 1 object selected”);return
ref_mat = ref_ob.getMaterials()
if not ref_mat:
me = ref_ob.getData(False, True)
ref_mat = me.materials
if not ref_mat[0]: P(“Error%t|Mesh has no material”);return
ref_mat_col = [mat.getRGBCol() for mat in ref_mat]
obs = [ob for ob in sce.objects if ob.type == “Mesh”]
for ob in obs:
mat = ob.getMaterials()
if not mat: mat = ob.getData(False,True).materials
if mat[0]:
mat_col = [mat.getRGBCol() for mat in mat]
if mat_col == ref_mat_col: ob.sel = True
sce.objects.active = ref_ob
Redraw()
main()