Convert int ID back into string representation ?



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 10/12/2012 at 05:15, xxxxxxxx wrote:

    hi,

    i have got a quite simple question again. is there a way to convert a plugin or basecontainer
    ID from their integer form back into the alphanummeric form defined in the header files ? i want
    to pass an integer and get back a string representation of that integer.

    thanks for your help :)



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 10/12/2012 at 06:00, xxxxxxxx wrote:

    Well, it's technically possible, but you could end up with multiple symbol-names. You'd
    need a basecase for the symbol-detection, e.g. when you only want to reach
    plugin-symbols, you could use a regular expression like this:

    import re  
    import c4d  
      
    plugExpr = re.compile('[A-Z]\w+')  
      
    def find_keys(dct, value, filter=lambda x: True) :  
      for k, v in dct.iteritems() :  
          if v == value and filter(k) :  
              yield k  
      
    symbols = find_keys(vars(c4d), c4d.Obase, plugExpr.match)  
    for k in symbols:  
      print k  
    print '-' * 30
    

    Best,
    Niklas



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 10/12/2012 at 08:10, xxxxxxxx wrote:

    i do not want to sound ungrateful, but if i have understood your example correctly, you suggest
    serializing the class into a dictionary and then poke with a regEx in the remains ? i have tried your 
    example with with Olight and it works for the plugin id as you said, but the returned bc content 
    was utter nonsense.

    i was so naive to believe, that there might be a less painfull way to do this :) isn't the symbol
    cache file just a cached version of all header files to do this translation , or am i worng ?


Log in to reply