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

    texture tag re-name with assigned material name

    Plugin Requests
    0
    3
    1.4k
    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 21/07/2017 at 05:09, xxxxxxxx wrote:

      Hello,
      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.

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

        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..

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

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

          Hi,

          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;
          	mat->GetParameter(ID_MATERIALASSIGNMENTS, d, DESCFLAGS_GET_0);
          	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)
          			continue;
          		if (atom->IsInstanceOf(Ttexture))
          		{
          			BaseTag* tag = static_cast<BaseTag*>(atom);
          			BaseObject* const op = tag->GetObject();
          			// do something here...
          		}
          	}
          
          1 Reply Last reply Reply Quote 0
          • First post
            Last post