Multiple of single plugin



  • On 31/12/2013 at 11:54, xxxxxxxx wrote:

    Is it possible to have a python plugin be able to open more than once? For example: If I have a simple plugin that checks specifics of a folder and its files and I want to check another folder but keep the other one open. It would be nice to just run the plugin again and have that second window.

    If that's not possible how could I, using a + button open a duplicate of the window with its resources?

    Any help would be great!



  • On 01/01/2014 at 10:34, xxxxxxxx wrote:

    Hi Shawn,

    just create a new dialog object and open it. You can specify a sub ID that you can use to identify the index
    of the dialog.

    class Command(c4d.plugins.CommandData) :
      
        def __init__(self) :
            super(Command, self).__init__()
            self.dialogs = []
      
        def Execute(self, doc) :
            # Find the first dialog that is not open.
            dialog = None
            index  = -1
            for i, d in self.dialogs:
                if not d.IsOpen() :
                    dialog = d
                    index  = i
      
            if dialog is None:
                index = len(self.dialogs)
                dialog = Dialog()
                self.dialogs.append(dialog)
      
            return dialog.Open(c4d.DLG_TYPE_ASYNC, self.PLUGIN_ID, subid=index)
    

    Best,
    -Niklas



  • On 02/01/2014 at 08:16, xxxxxxxx wrote:

    Thanks for the reply Niklas! I am trying to wrap my head around your bit of code. This is all still new to me, could you explain a little more on how this code works and how to use it so I can understand it better?

    Thanks.



  • On 02/01/2014 at 13:40, xxxxxxxx wrote:

    I think I figured it out. But instead of opening another window I get

    TypeError: 'MyDialog' object is not iterable
    

    Any ideas?



  • On 06/01/2014 at 16:19, xxxxxxxx wrote:

    Hi Shawn,

    sorry the code I posted was not 100% correct.

    class Command(c4d.plugins.CommandData) :
      
        def __init__(self) :
            super(Command, self).__init__()
            self.dialogs = []
      
        def Execute(self, doc) :
            # Find the first dialog that is not open.
            dialog = None
            index  = -1
            for i, d in enumerate(self.dialogs) :
                if not d.IsOpen() :
                    dialog = d
                    index  = i
      
            if dialog is None:
                index = len(self.dialogs)
                dialog = Dialog()
                self.dialogs.append(dialog)
      
            return dialog.Open(c4d.DLG_TYPE_ASYNC, self.PLUGIN_ID, xpos=-2, ypos=-2, subid=index)
    

    Now it is.

    Cheers,
    -Niklas



  • On 06/01/2014 at 17:42, xxxxxxxx wrote:

    That works! Thank you for your help Niklas.

    -Shawn


Log in to reply