Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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

    Truncate Selection Tag Names

    Plugin Requests
    0
    4
    1.7k
    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 06/02/2018 at 05:18, xxxxxxxx wrote:

      I'm looking for a very specific script...

      1. parse through all selection tags in a scene
      2. for each tag, if name contains one or more underscore characters ("_"), then truncate the first underscore character and all others after it
      3. done

      example:

      rename selection tag named polishedMetal_obj_imported to just simply polishedMetal

      I've made a very lame attempt at writing this script, but, alas, I'm not a coder.  But I do import a lot of OBJ files and I can't figure out how to make the R19 importer stop appending suffixes to the tag names (related to name collisions i think).  So, a script such as this would save me a lot of copy/paste/rename tool repetition.

      Thanks for reading...hoping an experienced coder will help me out.

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

        On 07/02/2018 at 09:29, xxxxxxxx wrote:

        Hi,

        there sure are a bunch of members in our community, who should be able to help you out easily. We here in MAXON's SDK Team can not (or, maybe better, are not supposed to) deliver complete solutions.
        But of course we can try to guide you through the process. So maybe you can post your "lame attempt" (your words) and we can push you into the right direction.

        The basic building blocks are as follows (maybe that's already enough to get you started) :

        1. Iterate through the scene hierarchy to visit every object. This can be done recursively[URL-REMOVED] and non-recursively[URL-REMOVED].
        2. For every object start with the first tag (GetFirstTag()) and loop over all others (GetNext()).
        3. For every tag of wanted type (GetType()) and/or name (GetName()), set a new name (SetName()).

        [URL-REMOVED] @maxon: This section contained a non-resolving link which has been removed.

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

          On 08/02/2018 at 09:13, xxxxxxxx wrote:

          lol, yeah my attempt certainly didnt get as far as your general steps.  I'll give it another attempt. Sure wish I was a good coder...question: could you link me to cineversity beginner course in python perhaps?

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

            On 09/02/2018 at 02:49, xxxxxxxx wrote:

            I'm not sure I understand you last question.
            You can easily search Cineversity for "Python" and will find quite a bunch of tutorials, for example this "Introduction to Python in C4D". This tutorial is not free, though, but requires a Cineversity Premium membership (either booked directly on Cineversity or via a valid MSA contract). This is nothing we can help with here at SDK Support, sorry.

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