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
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    Tutorial: how to create a dialog plugin

    Scheduled Pinned Locked Moved PYTHON Development
    5 Posts 0 Posters 510 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

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

      On 06/12/2012 at 08:56, xxxxxxxx wrote:

      This tutorial will explain how to create a 'floating' dialog using Python.

      What you will learn:

      • Register the plugin
      • Define Tabs
      • Define, read and write a Link field using the AddCustomGui function
      • Define Separators
      • Define, read and write a Combo Box
      • Define and read File Input field using again the AddCustomGui function

      You can download the zip file with the pdf tutorial, the source and the plugin from my blog.

      Everybody on the forum, thanks for your help.

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

        On 01/01/2013 at 06:29, xxxxxxxx wrote:

        Dear users,

        I see this video for create a script for show a dialog, but when i run the script, show me the next message:  "EnvironmmentError: cannot find the pyp file - plugin registration failed".

        I sure that the problem is because i don´t know how to create the pyp file.

        This is my script:

        import c4d
        from c4d import gui
        from c4d import utils
        from c4d import plugins

        PLUGIN_ID=1029596

        #Welcome to the world of Python
        class MiDialogo(c4d.gui.GeDialog) :
            
            def CreateLayout(self) :
                self.element=self.AddStaticText(id=1001,flags=c4d.BFH_LEFT,initw=200, name="Diametro")
                self.element=self.AddEditText(id=1001,flags=c4d.BFH_SCALEFIT|C4D.BFV_SCALEFIT,initw=400,inith=10,name="VDiametro")
            
                return True

        class MyMenuPlugin(c4d.plugins.CommandData) :
                dialog = None
                def Execute(self, doc) :
                #self.dialog=MiDialogo()
                    return MiDialogo.Open(dlgtype=c4d.DLG_TYPE_ASYNC,pluginid=PLUGIN_ID,xpos=-1, ypos=-1,defaultw=200, defaulth=150)

        def RestoreLayout(self, sec_ref) :
                # manage the dialog
                    if self.dialog is None:
                        self.dialog = MyDialog()
                    return self.dialog.Restore(pluginid=PLUGIN_ID, secret=sec_ref)
                
        if __name__=='__main__':
            okyn = plugins.RegisterCommandPlugin(PLUGIN_ID, "Generador de anillos",0,None, "Menu de anillos", MyMenuPlugin())
            if (okyn) :
                print "Inicializado el generador de anillos"
           
        main()

        Thanks.

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

          On 01/01/2013 at 08:47, xxxxxxxx wrote:

          Script?
          Are you trying to run this code in the script manager?
          The code you're using is meant to be put in a .pyp file that sits in your plugins folder.

          There are also some mistakes in your code:
          -Don't use Main() like this in plugins. That's usually a scripting thing.
          -You had a C4D in the AddEditText() function instead of c4d
          -AddEditText() does not have a "name" keyword. Each gizmo has their own parameters. Always check the docs for that.
          -You have self.dialog = MiDialogo() commented out.

          Create a .txt file and paste this code into it:

          import c4d  
          from c4d import gui  
          from c4d import utils  
          from c4d import plugins  
            
          PLUGIN_ID=1029596   
            
          #Welcome to the world of Python  
          class MiDialogo(c4d.gui.GeDialog) :  
              
            def CreateLayout(self) :  
                self.element=self.AddStaticText(id=1001,flags=c4d.BFH_LEFT,initw=200, name="Diametro")  
                self.element=self.AddEditText(id=1002,flags=c4d.BFH_SCALEFIT|c4d.BFV_SCALEFIT,initw=400,inith=10)  
              
                return True  
            
            
          class MyMenuPlugin(c4d.plugins.CommandData) :  
            dialog = None  
            def Execute(self, doc) :  
            # create the dialog  
               if self.dialog is None:  
                  self.dialog = MiDialogo()  
               return self.dialog.Open(dlgtype=c4d.DLG_TYPE_ASYNC, pluginid=PLUGIN_ID, defaultw=200, defaulth=150, xpos=-1, ypos=-1)  
            
            def RestoreLayout(self, sec_ref) :  
            # manage the dialog  
                if self.dialog is None:  
                    self.dialog = MiDialogo()  
                return self.dialog.Restore(pluginid=PLUGIN_ID, secret=sec_ref)  
                  
          if __name__=='__main__':  
            okyn = plugins.RegisterCommandPlugin(PLUGIN_ID, "Generador de anillos",0,None, "Menu de anillos", MyMenuPlugin())  
            if (okyn) :  
                print "Inicializado el generador de anillos"
          

          Then change the file extension from .txt to .pyp. ANd put it in your plugins folder.
          It should run fine after doing that.

          -ScottA

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

            On 01/01/2013 at 09:20, xxxxxxxx wrote:

            Generador de anillos either sounds like something very tasty with loads of garlic or like something making you so drunk that everything is  'very t.asty with loads of garlic' for you. 😂

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

              On 01/01/2013 at 10:54, xxxxxxxx wrote:

              Thanks ScottA, this code run perfectly in the plugin. It´s my first trial in cinema4d programming.

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