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

    SplineControl GUI

    PYTHON Development
    0
    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.
    • H
      Helper
      last edited by

      On 27/02/2013 at 12:46, xxxxxxxx wrote:

      I have following code, defining the custom SplineControl GUI.
      It shows everything, but how to define and draw the spline?

      self.spline_gui.MakeLinearSplineLinear(3) is not working?

      import c4d
      import os
      import time
      from c4d import gui, plugins, bitmaps, utils

      PLUGIN_ID = 10281842    #test ID!

      MY_HELPBUTTON = 11002
      MY_SPLINE = 11003

      class SettingsDialog(gui.SubDialog) :

      def CreateLayout(self) :
       
            self.AddButton (MY_HELPBUTTON, c4d.BFH_SCALEFIT, 0, 0, 'Help')
           
            bc = c4d.BaseContainer()
            bc[c4d.SPLINECONTROL_GRID_H] = True
            bc[c4d.SPLINECONTROL_GRID_V] = True
            bc[c4d.SPLINECONTROL_VALUE_EDIT_H] = True
            bc[c4d.SPLINECONTROL_VALUE_EDIT_V] = True
            bc[c4d.SPLINECONTROL_VALUE_LABELS_H] = True
            bc[c4d.SPLINECONTROL_VALUE_LABELS_V] = True

      self.spline_gui = self.AddCustomGui(
                    MY_SPLINE, c4d.CUSTOMGUI_SPLINE, "Spline",
                    c4d.BFH_SCALEFIT|c4d.BFV_SCALEFIT, 0, 0, bc)
            return True
       
        def InitValues(self) :
            return True

      def Command(self, id, msg) :
            if (id == MY_HELPBUTTON) :
                gui.MessageDialog("Help")
                return -1

      return True

      class ASSP(plugins.ToolData) :

      def __init__(self) :
            self.data = dict()                  #container

      def AllocSubDialog(self, bc) :
            return SettingsDialog(self.data)    #always return new instance(self.data)

      if __name__ == "__main__":
        bmp = bitmaps.BaseBitmap()
        dir, file = os.path.split(__file__)
        fn = os.path.join(dir, "res", "Icon.tif")
        bmp.InitWith(fn)
        okyn = plugins.RegisterToolPlugin(id=PLUGIN_ID, str="Tab test",info=0, icon=bmp, help="Statusbar Text",dat=ASSP())
        if (okyn) :
            print "Tab Test Plugin V01 initialized."

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

        On 27/02/2013 at 17:17, xxxxxxxx wrote:

        Try this:

            def InitValues(self) :  
              self.sd = c4d.SplineData()  
              self.sd.MakeLinearSplineLinear(3)  
              self.sd.MakeRootSpline(3)  
              self.sd.SetRound(1.0)  
              self.sd.SetRange(xmin=0, xmax=100, xsteps=1, ymin=0, ymax=100, ysteps=1) #Set the spline's range in memory only  
              self.sd.SetKnot(index=0, vPos= c4d.Vector(0,80.0, 0))                    #Set the first knot's position in memory only   
              self.sd.SetKnot(index=1, vPos= c4d.Vector(50,50.0, 0))                   #Set the second knot's position in memory only  
              self.sd.SetKnot(index=2, vPos= c4d.Vector(100,100.0, 0))                 #Set the third knot's position in memory only  
           
              self.spline_gui.SetSpline(self.sd)                                 #Apply the changes made to the spline from memory  
              data = self.spline_gui.GetSplineData()                             #Gets the information about the spline if needed  
                
              c4d.EventAdd  
              return True
        

        -ScottA

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

          On 27/02/2013 at 23:54, xxxxxxxx wrote:

          That should rather work, yes.

          Remember that the Spline GUI itself only provides access to the SplineData inside. The actual manipulation of the spline must be done in the SplineData.

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

            On 28/02/2013 at 01:54, xxxxxxxx wrote:

            Thanks, I'll try and report back.

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

              On 28/02/2013 at 11:20, xxxxxxxx wrote:

              Originally posted by xxxxxxxx

              Try this:

                  def InitValues(self) :  
                    self.sd = c4d.SplineData()  
                    self.sd.MakeLinearSplineLinear(3)  
                    self.sd.MakeRootSpline(3)  
                    self.sd.SetRound(1.0)  
                    self.sd.SetRange(xmin=0, xmax=100, xsteps=1, ymin=0, ymax=100, ysteps=1) #Set the spline's range in memory only  
                    self.sd.SetKnot(index=0, vPos= c4d.Vector(0,80.0, 0))                    #Set the first knot's position in memory only   
                    self.sd.SetKnot(index=1, vPos= c4d.Vector(50,50.0, 0))                   #Set the second knot's position in memory only  
                    self.sd.SetKnot(index=2, vPos= c4d.Vector(100,100.0, 0))                 #Set the third knot's position in memory only  
                 
                    self.spline_gui.SetSpline(self.sd)                                 #Apply the changes made to the spline from memory  
                    data = self.spline_gui.GetSplineData()                             #Gets the information about the spline if needed  
                      
                    c4d.EventAdd  
                    return True
              

              -ScottA

              After adding ScottA codes and some additional init lines, it works. Thanks!

              Additional init lines:
                    bc[c4d.SPLINECONTROL_X_MIN] = 0
                    bc[c4d.SPLINECONTROL_X_MAX] = 100
                    bc[c4d.SPLINECONTROL_X_STEPS] = 10
                    bc[c4d.SPLINECONTROL_Y_MIN] = 0
                    bc[c4d.SPLINECONTROL_Y_MAX] = 100
                    bc[c4d.SPLINECONTROL_Y_STEPS] = 10
                    bc[c4d.SPLINECONTROL_PRESET_BTN] = True
                    bc[c4d.SPLINECONTROL_ROUND_SLIDER] = True

              I'll make a tutorial about what I learned.

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

                On 28/02/2013 at 12:41, xxxxxxxx wrote:

                FYI.
                There's a difference between SetKnot() and InsertKnot() worth mentioning.
                SetKnot() will insert knots that are sort of constrained by default.  And InsertKnot() will insert knots that let the user freely drag them around in X&Y by default.

                You might want to play around with that too for a while to get the feel for it.

                -ScottA

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

                  On 28/02/2013 at 12:59, xxxxxxxx wrote:

                  Yes, I noticed some of it already.

                  In the example you give, you cannot change the horizontal position of the knots.
                  However when you add: lFlagsSettings=0, you can change them.
                  But I guess InsertKnot is better.

                  self.sd.SetKnot(index=0, vPos= c4d.Vector(0,80.0, 0), lFlagsSettings=0)

                  Adding it to one point makes all points possible to change horizontal.

                  Another question:
                  I now get the grid, the spline, etc., but I cannot / see not edit X or Y .
                  Although I added
                        bc[c4d.SPLINECONTROL_VALUE_EDIT_H] = True
                        bc[c4d.SPLINECONTROL_VALUE_EDIT_V] = True

                  In your Tag example (with a res file) there is a little triangle which you can click in order to added values.

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

                    On 28/02/2013 at 13:13, xxxxxxxx wrote:

                    I have the same question.
                    This is the first time I've tried using a splineGUI in a tool plugin. And I'm also wondering why the attributes don't show up in the AM?

                    I've written a GeDialog plugin with a splineGUI in C++. Which is a little bit similar to this.
                    But I used the .res file to layout the splineGUI instead of the AddCustomGui() gizmo method. And there is an attribute called OPEN that makes the splineGUI's attributes show up.

                    I couldn't find any option like that for the AddCustomGui() gizmo method you're using.

                    -ScottA

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

                      On 28/02/2013 at 14:18, xxxxxxxx wrote:

                      So it seems that
                            bc[c4d.SPLINECONTROL_VALUE_EDIT_H] = True
                            bc[c4d.SPLINECONTROL_VALUE_EDIT_V] = True

                      are not working?

                      Back to the res file.

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