Adding python tag to interface



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

    On 14/06/2012 at 07:22, xxxxxxxx wrote:

    I have create my own Python tag, not a plugin but a tag.

    How can I add this tag into Cinema 4d's interface?

    - Pim



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

    On 14/06/2012 at 13:40, xxxxxxxx wrote:

    Ok, I now see my tag in the object manager.
    However, I cannot add it to an object.

    Here the code (all it should do, is print "hello world" when frame =0) :

    import c4d
    import os
    import sys
    from c4d import gui, plugins, bitmaps

    PLUGIN_ID = 1234567880 #test id

    class SayHello(plugins.ToolData) :
      pass  #put in your code here

    def Execute(self, tag, doc, op, bt, priority, flags) :

    frame = doc.GetTime().GetFrame(doc.GetFps())
     
          if (frame == 0) :
              print "Hello World."
         
          return c4d.EXECUTIONRESULT_OK

    if __name__ == "__main__":
      bmp = bitmaps.BaseBitmap()
      dir, file = os.path.split("D:\Program Files\MAXON\CINEMA 4D R13\plugins\hello.pyp")
      fn = os.path.join(dir, "res", "Icon.tif")
      print dir, file
      bmp.InitWith(fn)
     
      #c4d.plugins.RegisterTagPlugin(id, str, info, g, description, icon[, disklevel=0][, res])
      okyn = plugins.RegisterTagPlugin(id=PLUGIN_ID, str="Hello", info=c4d.TAG_VISIBLE, g=SayHello, description=None,  icon=None)
      print "SayHello initialized: ", okyn



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

    On 14/06/2012 at 14:27, xxxxxxxx wrote:

    I changed class SayHello(plugins.ToolData) :
    to class SayHello(plugins.TagData) :
    and now I can add it to an object.

    However, the Icon is not displayed ok, I get aquestion mark (?).
    Also the tag does not seem to get executed.
    On frame == 0, nothing is printed.



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

    On 14/06/2012 at 16:05, xxxxxxxx wrote:

    Hi, you pass icon = None so you don't get an icon.
    The tag must be registered as an expression tag. Pass info = c4d.TAG_VISIBLE | c4d.TAG_EXPRESSION to the register function. Hope that helps.

    Cheers, Sebastian



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

    On 15/06/2012 at 03:54, xxxxxxxx wrote:

    Thanks, it is now working.

    So, 3 issues:
    - c4d.TAG_EXPRESSION needs to be set
    - description directory must be there, although I do not use a user interface
    - reload Python plugins command do not always seem to work (or it might be my messing with directories, etc.)


Log in to reply