Python Tag Plugin Doesn't Work Properly With Resource Files



  • Hello guys,
    I'm a newbie to C4D python script / plugin development and please allow me to ask you guys some points.

    I tried to write a python tag plugin based on "py-look_at_camera_r13" example but I encountered the error like below when I attach the tag this plugin created.

    c4d_error.png

    I looked through this forum and I keep googling but I can't find the proper answer. I think the problem is related to description resource but I'm not familiar with these things. Python plugin development with resource files is pretty confusing...
    So please help me! Any help would be greatly appreciated.

    My code is below.

    text_plugin.pyp

    import os
    import c4d
    
    
    PLUGIN_ID = *******
    
    
    class TestPlugin(c4d.plugins.TagData):
        def Init(self, node):
            self.InitAttr(node, bool, c4d.TESTPLUGIN_ENABLE)
            node[c4d.TESTPLUGIN_ENABLE] = True
            pd = c4d.PriorityData()
            if pd is None:
                raise MemoryError("Failed to create a priority data.")
            pd.SetPriorityValue(c4d.PRIORITYVALUE_CAMERADEPENDENT, True)
            node[c4d.EXPRESSION_PRIORITY] = pd
            return True
    
        def Execute(self, tag, doc, op, bt, priority, flags):
            return c4d.EXECUTIONRESULT_OK
    
    
    if __name__ == "__main__":
        register_check = c4d.plugins.RegisterTagPlugin(id = PLUGIN_ID, str = "Test Plugin", info = c4d.TAG_EXPRESSION | c4d.TAG_VISIBLE, g = TestPlugin, description = "Ttestplugin", icon = None)
        if register_check:
            print("Test Plugin by beatgram")
    
    
    

    c4d_symbols.h

    enum
    {
        // End of symbol definition
        _DUMMY_ELEMENT_
    };
    

    ttestplugin.h

    #ifndef _Ttestplugin_H_
    #define _Ttestplugin_H_
    
    enum
    {
        TESTPLUGIN_ENABLE = 1000
    }
    
    #endif
    

    ttestplugin.str

    STRINGTABLE Ttestplugin
    {
        Ttestplugin "Test Plugin";
        TESTPLUGIN_ENABLE "Enable";
    }
    

    ttestplugin.res

    CONTAINER Ttestplugin
    {
        NAME Ttestplugin;
        INCLUDE Texpression;
    
        GROUP ID_TAGPROPERTIES
    	{
    		BOOL TESTPLUGIN_ENABLE { ANIM ON; }
    	}
    }
    

    Plugin structure

    Test Plugin/
        test_plugin.pyp
        res/
            c4d_symbols.h
            description/
                ttestplugin.h
                ttestplugin.res
            strings_en-US/
                ttestplugin.str
    

    ---------- User Information ----------

    Cinema 4D version: R23
    OS: Windows 10
    Language: Python



  • hi,

    using your content is working perfectly fine here.
    Maybe you could zip the file and set it to us ?

    Does the python examples works on your system ?
    Did you copy/paste the py-look_at_camera directyory or did you create your own hierarchy on your drive ?

    Cheers,
    Manuel.



  • @m_magalhaes Thank you for checking on your end.
    That example code made a same error on my end and I created my own hierarchy on my drive.



  • I double checked my hierarchy / structure and finally I found my mistake!
    The structure below works well and I think it's correct one.

    Test Plugin/
        test_plugin.pyp
        res/
            c4d_symbols.h
            description/
                ttestplugin.h
                ttestplugin.res
            strings_en-US/
                description  -------------------- This folder needed! --------------------
                    ttestplugin.str
    


  • ho yes,

    sorry i created my hierarchy and added that directory without checking yours : /

    Cheers,
    Manuel



  • @m_magalhaes Anyway thanks for the support, Manuel! I love this great community.


Log in to reply