I have a VRML version of a PDB file imported into Blender.
Every geometric segment has its own material assigned even though the materials are identical. Can I select the objects by color instead of by material?
Asked
Active
Viewed 1,059 times
1
-
I'm not familiar with this kind of imported file, but is your molecule all represented by a single mesh? If yes, maybe this scripted approach could help. – Nicola Sap Sep 05 '17 at 15:51
-
2There is no such thing as "colors" in Blender, only materials. Could you clarify what you are trying to do, maybe post some screenshots – Duarte Farrajota Ramos Sep 05 '17 at 23:53
-
The answer is no, however you can group them to the same vertex group so that you can select them more easily later on. – J Sargent Sep 06 '17 at 00:42
-
I opened the PDB file (these are representations of proteins) in Pymol changed the representation to "ribbon" with one color and "saved image as VRML2". When I import this into Blender it comes in as thousands of tiny segments and spheres, each with its own material, but all are the same color (e.g. red 1.0, blue 1.0, green 0.0). When I join them into a single mesh there are thousands of material slots, all identical. I actually wanted to make the mesh semi transparent, (sorry for being unclear). So I used material util add on, removed all slots and made one new one. Thanks for your help! – Elyz Sep 06 '17 at 21:07
1 Answers
1
This simple script loops through the visible objects, and checks if the active object's diffuse color (blender internal) matches. If they do match, then that object gets selected.
Make sure the active object has a material with the color you want to merge. Then load the script below in blender's text editor and hit "Run Script".
After you run the script all you need to do is press CrtlL then M. Or from the 3D view header Object > Make Links... > Materials.
import bpy
active = bpy.context.scene.objects.active
bpy.ops.object.select_all(action='DESELECT')
for obj in bpy.context.visible_objects:
if obj.type == "MESH":
if obj.data.materials[0].diffuse_color == active.data.materials[0].diffuse_color:
obj.select = True
active = bpy.context.selected_objects[0]
David
- 49,291
- 38
- 159
- 317