CreateLayout in ObjectPlugin without res file



  • On 06/08/2013 at 07:08, xxxxxxxx wrote:

    Hi. Probably silly question, but I cannot figure out how to create layout without res file:
    Am I missing something? Thank you.

      
    import c4d   
    from c4d import gui, plugins, utils   
    import os, random   
      
    PLUGIN_ID = 3333333   
    PLUGIN_NAME = "pluginname"   
    PLUGIN_DESCRIPTION = "Opluginname"   
      
    class MYPLUGIN(c4d.plugins.ObjectData) :   
        def CreateLayout(self) :   
            self.SetTitle("My Dialog")   
            self.GroupBegin(id=100010, flags=0, cols=1, rows=1)   
            self.AddGroupSpace(4, 4)   
            self.AddGroupBorderSpace(4, 4, 4, 4)   
            self.AddStaticText(id=100011, flags=0, name="Hello World!")   
            self.GroupEnd()   
            return True   
      
    if __name__ == '__main__':   
        bmp = c4d.bitmaps.BaseBitmap()   
        dir, file = os.path.split(__file__)   
        fn = os.path.join(dir, "res", "Icon.tif")   
        bmp.InitWith(fn)   
        result = plugins.RegisterObjectPlugin(   
            id=PLUGIN_ID, str=PLUGIN_NAME, g=MYPLUGIN, description="", info=c4d.OBJECT_GENERATOR, icon=bmp   
        )   
      
    


  • On 06/08/2013 at 07:24, xxxxxxxx wrote:

    Hi Tomas,

    There's no CreateLayout() for data plugins. You can only use .res files description.
    Do not confound descriptions and dialogs. CreateLayout() is only defined for dialogs.



  • On 06/08/2013 at 07:25, xxxxxxxx wrote:

    I see. I thought so:)
    Thanks for clearing this out for me. Appreciate that.



  • On 06/08/2013 at 08:53, xxxxxxxx wrote:

    On the other hand, if I build buy GUI in res file, can I make some elements greyed out, depending on what settings/buttons are pressed by user?



  • On 06/08/2013 at 08:59, xxxxxxxx wrote:

    Originally posted by xxxxxxxx

    On the other hand, if I build buy GUI in res file, can I make some elements greyed out, depending on what settings/buttons are pressed by user?

    Yes, you can override NodeData.GetDEnabling() and depending on the passed id return True to enable or False to disable the description parameter.
    Here's how it's implemented in Py-DoubleCircle example:

    def GetDEnabling(self, node, id, t_data, flags, itemdesc) :
            data = node.GetDataInstance()
            if data is None: return
            
            inter = data.GetLong(c4d.SPLINEOBJECT_INTERPOLATION)
            if id[0].id==c4d.SPLINEOBJECT_SUB:
                return inter==c4d.SPLINEOBJECT_INTERPOLATION_NATURAL or inter==c4d.SPLINEOBJECT_INTERPOLATION_UNIFORM
            elif id[0].id==c4d.SPLINEOBJECT_ANGLE:
                return inter==c4d.SPLINEOBJECT_INTERPOLATION_ADAPTIVE or inter==c4d.SPLINEOBJECT_INTERPOLATION_SUBDIV
            elif id[0].id==c4d.SPLINEOBJECT_MAXIMUMLENGTH:
                return inter==c4d.SPLINEOBJECT_INTERPOLATION_SUBDIV
            
            return True
    


  • On 06/08/2013 at 09:02, xxxxxxxx wrote:

    Oh ok, that makes a lot of sense. Will investigate your code. Thanks for your input.


Log in to reply