Is there a way to find and select all objects in the scene which are cylinders? Or which contain a mesh of certain number of vertices? Or maybe there are any other properties available for searching?
Well, you can search by object name…
Usually it’s expected that the person creating the scene would name all their objects such that they can search for whatever they need by name, and arrange things into Groups/Collections etc. and then you can use the Outliner and its name search pretty effectively with that pre-planning in place, and there’s a Select Pattern that can select objects by name using a pattern match.
But I can see if you got handed some big scene (maybe imported from somewhere) with lots of objects that you might want to do things like this.
I don’t know of anything built-in or of an add-on specifically with this kind of object search functionality (which totally does not mean it’s not in there or out there somewhere) but it’s pretty straightforward in the Python API to go through all objects and for the ones that are meshes look at properties like total number of verts/edges/faces etc. and then add ones that match some criteria to the current selection, so you could do that manually in the scripting console, or make a basic script, or even build an add-on to provide these features in a more general way.
Primitive mesh objects once created don’t remember their original primitive (cube, cylinder, etc.) apart from maybe still having their default name like Cylinder.001 (which of course you can search for). But Blender scenes often contain a “Cube” that no longer looks anything like a cube! Once created meshes are meshes regardless of what they look like (though you could always write some clever code to look at a mesh and try and decide whether it’s shaped like a cylinder or not, but this could be tricky).
Searching by name is not what I’m looking for.
Maybe something similar to ‘Select Faces by Sides’ available in edit mode exists in object mode? A tool which would go through all objects and select only those which match certain criteria.
So what would your dream list of criteria be to select on?
- Minimum and maximum number of vertices (or edges/faces)
Actually exact number of vertices would be enough
Select object and run script.
import bpy ACT_OBJ = bpy.context.active_object ACT_VRTS = ACT_OBJ.data.vertices SCN_OBJS = [m for m in bpy.context.scene.objects if m.type == 'MESH'] for OBJS in SCN_OBJS: if len(ACT_VRTS) == len(OBJS.data.vertices): OBJS.select_set(state=True)
import bpy ACT_OBJ = bpy.context.active_object ACT_VRTS = ACT_OBJ.data.vertices SCN_OBJS = [m for m in bpy.context.scene.objects if m.type == 'MESH'] for OBJS in SCN_OBJS: if len(ACT_VRTS) == len(OBJS.data.vertices): OBJS.select = True
Wow, thank you!
I found this script is very usefull for me and i want to incorporate it into my right click object menu so each time i need it i just have to select them from popped up menu after i right click my mouse, but i have no coding skill for that to happen.
Is there anybody can tell me how to do that in a very clear step by step instruction?