Python_gradient gizmo won't maximize

On 02/08/2014 at 19:00, xxxxxxxx wrote:

User Information:
Cinema 4D Version:   13 
Platform:   Windows  ;   
Language(s) :

I can't open the gradient gizmo's options pallet when creating it with AddCustomGui() function.
SetLayoutMode(c4d.LAYOUTMODE_MAXIMIZED) does not work.

Example of the various things I've tried to maximize the gizmo:

import c4d,os,sys  
from c4d import plugins, utils, bitmaps, gui, documents  
Plugin_ID = 1000010    #Testing id ONLY!!!!!!!   
MY_GRADIENT = 10001  
class MyDialog_Gui(gui.GeDialog) :  
  myGradGizmo = None  
  gradient = c4d.Gradient()  
  def CreateLayout(self) :  
      #Create the gradient gui here  
      #We will change it's options in the InitValues() method  
      gSettings = c4d.BaseContainer()  
      #gSettings.SetBool(c4d.LAYOUTMODE_MAXIMIZED, True)  #<---Wrong!!!  
      #gSettings.SetLong(c4d.LAYOUTMODE_MAXIMIZED, 2)     #<---Wrong!!!  
      #gSettings.SetLayoutMode(c4d.LAYOUTMODE_MAXIMIZED)  #<---Wrong!!!  
      self.myGradGizmo = self.AddCustomGui(MY_GRADIENT, c4d.CUSTOMGUI_GRADIENT, "", c4d.BFH_SCALEFIT|c4d.BFV_CENTER, 0, 0, gSettings)       
      return True      
  def InitValues(self) :  
      #To change the gradient gui we have to first create a gradient object and fill it with data  
      #Then we copy the settings to the CUSTOMGUI_GRADIENT we created in the CreateLayout() method          
      self.gradient.InsertKnot(col = c4d.Vector(0.0, 0.0, 0.0), pos = 0.0,index = 0)  
      self.gradient.InsertKnot(col = c4d.Vector(1.0, 1.0, 1.0), pos = 0.5,index = 1)  
      self.gradient.InsertKnot(col = c4d.Vector(1.0, 1.0, 1.0), pos = 1.0,index = 2)  
      self.gradient.SetData(c4d.GRADIENT_MODE, c4d.GRADIENTMODE_COLOR)  
      #self.gradient.SetLayoutMode(c4d.LAYOUTMODE_MAXIMIZED)      #<---Wrong!!!          
      #self.myGradGizmo.SetLayoutMode(c4d.LAYOUTMODE_MAXIMIZED)   #<---Wrong!!!  
      return True  
  def Command(self, id, msg) :      
      return True  
  def CoreMessage(self, id, msg) :  
      return True          
#   MyDialog_Main --- Where the plugin stuff happens--Don't edit this part  
class myDialog_Main(plugins.CommandData) :  
  dialog = None  
  def Execute(self, doc) :  
      #Create the dialog  
      if self.dialog is None:  
          self.dialog = MyDialog_Gui()  
      return self.dialog.Open(dlgtype=c4d.DLG_TYPE_ASYNC, pluginid=Plugin_ID, xpos=-1, ypos=-1)  
  def RestoreLayout(self, sec_ref) :  
      #Manage the async dialog so it can be docked in the UI  
      if self.dialog is None:  
          self.dialog = MyDialog_Gui()  
      return self.dialog.Restore(pluginid=Plugin_ID, secret=sec_ref)  
if __name__ == "__main__":  
 path, fn = os.path.split(__file__)  
 #bmp = bitmaps.BaseBitmap()  
 #bmp.InitWith(os.path.join(path, "res/icons/", "None")) #Uses a folder called "icons" inside the "res" folder to hold the icon  
 plugins.RegisterCommandPlugin(Plugin_ID, "LinkBox Example", 0, None, "", myDialog_Main())


On 13/01/2015 at 04:57, xxxxxxxx wrote:

I was also struggling with the gradient UI.
It is now working, also thanks to this above example.

Except, there are 6 knots in the gradient and not 3 as defined.
When you drag a knot you can see another one beneath it.
It seems every knot is inserted twice?

What am I doing and the example above doing wrong?


On 14/01/2015 at 03:47, xxxxxxxx wrote:


SetLayoutMode() is not available in Python. But it is possible to set a value for CUSTOMGUI_LAYOUTMODE in the BaseContainer used with AddCustomGui() :

bc = c4d.BaseContainer()  
gradient = self.AddCustomGui(id=4000, pluginid=c4d.CUSTOMGUI_GRADIENT, name="gradient", flags=c4d.BFH_LEFT, minw=400, minh=20, customdata = bc)  

The behavior that two knots are inserted instead of one is indeed a bug. A bug report was filed.

best wishes,

On 14/01/2015 at 04:14, xxxxxxxx wrote:

Thanks for the reply.
It is good to know it is a bug.
I spend about a day debugging/trying/testing before asking the question this forum.