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
    • Login

    Docked Dialog Problem with width of CUSTOMGUI_FILENAME

    Cinema 4D SDK
    windows python 2025
    2
    6
    790
    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.
    • D
      datamilch
      last edited by

      hi there,
      i'm working on a command plugin with gedialog, that i want to dock in the layout.
      one of the gui elements is AddCustomGui c4d.CUSTOMGUI_FILENAME.
      the paths that are stored can be quite long.
      the problem is, that the dialog wants to show the complete string, which makes the dialog extremely wide.
      this only happens when the dialog is docked. then i can not scale the dialog smaller then the length of the string/filename.
      if the dialog is not docked i can scale it smaller and the overflowing string is hidden.
      sadly AddCustomGui has no properties initw and inith. i tried some combinations of flags but had no success.
      am i missing something?

      i could place the element in a scrollgroup, but then the "open document" button might be hidden in the part that is scrolled away.
      any other options or workarouds?

      cheers, sebastian

      here is the code

      import c4d, typing
      
      ID_PLUGIN_CMD: int = 1025245
      
      class MainDialog(c4d.gui.GeDialog):
      
          ID_GRP_MAIN     = 1000
          ID_TEXT_1       = 1001
          ID_TEXT_2       = 1002
          extra_long_str  = "this is some realy looooooooooooooooooooooooooooooooong text"
      
      
          def __init__(self) -> None:
              super().__init__()
      
          def InitValues(self) -> bool:
              return super().InitValues()
          
          def CreateLayout(self) -> bool:
              self.SetTitle("My Dialog")
      
              self.GroupBegin(id=self.ID_GRP_MAIN, flags=c4d.BFH_SCALEFIT, cols=1)
              self.GroupSpace(spacex=5, spacey=5)
      
              self.GroupBegin(id=0, flags=c4d.BFH_SCALEFIT, cols=2)
              self.AddStaticText(0, c4d.BFH_LEFT, name="path", initw=0 )
              bc = c4d.BaseContainer()
              self.AddCustomGui(self.ID_TEXT_1, c4d.CUSTOMGUI_FILENAME, '' ,c4d.BFH_SCALEFIT, 0, 0, bc,)
              self.AddStaticText(0, c4d.BFH_LEFT, name="text", initw=0 )
              self.AddEditText(self.ID_TEXT_2, c4d.BFH_FIT, 20,10 )
              self.GroupEnd()
              
              self.GroupEnd()
      
              self.SetString( id=self.ID_TEXT_1, value=self.extra_long_str )
              self.SetString( id=self.ID_TEXT_2, value=self.extra_long_str )
      
              return  super().CreateLayout()
          
      
          def Command(self, cid: int, msg: c4d.BaseContainer) -> bool:
              return super().Command(cid, msg)
      
      class DialogManagerCommand (c4d.plugins.CommandData):
          dialog: typing.Optional[MainDialog] = None
      
          def Execute(self, doc: c4d.documents.BaseDocument) -> bool:
              if self.dialog is None:
                  self.dialog = MainDialog()
              if self.dialog.IsOpen() and not self.dialog.GetFolding():
                  self.dialog.SetFolding(True)
              else:
                  self.dialog.Open(c4d.DLG_TYPE_ASYNC, ID_PLUGIN_CMD, -2, -2, defaultw=300, defaulth=200)
              return True
      
          def RestoreLayout(self, secret: any) -> bool:
              if self.dialog is None:
                  self.dialog = MainDialog()
              return self.dialog.Restore(ID_PLUGIN_CMD, secret)
      
          def GetState(self, doc: c4d.documents.BaseDocument) -> int:
              result: int = c4d.CMD_ENABLED
              if self.dialog:
                  if self.dialog.IsOpen() and not self.dialog.GetFolding():
                      result |= c4d.CMD_VALUE
              return result
      
      def RegisterPlugin() -> bool:
          return c4d.plugins.RegisterCommandPlugin(
              id=ID_PLUGIN_CMD,
              str="filename_test_01",
              info=c4d.PLUGINFLAG_SMALLNODE,
              icon=None,
              help="",
              dat=DialogManagerCommand())
      
      def main():
          if not RegisterPlugin():
              raise RuntimeError( f"Failed to register {DialogManagerCommand} plugin." )
      
      if __name__ == '__main__':
          main()
      
      1 Reply Last reply Reply Quote 0
      • i_mazlovI
        i_mazlov
        last edited by

        Hi @datamilch,

        Although I highly suspect this to be a bug, I'll need more time to double check it. I'll update you further, once have a more clear vision on this.

        Cheers,
        Ilia

        MAXON SDK Specialist
        developers.maxon.net

        1 Reply Last reply Reply Quote 0
        • D
          datamilch
          last edited by

          Thanks for the preliminary feedback.
          I'll wait patiently 🙂

          i_mazlovI 1 Reply Last reply Reply Quote 0
          • i_mazlovI
            i_mazlov @datamilch
            last edited by

            Hi Sebastian,

            Thanks for your patience. TLDR; it's a bug but you still need to set minimal width.

            The issue is twofold:

            1. For this UI element to work as intended you need to specify the minimal width argument minw, for example using the c4d.gui.SizeChr() function:
              self.AddCustomGui(self.ID_TEXT_1, c4d.CUSTOMGUI_FILENAME, '', c4d.BFH_SCALEFIT, c4d.gui.SizeChr(80), 0, bc)
            2. There's currently a bug, which prevents this from working properly. The fix is going to be included in one of further Cinema 4D releases.

            After the fix is released, given you're using the minw argument, the issue wouldn't be there anymore. Thanks for drawing our attention to this issue!

            Cheers,
            Ilia

            MAXON SDK Specialist
            developers.maxon.net

            1 Reply Last reply Reply Quote 0
            • D
              datamilch
              last edited by

              hi, thanks for the info.
              i just updated to 2025.2.0 ... but i suppose the fix is not in this one yet? not sure when the release date was ...

              i_mazlovI 1 Reply Last reply Reply Quote 0
              • i_mazlovI
                i_mazlov @datamilch
                last edited by

                Hi Sebastian,

                correct, it hasn't been included into 2025.2.0. The next minor release will likely have it fixed though.

                Cheers,
                Ilia

                MAXON SDK Specialist
                developers.maxon.net

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