Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware 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
    • Register
    • Login

    Get CustomGUI Data in python

    Cinema 4D SDK
    python c++ r20 sdk
    3
    9
    1.1k
    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.
    • N
      neon
      last edited by

      Hello plugincafe!
      I have recently created a customgui using the example customgui plugin. The only major thing that I changed, appart from drawing, is that I save a single float value.
      I now need to implement this custom gui into a python plugin but I can't seem to find out how to retrieve my saved data from the gui element.

      Do I need to completely switch to a c++ plugin to do this, or is there a way in python.

      Kind Regards,
      Florian

      1 Reply Last reply Reply Quote 0
      • M
        m_adam
        last edited by

        Hi if your data type is already a know python type you shouldn't have any issue and could use the BaseCustomGui.GetData / BaseCustomGui.SetData.

        So if we take the C++ example of the String Custom GUI.
        You can use it in Python like bellow:

        import c4d
        
        ID_CUSTOM_GUI = 1001
        ID_BUTTON_DO = 1002
        
        class myCustomGuiDlg(c4d.gui.GeDialog):
            
            def CreateLayout(self):
                
                self._customGui = self.AddCustomGui(ID_CUSTOM_GUI, 1034655, 'my value', c4d.BFH_SCALEFIT, 50, 10)
                self.AddButton(ID_BUTTON_DO,c4d.BFH_SCALEFIT,name = 'Get Data')
                return True
            
            def InitValues(self):
                self._customGui.SetData("Some custom text")
                return True
            
            
            def Command(self, id, msg):
                if id == ID_BUTTON_DO:
                    print self._customGui.GetData()
                    
                return True
            
        
        if __name__=='__main__':
            dlg = myCustomGuiDlg()
            dlg.Open(c4d.DLG_TYPE_ASYNC)
        

        Cheers,
        Maxime.

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        1 Reply Last reply Reply Quote 1
        • N
          neon
          last edited by

          Hello Maxime,
          thanks for you answer!
          I actually have my custom gui not in a GeDialog but inside a res file of an ObjectData. How would I be able to access the customgui from there?

          Best Regards,
          Florian

          1 Reply Last reply Reply Quote 0
          • S
            s_bach
            last edited by

            In an ObjectData plugin, you don't access GUIs. You access parameters. So what is the parameter type that is using your custom GUI? Can you show your *.res file?

            MAXON SDK Specialist

            Development Blog, MAXON Registered Developer

            1 Reply Last reply Reply Quote 0
            • N
              neon
              last edited by neon

              Hello Sebastian,
              basically I have something like this

              [...]
              MY_CUSTOMGUI CUSTOMGUIPARAM { }
              [...]

              that is what I use.

              1 Reply Last reply Reply Quote 0
              • S
                s_bach
                last edited by

                Sorry, but this is not how it works. A NodeData's res file looks like this:

                STRING ID_RESULT_TEXT  { CUSTOMGUI MULTISTRING; ANIM OFF; }
                

                The first symbol is the data type (STRING), the second the parameter ID, The custom GUI can be found after the CUSTOMGUI keyword.

                So in your case, MY_CUSTOMGUI is NOT a custom GUI. It is a custom data type. Is that correct?

                MAXON SDK Specialist

                Development Blog, MAXON Registered Developer

                1 Reply Last reply Reply Quote 0
                • N
                  neon
                  last edited by

                  oh... yeah that is true.

                  I edited the customdata_customgui example to fit my needs. (mainly only the drawing).
                  So I guess I would have to change my customdata to a REAL customgui?

                  1 Reply Last reply Reply Quote 0
                  • S
                    s_bach
                    last edited by

                    Please make sure you understand the difference between a data type and a GUI. A data type stores data of some type. A GUI displays that data and allows interaction with that data in the UI. But it does not persistently store the data.

                    So if you want to have a parameter in your object that stores a float value, just use a REAL parameter. You can display that parameter in the UI using a custom GUI element. See for example customgui_string.cpp.

                    best wishes,
                    Sebastian

                    MAXON SDK Specialist

                    Development Blog, MAXON Registered Developer

                    1 Reply Last reply Reply Quote 1
                    • N
                      neon
                      last edited by

                      Hello Sebastian,
                      I now understand what the difference is, thank you very much!
                      With the customdata_customgui example file I actually made both a GUI and a custom DataType. So I only needed to change my resource file and modifiy my data code a bit!

                      Best Regards,
                      Florian

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