texture tag re-name with assigned material name

On 21/07/2017 at 05:09, xxxxxxxx wrote:

Is there a script which will automatically rename all selected texture tags so they have the same name as their assigned material?

I'm trying to select all my texture tags with specific material assignment and they are all over the place in different heirarchies, its tricky! this script would help a lot.

On 21/07/2017 at 05:18, xxxxxxxx wrote:

just realising I could select the material, then click "Select texture tags / objects".. spoke before I thought.. wondering if theres any use for such a script now..

On 24/07/2017 at 02:32, xxxxxxxx wrote:


I guess, the actual question was not so much about the renaming (BaseList2D::SetName()).
So it's probably more about iterating the hierarchy. In the GeListNode manual there's a code snippet demonstrating how to recursively iterate a tree (in this case the object tree). With this such a script should be quite easy to accomplish.

Another option is to use the material assignment data you can get from a material (basically what's used for the "Select texture tags / objects..." command) :

	GeData d;
	MatAssignData* const mad = static_cast<MatAssignData*>(d.GetCustomDataType(CUSTOMDATATYPE_MATASSIGN));
	if (mad == nullptr)
		return false;
	const Int32 cnt = mad->GetObjectCount();
	for (Int32 idx = 0; idx < cnt; ++idx)
		C4DAtom* atom = mad->ObjectFromIndex(document, idxTag);
		if (atom == nullptr)
		if (atom->IsInstanceOf(Ttexture))
			BaseTag* tag = static_cast<BaseTag*>(atom);
			BaseObject* const op = tag->GetObject();
			// do something here...