Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Recent
    • Tags
    • Users
    • Login

    Multiple of single plugin

    Scheduled Pinned Locked Moved PYTHON Development
    6 Posts 0 Posters 471 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

      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!

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

        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

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

          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.

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

            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?

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

              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

              1 Reply Last reply Reply Quote 0
              • H Offline
                Helper
                last edited by

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

                That works! Thank you for your help Niklas.

                -Shawn

                1 Reply Last reply Reply Quote 0
                • First post
                  Last post