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

    Material Being Used

    SDK Help
    0
    2
    851
    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.
    • H
      Helper
      last edited by

      On 24/07/2018 at 09:14, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   R14 
      Platform:   Windows  ; Mac  ;  
      Language(s) :     C++  ;

      ---------
      Is it possible to get whether a material is currently being used in a scene?  In a similar way to how Remove Unused Materials checks, but without the deleting step.

      Dan

      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

        On 25/07/2018 at 02:21, xxxxxxxx wrote:

        Hi Dan,

        You can read the assignment data with the following code

        Bool MyCommand::Execute(BaseDocument* doc)
        {
        	BaseMaterial* mat = doc->GetActiveMaterial();
        	if (mat == nullptr)
        		return true;
          
        	GeData d;
        	if (!mat->GetParameter(DescLevel(ID_MATERIALASSIGNMENTS), d, DESCFLAGS_GET_0))
        		return true;
          
        	MatAssignData *mad = (MatAssignData* )d.GetCustomDataType(CUSTOMDATATYPE_MATASSIGN);
        	if (mad)
        		GePrint(String::IntToString(mad->GetObjectCount()) + " objects");
          
        	return true;
        }
        

        If you have any question, please let me know.
        Cheers,
        Maxime

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