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

    Is there a successful example of c4d.gui.SplineCustomGui?

    Cinema 4D SDK
    python
    2
    3
    621
    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.
    • L
      LingZA
      last edited by

      I need a simple and successful example of c4d.gui.SplineCustomGui which has same params as the picture below.
      d2946599-5784-4459-a8c4-53cf1a7d03f0-image.png

      I have tried directly code below. But it can not have the full control of c4d.gui.SplineCustomGui by bc[c4d.constant], and it is without the gui elements, such as "Point X", "Point Y" and so on.
      class Dialog(c4d.gui.GeDialog):

      def __init__(self):
      
          compoId = 1000
          i = 1
      
          compoId += i
          self.groId_0 = compoId
      
          compoId += i
          self.spliId_0 = compoId
      
      def CreateLayout(self):
          bc = c4d.BaseContainer()  
          # bc[c4d.SPLINECONTROL_GRID_H] = True
          # bc[c4d.SPLINECONTROL_GRID_V] = True
          # bc[c4d.SPLINECONTROL_VALUE_LABELS_H_LEGACY] = True
          # bc[c4d.SPLINECONTROL_VALUE_LABELS_V_LEGACY] = True
          bc[c4d.SPLINECONTROL_X_MIN] = 0
          bc[c4d.SPLINECONTROL_X_MAX] = 1
          # bc[c4d.SPLINECONTROL_X_STEPS] = 0.1
          bc[c4d.SPLINECONTROL_Y_MIN] = 0
          bc[c4d.SPLINECONTROL_Y_MAX] = 1
          # bc[c4d.SPLINECONTROL_Y_STEPS] = 0.1
          # bc[c4d.SPLINECONTROL_PRESET_BTN_LEGACY] = True
          # bc[c4d.SPLINECONTROL_ROUND_SLIDER_LEGACY] = True
          # bc[c4d.SPLINECONTROL_GRIDLINES_H_LEGACY] = 10
          # bc[c4d.SPLINECONTROL_GRIDLINES_V_LEGACY] = 10
          # bc[c4d.SPLINECONTROL_MINSIZE_H] = 0.1
          # bc[c4d.SPLINECONTROL_MINSIZE_V] = 0.1
          # bc[c4d.SPLINECONTROL_X_MIN_TEXT_LEGACY] = "True"
          # bc[c4d.SPLINECONTROL_X_MAX_TEXT_LEGACY] = "True"
          # bc[c4d.SPLINECONTROL_Y_MIN_TEXT_LEGACY] = "True"
          # bc[c4d.SPLINECONTROL_Y_MAX_TEXT_LEGACY] = "True"
          # bc[c4d.SPLINECONTROL_X_TEXT] = "Density"
          # bc[c4d.SPLINECONTROL_Y_TEXT] = "Vertex Weight"
          # bc[c4d.SPLINECONTROL_NEW_NO_HORIZ_LEGACY] = False
          # bc[c4d.SPLINECONTROL_NEW_NO_VERT_LEGACY] = False
          # bc[c4d.SPLINECONTROL_HIDE_GRID_H_LEGACY] = False
          # bc[c4d.SPLINECONTROL_HIDE_GRID_V_LEGACY] = False
          # bc[c4d.SPLINECONTROL_HIDE_PRESET_BTN_LEGACY] = False
          # bc[c4d.SPLINECONTROL_HIDE_ROUND_SLIDER_LEGACY] = False
          # bc[c4d.SPLINECONTROL_HIDE_VALUE_EDIT_H_LEGACY] = False
          # bc[c4d.SPLINECONTROL_HIDE_VALUE_EDIT_V_LEGACY] = False
          # bc[c4d.SPLINECONTROL_HIDE_VALUE_LABELS_H_LEGACY] = False
          # bc[c4d.SPLINECONTROL_HIDE_VALUE_LABELS_V_LEGACY] = False
          # bc[c4d.SPLINECONTROL_ALLOW_HORIZ_SCALE_MOVE] = True
          # bc[c4d.SPLINECONTROL_ALLOW_VERT_SCALE_MOVE] = True
          # bc[c4d.SPLINECONTROL_OPTIMAL] = True
          # bc[c4d.SPLINECONTROL_OPTIMAL_X_MIN] = 0.01
          # bc[c4d.SPLINECONTROL_OPTIMAL_Y_MIN] = 0.01
          # bc[c4d.SPLINECONTROL_OPTIMAL_X_MAX] = 0.01
          # bc[c4d.SPLINECONTROL_OPTIMAL_Y_MAX] = 0.01
          # bc[c4d.SPLINECONTROL_SQUARE] = False
          # bc[c4d.SPLINECONTROL_CUSTOMCOLOR_SET] = True
          # bc[c4d.SPLINECONTROL_CUSTOMCOLOR_COL] = c4d.Vector(1,1,1)
          bc[c4d.SPLINECONTROL_NO_FLOATING_WINDOW] = True
          # bc[c4d.SPLINECONTROL_NO_PRESETS] = False
      
          self.spli = self.AddCustomGui(self.spliId_0, c4d.CUSTOMGUI_SPLINE, "", c4d.BFH_SCALEFIT|c4d.BFV_SCALEFIT, 0, 0, bc)
      
          return True
      

      The second way with description files, I also have tried
      https://developers.maxon.net/forum/topic/13499/splinecustomgui-settings-issue/10?_=1653814204664.
      But I failed.
      If it can have all params like the picture in the second way, I want a successful and simple example including its description files(.res and .h).

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

        Hi @LingZA, this is not possible. It's important to point that GUI element available and their properties for NodeData are not the same as the one for GeDialog. Dialog offer possibility to directly create Gadget via code or to load resource files (.res) as NodeData does, but this is just a file format used to define the UI.

        So the easier way would be to either migrate your tool to a NodeData, or you could host a NodeData instance (GeListNode) directly into your dialog and display this GeListNode description as the Attribute Manager display it.

        Here a short code sample demonstrating the use of a Description. In my case I used a Null object, but you could register your own NodeData plugin via c4d.plugins.RegisterNodePlugin with a description containing only a Spline Parameter and not all default Object parameters.

        import c4d
        
        
        class MyDialog(c4d.gui.GeDialog):
        
            def __init__(self):
                super().__init__()
                
                # Store the Description Custom GUI
                self.descriptionGUI = None
                
                # Create a null object in the GeDialog memory, that will host the spline parameter
                self.baselist2d = c4d.BaseObject(c4d.Onull)
                
                # Add the spline parameter to the user data and assign it a default value
                bc = c4d.GetCustomDataTypeDefault(c4d.CUSTOMDATATYPE_SPLINE)
                self.splineDescId = self.baselist2d.AddUserData(bc)
                sd = c4d.SplineData()
                sd.MakeLinearSplineLinear()
                self.baselist2d[self.splineDescId] = sd
        
            def CreateLayout(self):
                # Create a DescriptionUI to display the self.baselist2d stored in the Dialog
                bc = c4d.BaseContainer()
                bc[c4d.DESCRIPTION_ALLOWFOLDING] = True
                bc[c4d.DESCRIPTION_OBJECTSNOTINDOC] = True
                bc[c4d.DESCRIPTION_NOUNDO] = False
                bc[c4d.DESCRIPTION_SHOWTITLE] = False
                bc[c4d.DESCRIPTION_OBJECTSNOTINDOC] = True
                bc[c4d.DESCRIPTION_NO_TAKE_OVERRIDES] = False
                self.descriptionGUI = self.AddCustomGui(1000,
                                                        c4d.CUSTOMGUI_DESCRIPTION,
                                                        "",
                                                        c4d.BFH_SCALEFIT | c4d.BFV_SCALEFIT,
                                                        300,
                                                        300,
                                                        bc)
                
                # Define the BaseList2D to display 
                self.descriptionGUI.SetObject(self.baselist2d)
        
                return True
        
        
        if __name__ == '__main__':
            global dialog
            dialog = MyDialog()
            dialog.Open(c4d.DLG_TYPE_ASYNC, xpos=-2, ypos=-2)
        
        

        Cheers,
        Maxime.

        MAXON SDK Specialist

        Development Blog, MAXON Registered Developer

        L 1 Reply Last reply Reply Quote 1
        • L
          LingZA @m_adam
          last edited by

          @m_adam
          Thanks so much!
          You are a very professional guy!!!

          1 Reply Last reply Reply Quote 0
          • P pim referenced this topic on
          • First post
            Last post