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

    [SOLVED]SubDialog Redraw layout && color text

    Scheduled Pinned Locked Moved PYTHON Development
    12 Posts 0 Posters 1.3k 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 01/04/2017 at 09:03, xxxxxxxx wrote:

      Thanks ScottA
      I didn't know we can mannually call the CreateLayout.
      But is it a limiation of the FlusshLayout / LayoutChanged?

      Because normally it should work.

      Is not the case but imagine I only want to update a group with custom data. The only way to do it it's set bool class member for checking if It's in refresh state. And then in CreateLayout do a conditional check based on this variable? It's a bit boring but it's ok

      Thanks for the workaround I finally did the same things but would love to know as you if there is a better way for doing this stuff.

      Anyway thanks you !

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

        On 01/04/2017 at 10:00, xxxxxxxx wrote:

        The LayoutFlushGroup() function deletes the targeted group.
        So if you want it to come back after it's been deleted. You will need to rebuild it again from scratch.
        This can be done by calling the CreateLayout() method. Which will reset(rebuild) everything in the dialog.
        Or
        You can write a custom function that flushes the group, then re-builds the specific group and child gizmos when your button is pressed. Which the most common way I've seen people handle this.

        You might be able to do some simple re-setting tasks by giving your gizmos default values in the Init() method. And then calling Init() and using self.LayoutChanged(your group ID) in your button code.
        But I typically make a custom function whenever I need to change/reset only specific gizmos.

        -ScottA

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

          On 01/04/2017 at 10:13, xxxxxxxx wrote:

          Originally posted by xxxxxxxx

          The LayoutFlushGroup() function deletes the targeted group.
          So if you want it to come back after it's been deleted. You will need to rebuild it again from scratch.
          This can be done by calling the CreateLayout() method. Which will reset(rebuild) everything in the dialog.

          Dammmmmn it's that to code during 20h... You make stupid error... I hate myself... I usually do the thing I did but I mess up an indent wich of course lead to the creation part was only done when refresh is not set..

          Then my normal code should be

              def __create_ui(self, refresh=False) :
                  if refresh:
                      self.LayoutFlushGroup(1002)
                  else:
                      self.GroupBegin(1002, c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, 1, 1, "My Group")
            
                  self.AddStaticText(1003, c4d.BFH_CENTER | c4d.BFV_SCALEFIT, name="test")
                  if refresh:
                      self.SetString(1003, self.data)
                      self.SetDefaultColor(1003, c4d.COLOR_TEXT, c4d.Vector(0.631, 1, 0.33))
                  else:
                      self.SetDefaultColor(1003, c4d.COLOR_TEXT, c4d.Vector(0.78, 0.257, 0.257))
            
                  self.AddButton(1004, c4d.BFH_CENTER, 60, 15, "Refresh")
                  self.GroupEnd()
            
                  if refresh:
                      self.LayoutChanged(1002)
          

          Wich obviously work.

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

            On 01/04/2017 at 11:36, xxxxxxxx wrote:

            LOL.
            I threw away your create_ui function because I thought you were asking about a different thing.
            Glad you found the problem.

            -ScottA

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

              On 03/04/2017 at 04:55, xxxxxxxx wrote:

              Hi,

              since we know, that you, gr4ph0s, are learn ing C++, here's the link to the C++ GeDialog Gadgets example and especially its UpdateDialog() function. We think, it demonstrates most needed update mechanisms.

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

                On 03/04/2017 at 05:25, xxxxxxxx wrote:

                Thanks you andreas. Maybe I should have edited my first post since we have figured what is going wrong for hte refresh part. (Wich was a stupid error from me... Even if re-read my code 50times)

                But I still got an issue regarding the color of a StaticText after a left click it's reset to c4d default color. Is there a way for removing this behavior?

                import c4d
                  
                class mainDialog(c4d.gui.GeDialog) :
                    def CreateLayout(self) :
                        self.AddStaticText(1001, c4d.BFH_CENTER | c4d.BFV_SCALEFIT, name="Right click on me")
                        self.SetDefaultColor(1001, c4d.COLOR_TEXT, c4d.Vector(0.78, 0.257, 0.257))
                        
                        return True
                  
                    def Command(self, id, msg) :
                        if id == 1001:
                            color = self.GetDefaultColor(1001, c4d.COLOR_TEXT)
                            self.SetString(1001, self.GetString(1003))
                            self.SetDefaultColor(1001, c4d.COLOR_TEXT, c4d.Vector(0.631, 1, 0.33))
                        
                        return True
                            
                def main() :
                    main_dlg = mainDialog()
                    main_dlg.Open(dlgtype=c4d.DLG_TYPE_MODAL, defaultw=100, defaulth=50, xpos=-1, ypos=-1)
                  
                if __name__=='__main__':
                    main()
                
                1 Reply Last reply Reply Quote 0
                • H Offline
                  Helper
                  last edited by

                  On 05/04/2017 at 10:39, xxxxxxxx wrote:

                  I think, you are doing something here, nobody else did before... never tested, never running... I have some doubts, this can be fixed in a modal dialog (not implying it will be easier in a non-model one), as there are no command messages fired by a static text. In a non-modal dialog you could... well... fake it with a timer (imagine me shudder), but you really shouldn't use non-modal dialogs from a Script Manager script.

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

                    On 05/04/2017 at 11:17, xxxxxxxx wrote:

                    Thanks Andreas. Yes in my plugin it's in async so it's ok.
                    I would have prefer a message but I will got for the timer option.

                    But I guess it may be considered as an issue?

                    Anyway Thanks ! 🙂

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

                      On 06/04/2017 at 02:06, xxxxxxxx wrote:

                      Hi,

                      yep, it is considered an issue and I have reported it to our development. But I hope you don't mind, it's probably considered pretty low priority. Nothing crashes, the user will still be able to work and it's a pretty uncommon use-case. Not saying, it's not annoying in your case, I completely understand, but I'm sure you understand we have to prioritize in some ways...

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

                        On 06/04/2017 at 02:15, xxxxxxxx wrote:

                        Yes, no problem I completly understand !

                        Again thanks you for everythings.
                        And congrats for your plugin at maxon labs.

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