Truncate Selection Tag Names



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



  • 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 and non-recursively.
    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()).


  • 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?



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