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
    1. Maxon Developers Forum
    2. mogli
    M
    • Profile
    • Following 0
    • Followers 0
    • Topics 3
    • Posts 8
    • Best 0
    • Controversial 0
    • Groups 0

    mogli

    @mogli

    0
    Reputation
    4
    Profile views
    8
    Posts
    0
    Followers
    0
    Following
    Joined Last Online

    mogli Unfollow Follow

    Latest posts made by mogli

    • RE: some problem with CUSTOMGUI_BITMAPBUTTON

      thank you very much! It's help me a lot! sorry about the multiple topics, I'll take them apart next time

      posted in Cinema 4D SDK
      M
      mogli
    • some problem with CUSTOMGUI_BITMAPBUTTON

      hello,guys
      there is some problem with CUSTOMGUI_BITMAPBUTTON, I want to use it to create a file browser.
      my envirment: c4d R26, Python
      1.width self-adaptive,when I change the dialog width,the number of BitmapButton in row could be changed by the dialog width。
      GIF 2022-9-2 10-29-09.gif
      just like this.
      here is my demo picture🤒
      GIF 2022-9-2 10-29-44.gif

      2.can I capture the double click event Message with bitmapbutton? I want entry the directory when I double click the directory bitmapbutton。

      3.the bottom of the directory bitmapbutton Text
      when the text is too long, it will be hide in the end

      exp. Text is “electric wire”
      I want Is Shows "delctric..."
      but is Shows "electric w"
      how could I measure the width,or Is there have some other solution?

      thanks very much for reading! have a good day!

      here is my demo code

      import c4d
      
      class Test1Dialog(c4d.gui.GeDialog):
          ID_BITMAP_BUTTON = 10000
          ID_BITMAP_TEXT = 20000
          BITMAP_WIDTH = 50
      
          def CreateLayout(self):
              """Creates the layout for the dialog.
              """
              if self.ScrollGroupBegin(0, c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, c4d.SCROLLGROUP_VERT  |  c4d.SCROLLGROUP_AUTOVERT, 80, 80):
                  if self.GroupBegin(1, c4d.BFH_LEFT | c4d.BFV_TOP, 0, 0, "", c4d.BFV_GRIDGROUP_EQUALCOLS | c4d.BFV_GRIDGROUP_EQUALROWS | c4d.BFV_DIALOG_BAR_VERT | c4d.BFV_LAYOUTGROUP_PALETTEOUTLINES):
                      for i in range(30):
                          bc = c4d.BaseContainer()
                          bc[c4d.BITMAPBUTTON_BUTTON] = True
                          bc[c4d.BITMAPBUTTON_ICONID1] = 1052837
                          bc[c4d.BITMAPBUTTON_BACKCOLOR] = c4d.COLOR_BG
                          bc[c4d.BITMAPBUTTON_DISABLE_FADING] = False
                          bc[c4d.BITMAPBUTTON_FORCE_SIZE] = Test1Dialog.BITMAP_WIDTH
                          if self.GroupBegin(0, c4d.BFH_LEFT, 1, 2):
                              self.AddCustomGui(Test1Dialog.ID_BITMAP_BUTTON + i, c4d.CUSTOMGUI_BITMAPBUTTON, "", c4d.BFH_CENTER | c4d.BFV_CENTER, 0, 0, bc)
                              self.AddStaticText(id= Test1Dialog.ID_BITMAP_TEXT + i,flags=c4d.BFH_SCALEFIT,initw=Test1Dialog.BITMAP_WIDTH,inith=0,name="test string number" + str(i) ,borderstyle=0)
                          self.GroupEnd()
                  self.GroupEnd()
              self.GroupEnd()
              self.AddDlgGroup(c4d.DLG_OK | c4d.DLG_CANCEL)
              return True
      
      def main():
          global dialog
          dialog = Test1Dialog()
          dialog.Open(dlgtype=c4d.DLG_TYPE_ASYNC, defaultw=-2, defaulth=-2)
      
      if __name__ == '__main__':
          main()
      
      posted in Cinema 4D SDK s26 python sdk
      M
      mogli
    • RE: embed interface

      @ferdinand thanks a lot, best wishes!

      posted in Cinema 4D SDK
      M
      mogli
    • RE: embed interface

      hi @ferdinand about 3,I'm try to exeute the example code by the link provided, but It seems not work,It opens as Separate Window.
      2943e1a2-ad68-4539-b3be-80ca0b115c51-图片.png
      😵

      posted in Cinema 4D SDK
      M
      mogli
    • RE: embed interface

      hi @ferdinand
      These responses are very useful to me,Thank you for taking so much time to reply,Have a nice day!

      posted in Cinema 4D SDK
      M
      mogli
    • embed interface

      hello,guys
      I'm implement some functions like model manage system, similar with asset browser, but the data come from Remote DataBase,so this is some questions on my way。

      my environment
      python
      c4d R26
      code:

      import c4d
      
      ID_NAME = 1              
      
      PLUGIN_ID = 3000011 # TEST ID ONLY
      
      class TreeNode(object):
          data = None
          _selected = False
      
          def __init__(self, data):
              self.data = data
      
          @property
          def Text(self):
              return self.__text
      
          @Text.setter
          def Text(self, value: str):
              self.__text = value
      
          @property
          def IsSelected(self):
              return self._selected
      
          def Select(self):
              self._selected = True
      
          def Deselect(self):
              self._selected = False
      
          def __repr__(self):
              return str(self)
      
          def __str__(self):
              return str(self.data)
      
      class TreeView(c4d.gui.TreeViewFunctions):
      
          def __init__(self):
              self.listOfItems = list() # Store all objects we need to display in this list
      
          def IsResizeColAllowed(self, root, userdata, lColID):
              return True
      
          def IsTristate(self, root, userdata):
              return False
      
          def GetColumnWidth(self, root, userdata, obj, col, area):
              return 80  # All have the same initial width
      
          def IsMoveColAllowed(self, root, userdata, lColID):
              # The user is allowed to move all columns.
              # TREEVIEW_MOVE_COLUMN must be set in the container of AddCustomGui.
              return False
      
          def GetFirst(self, root, userdata):
              """
              Return the first element in the hierarchy, or None if there is no element.
              """
              rValue = None if not self.listOfItems else self.listOfItems[0]
              return rValue
      
          def GetDown(self, root, userdata, obj):
              """
              Return a child of a node, since we only want a list, we return None everytime
              """
              return None
      
          def GetNext(self, root, userdata, obj):
              """
              Returns the next Object to display after arg:'obj'
              """
              rValue = None
              currentObjIndex = self.listOfItems.index(obj)
              nextIndex = currentObjIndex + 1
              if nextIndex < len(self.listOfItems):
                  rValue = self.listOfItems[nextIndex]
      
              return rValue
      
          def GetPred(self, root, userdata, obj):
              """
              Returns the previous Object to display before arg:'obj'
              """
              rValue = None
              currentObjIndex = self.listOfItems.index(obj)
              predIndex = currentObjIndex - 1
              if 0 <= predIndex < len(self.listOfItems):
                  rValue = self.listOfItems[predIndex]
      
              return rValue
      
          def GetId(self, root, userdata, obj):
              """
              Return a unique ID for the element in the TreeView.
              """
              return hash(obj)
      
          def Select(self, root, userdata, obj, mode):
              """
              Called when the user selects an element.
              """
              if mode == c4d.SELECTION_NEW:
                  for tex in self.listOfItems:
                      tex.Deselect()
                  obj.Select()
              elif mode == c4d.SELECTION_ADD:
                  obj.Select()
              elif mode == c4d.SELECTION_SUB:
                  obj.Deselect()
      
          def IsSelected(self, root, userdata, obj):
              """
              Returns: True if *obj* is selected, False if not.
              """
              return obj.IsSelected
      
          def SetCheck(self, root, userdata, obj, column, checked, msg):
              """
              Called when the user clicks on a checkbox for an object in a
              `c4d.LV_CHECKBOX` column.
              """
              if checked:
                  for tex in self.listOfItems:
                      tex.Deselect()
                  obj.Select()
              else:
                  obj.Deselect()
      
          def IsChecked(self, root, userdata, obj, column):
              """
              Returns: (int): Status of the checkbox in the specified *column* for *obj*.
              """
              if obj.IsSelected:
                  return c4d.LV_CHECKBOX_CHECKED | c4d.LV_CHECKBOX_ENABLED
              else:
                  return c4d.LV_CHECKBOX_ENABLED
      
          def GetName(self, root, userdata, obj):
              """
              Returns the name to display for arg:'obj', only called for column of type LV_TREE
              """
              return str(obj.Text)
      
          def DrawCell(self, root, userdata, obj, col, drawinfo, bgColor):
              """
              Draw into a Cell, only called for column of type LV_USER
              """
              value = obj.Text
              geUserArea = drawinfo["frame"]
              w = geUserArea.DrawGetTextWidth(value)
              h = geUserArea.DrawGetFontHeight()
              xpos = drawinfo["xpos"]
              ypos = drawinfo["ypos"] + drawinfo["height"]
              drawinfo["frame"].DrawText(value, xpos, ypos - h * 1.1)
      
          def DoubleClick(self, root, userdata, obj, col, mouseinfo):
              """
              Called when the user double-clicks on an entry in the TreeView.
      
              Returns:
                (bool): True if the double-click was handled, False if the
                  default action should kick in. The default action will invoke
                  the rename procedure for the object, causing `SetName()` to be
                  called.
              """
              return True
      
          def EmptyText(self, root: object, userdata: object) -> str:
              return "empty"
      
      class TestTreeDialog(c4d.gui.SubDialog):
          _treegui = None # Our CustomGui TreeView
          _listView = TreeView() # Our Instance of c4d.gui.TreeViewFunctions
          ID_LISTVIEW = 10000
      
          def CreateLayout(self):
      
              if self.GroupBegin(0, c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT, cols=2):
                  # Create the TreeView GUI.
                  customgui = c4d.BaseContainer()
                  customgui.SetBool(c4d.TREEVIEW_BORDER, c4d.BORDER_THIN_OUT)
                  # True if the tree view may have a header line.
                  customgui.SetBool(c4d.TREEVIEW_HAS_HEADER, True)
                  # True if no lines should be drawn.
                  customgui.SetBool(c4d.TREEVIEW_HIDE_LINES, False)
                  # True if the user can move the columns.
                  customgui.SetBool(c4d.TREEVIEW_MOVE_COLUMN, True)
                  # True if the column width can be changed by the user.
                  customgui.SetBool(c4d.TREEVIEW_RESIZE_HEADER, True)
                  # True if all lines have the same height.
                  customgui.SetBool(c4d.TREEVIEW_FIXED_LAYOUT, True)
                  # Alternate background per line.
                  customgui.SetBool(c4d.TREEVIEW_ALTERNATE_BG, True)
                  # True if cursor keys should be processed.
                  customgui.SetBool(c4d.TREEVIEW_CURSORKEYS, True)
                  # Suppresses the rename popup when the user presses enter.
                  customgui.SetBool(c4d.TREEVIEW_NOENTERRENAME, False)
                  customgui.SetBool(c4d.TREEVIEW_NO_MULTISELECT, True)
                  #customgui.SetBool(c4d.TREEVIEW_RESIZABLE, True)
      
                  self._treegui = self.AddCustomGui(
                      self.ID_LISTVIEW, c4d.CUSTOMGUI_TREEVIEW, "", c4d.BFH_SCALEFIT|c4d.BFV_SCALEFIT, 50, 100, customgui)
                  if not self._treegui:
                      print("[ERROR]: Could not create TreeView")
                      return False
                  self.AddMultiLineEditText(0, c4d.BFH_SCALEFIT|c4d.BFV_SCALEFIT, 80,100)
              self.GroupEnd()
              return True
      
          def InitValues(self):
      
              #testcode
              node1 = TreeNode("1")
              node1.Text = "a1"
              self._listView.listOfItems.append(node1)
      
              node2 = TreeNode("1")
              node2.Text = "a2"
              self._listView.listOfItems.append(node2)
      
              # Initialize the column layout for the TreeView.
              layout = c4d.BaseContainer()
              layout.SetLong(ID_NAME, c4d.LV_TREE)
      
              self._treegui.SetLayout(1, layout)
      
              # Set the header titles.
              self._treegui.SetHeaderText(ID_NAME, "name")
              #self._treegui.Refresh()
      
              # Set TreeViewFunctions instance used by our CUSTOMGUI_TREEVIEW
              self._treegui.SetRoot(self._treegui, self._listView, None)
              self._treegui.Refresh()
      
              return True
      
          def Command(self, messageId, bc):
              return True
      
      class MenuToolData(c4d.plugins.ToolData):
          dialog = None
      
          def Message(self, doc, data, msgType, t_data):
              return True
      
          def AllocSubDialog(self, bc):  
              return TestTreeDialog()
      
          def GetState(self, doc):
              return c4d.CMD_ENABLED
      
          def MouseInput(self, doc, data, bd, win, msg):
              return True
      
      
      def main() -> None:
          # c4d.plugins.RegisterCommandPlugin(
          #     PLUGIN_ID, "treeTest1", 0, None, "treeTest1", MenuCommand())
      
          c4d.plugins.RegisterToolPlugin(PLUGIN_ID, "treeTest2menu", 0, None,"treeTest2describe", MenuToolData())
      
      if __name__ == '__main__':
          main()
      

      1.is there any way to add a separator in the model of the two control, so I'can drag to resize,
      e2c12902-f5f4-41fd-aa72-2de1763662d0-图片.png
      like asset browser.
      GIF 2022-7-27 16-47-21.gif
      2.how to hide this title? It's seem useless
      90337541-a545-43b9-9f38-0fee8bf3f18b-图片.png
      3.can embed the Dialog like asset browser?
      a64270ce-54dd-4825-b0bf-fef0fadf36ce-图片.png

      thanks a lot!

      posted in Cinema 4D SDK python sdk
      M
      mogli
    • RE: something problem with using TreeViewCustomGui

      @ferdinand thank you very much,it had been solved According to your method,have a good day!

      posted in Cinema 4D SDK
      M
      mogli
    • something problem with using TreeViewCustomGui

      hello guys:
      when i'm using TreeViewCustomGui(python),there is some problem。
      1.CUSTOMGUI_TREEVIEW is empty,this is some ??? showing in the form😵
      35017f41-605a-4d11-bf0f-2d351c056a4e-图片.png
      2.when i use DLG_TYPE_ASYNC, the open form show empty, if i instead of using DLG_TYPE_MODAL it shows normal。
      1b66b372-b69e-47c7-a462-860e50dafd6b-图片.png
      does somewhere i use wrong?

      sorry about the grammar
      best wishes

      posted in Cinema 4D SDK python sdk
      M
      mogli