Debugging TagPlugin



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

    On 07/04/2011 at 19:00, xxxxxxxx wrote:

    I'm trying to get feed back from my tag plugin, via print or MessageDialog.  C4D is giving me zero feed back and I'm not sure if my code is even executed.

    I'm using R12, any help would be appreciated.

    import c4d
    from c4d import plugins
    from c4d import gui

    PLUGIN_ID = 1234567890

    class AnimationCacheTag(plugins.TagData) :

    def Execute(self, tag, doc, op, bt, priority, flags) :
            '''Run the tag code'''

    time = doc.GetTime()
            fps = doc.GetFps()

    if(fps > 0) :
                currentFrame = time / fps
                msg = 'Current frame is: {0}'.foramt(currentFrame)
                print(msg)
                c4d.gui.MessageDialog(msg)

    return c4d.EXECUTIONRESULT_OK

    if __name__ == "__main__":
        plugins.RegisterTagPlugin(id=PLUGIN_ID, str="Animation Cache Tag", g=AnimationCacheTag,
                                        description="IDD_CACHEDIALOG", icon=None,
                                        info=c4d.TAG_VISIBLE)



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

    On 07/04/2011 at 23:59, xxxxxxxx wrote:

    Hello ReptileCoder,

    doc.GetTime() return type is BaseTime.

    Do that instead:

      
    time = doc.GetTime();  
    fps = doc.GetFps()  
    frame = time.GetFrame(fps);  
      
    msg = 'Current Frame is:' +str(time2)  
    print(msg)  
    


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

    On 08/04/2011 at 02:25, xxxxxxxx wrote:

    @ReptileCoder: Calling the GUI from a tag thread is not allowed and can lead to crashs. The GUI should only be called from the main thread. There are some minor functions which allow this and they are documentated.



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

    On 08/04/2011 at 10:59, xxxxxxxx wrote:

    Thanks Nt2005.  I was able to run the frame code in a Python script and get it working, I appreciate your help.

    s_rath, thank you for the info on the dangers of calling the GUI from a tag.  What I would like to do, is get debug feed back from the tag code.  And currently it appears that the Execute() method of my tag is not getting called.  So I am unsure how tag code works, and the Python documentation is a little light.



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

    On 08/04/2011 at 11:18, xxxxxxxx wrote:

    Btw, you should add the TAG_EXPRESSION flag in RegisterTagPlugin.

    info=c4d.TAG_VISIBLE|c4d.TAG_EXPRESSION



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

    On 08/04/2011 at 11:26, xxxxxxxx wrote:

    Adding  |c4d.TAG_ EXPRESSION to the RegisterTagPlugin method did it.  Now my print statements are working.
    Thank you s_rath!

    solution:
    import c4d
    from c4d import plugins

    PLUGIN_ID = 1234567890

    class AnimationCacheTag(plugins.TagData) :

    def Execute(self, tag, doc, op, bt, priority, flags) :
            '''Run the tag code'''

    fps = doc.GetFps()
            currentFrame = doc.GetTime().GetFrame(fps)
            msg = 'Current frame is: {0}'.format(currentFrame)
            print(msg)

    return c4d.EXECUTIONRESULT_OK

    if __name__ == "__main__":
        plugins.RegisterTagPlugin(id=PLUGIN_ID, str="Animation Cache Tag", g=AnimationCacheTag,
                                        description="IDD_CACHEDIALOG", icon=None,
                                        info=c4d.TAG_VISIBLE |c4d.TAG_EXPRESSION )


Log in to reply