Plugin Cafe Homepage
Forum Home Forum Home > Plugin Cafe > Plugin Requests
  New Posts New Posts
  FAQ FAQ  Forum Search   Register Register  Login Login

Truncate Selection Tag Names

 Post Reply Post Reply
Author
Message
PerryM View Drop Down
Member
Member
Avatar

Joined: 2010 Apr 01
Online Status: Offline
Posts: 4
Post Options Post Options   Quote PerryM Quote  Post ReplyReply Direct Link To This Post Topic: Truncate Selection Tag Names
    Posted: 2018 Feb 06 at 5:18am
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.
Back to Top
Andreas Block View Drop Down
Forum Moderator
Forum Moderator
Avatar

Joined: 2014 Oct 01
Location: Hannover
Online Status: Offline
Posts: 1822
Post Options Post Options   Quote Andreas Block Quote  Post ReplyReply Direct Link To This Post Posted: 2018 Feb 07 at 9:29am
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()).

Cheers,
Andreas
SDK Support Engineer
Back to Top
PerryM View Drop Down
Member
Member
Avatar

Joined: 2010 Apr 01
Online Status: Offline
Posts: 4
Post Options Post Options   Quote PerryM Quote  Post ReplyReply Direct Link To This Post Posted: 2018 Feb 08 at 9:13am
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?
Back to Top
Andreas Block View Drop Down
Forum Moderator
Forum Moderator
Avatar

Joined: 2014 Oct 01
Location: Hannover
Online Status: Offline
Posts: 1822
Post Options Post Options   Quote Andreas Block Quote  Post ReplyReply Direct Link To This Post Posted: 2018 Feb 09 at 2:49am
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.

Cheers,
Andreas
SDK Support Engineer
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Bulletin Board Software by Web Wiz Forums® version 9.61 [Free Express Edition]
Copyright ©2001-2009 Web Wiz

This page was generated in 0.094 seconds.