Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Determine object category (Generator, Deformer, etc.) via Python

    Cinema 4D SDK
    python 2026 2025
    2
    3
    5
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • gheyretG
      gheyret
      last edited by

      Hi everyone, long time no see!

      I'm currently using c4d.utils.ViewportSelect.PickObject to pick the object under the mouse cursor, and then I want to determine which category it belongs to—such as Polygon Object, Deformer, or Generator. I'm referring to the kind of classification used in the Selection Filter, not the c4d.Obase type.

      I thought about manually creating Python lists containing all the IDs for Generators, Deformers, Fields, etc., but that seems cumbersome and hard to maintain.

      So my question is: is there a way to determine which high-level category (like those in the Selection Filter) a given object belongs to?
      12df8354-306e-44b3-9a9a-a589060f9a7a-image.png

      www.boghma.com

      1 Reply Last reply Reply Quote 0
      • M
        m_adam
        last edited by m_adam

        Hey the internal function is not exposed in Python neither in C++. Sadly the function also use a function that is only exposed in C++ with no proper workaround.

        Here is the C++ implementation of the function

        inline cinema::OBJECTCATEGORY ObjectToCategory(const cinema::BaseObject& object)
        {
        	return ObjectToCategory(object.GetType(), object.GetInfo());
        }
        
        inline cinema::OBJECTCATEGORY ObjectToCategory(cinema::Int32 type, cinema::Int32 objectInfo)
        {
        	cinema::OBJECTCATEGORY category = cinema::OBJECTCATEGORY::OTHER;
        
        	switch (type)
        	{
        		case Oweighteffector:	category = cinema::OBJECTCATEGORY::DEFORMER;		break; // FIX[4850]
        		case Ojoint:					category = cinema::OBJECTCATEGORY::JOINT;				break; // FIX[4853]
        		case Onull:						category = cinema::OBJECTCATEGORY::NULLOBJECT;	break;
        		case Opolygon:				category = cinema::OBJECTCATEGORY::POLYGON;			break;
        		case Osds:						category = cinema::OBJECTCATEGORY::HYPERNURBS;	break;
        		case Ocamera:				
        		case Orscamera:
        			category = cinema::OBJECTCATEGORY::CAMERA; break;
        		case Olight:				
        		case Orslight:
        			category = cinema::OBJECTCATEGORY::LIGHT; 
        			break;
        
        		case Oenvironment:
        		case Oforeground:
        		case Obackground:
        		case Ofloor:
        		case Osky:
        		case Ostage:
        		case Oselection:				category = cinema::OBJECTCATEGORY::SCENE; break;
        
        		case Oworkplane:				category = cinema::OBJECTCATEGORY::GRID; break;
        
        		case 1001414: // ID_TP_PARTICLEGEOMETRY
        		case Ofpgroup: // new particle group
        		case Ofpmultigroup: // new particle multi group
        		case Oparticle:					category = cinema::OBJECTCATEGORY::PARTICLE; break;
        
        		case Ovolume:
        		case Osimulationscene:
        		// ITEM#128166 Alembic: Viewport and Selection Filter recognizes it as Spline
        		case Oalembicgenerator:	category = cinema::OBJECTCATEGORY::GENERATOR; break;
        
        			// ITEM#9437 MoGraph and Spline Display Filter
        		case Omgcloner:					category = cinema::OBJECTCATEGORY::GENERATOR; break; // Omgcloner
        		case Ohair: 						category = cinema::OBJECTCATEGORY::HAIR; break; // Ohair
        
        		default:
        		{
        			// This function is not exposed in Python, so use objectInfo directly
        			if (!cinema::C4DOS_Bo->ObjectTypeToCategory(type, category))
        			{
        				// ITEM#133494 Spline filter doesn't filter splines
        				// i gave ISSPLINE the highest priority back and added switches for alembic and cloner generators above
        				if (objectInfo & OBJECT_ISSPLINE)
        					category = cinema::OBJECTCATEGORY::SPLINE;
        				else if (objectInfo & OBJECT_GENERATOR)
        					category = cinema::OBJECTCATEGORY::GENERATOR;
        				else if (objectInfo & OBJECT_MODIFIER)
        					category = cinema::OBJECTCATEGORY::DEFORMER;
        				else if (objectInfo & OBJECT_PARTICLEMODIFIER)
        					category = cinema::OBJECTCATEGORY::PARTICLE;
        				else if (objectInfo & OBJECT_FIELDOBJECT)
        					category = cinema::OBJECTCATEGORY::FIELD;
        			}
        			break;
        		}
        	}
        
        	return category;
        }
        

        With that's said I've made a note for myself to implement this function in Python (no ETA).
        Cheers,
        Maxime.

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        gheyretG 1 Reply Last reply Reply Quote 1
        • gheyretG
          gheyret @m_adam
          last edited by

          Thank you for the C++ code—it's been very helpful!
          Cheers!

          www.boghma.com

          1 Reply Last reply Reply Quote 0
          • First post
            Last post