Material Being Used

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.


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.