Get description of types of a group of objects ("1 point, 2 curves...")

If I have a list of objects, is there an easy way to get the text description of their types as in the title? This is the same output as the added to/removed from selection objects feedback.

make sure to set the typehint to “no type hint” :upside_down_face:

Sorry if I wasn’t clear. This is for a python script. I want to mimic the default Rhino behavior of displaying, e.g. 1 point, 2 curves, 1 polysurface added to selection when you select objects. I have a list (in python) of the objects that were selected, and I want to get the text string to print out. I could code my own method for this, but I was wondering if there was API access to the native method.

I’m not aware of an easy API thing (but that doesn’t mean there isn’t one). Here’s my attempt at doing this.

object_type_text.py (2.2 KB)

1 Like

Thanks! Very similar to what I had come up with.

def count_types(objects):
	if len(objects) == 0: return "No objects"
	type_dict = {
		0:			"unknown object",
		1:			"point",
		2:			"point cloud",
		4:			"curve",
		8:			"surface",
		16:			"polysurface",
		32:			"mesh",
		256:		"light",
		512:		"annotation",
		4096:		"block instance",
		8192:		"text dot",
		16384:		"grip object",
		32768:		"detail",
		65536:		"hatch",
		131072:		"morph control",
		262144:		"subD object",
		134217728:	"cage",
		268435456:	"phantom object",
		536870912:	"clipping plane",
		1073741824:	"extrusion"
	}
	count_dict = {}
	for obj in objects:
		type = rs.ObjectType(obj)
		if type not in count_dict:
			count_dict[type] = 0
		count_dict[type] += 1
	s = ""
	for type in sorted(count_dict):
		count = count_dict[type]
		type_str = type_dict[type]
		s += str(count)
		s += ' '
		s += type_str
		if count > 1: s += 'es' if type_str in ("mesh") else 's'
		s += ', '
	return s[:-2]
2 Likes