On 31/12/2016 at 21:05, xxxxxxxx wrote:
Hello there,
How can I disable a button if the selected object not an editable object, the example below do that but not exactly what I want. In the example below if I select anther object without closing the dialog, nothing is happening.
I want to autoupdate the enabling or disabling of the button without closing and reopening the dialog if I select anther object
I hope that is clear.
import c4d, os
from c4d import gui, documents, plugins
PLUGIN_ID = 1234567
class MyDLG( c4d.gui.GeDialog) :
def UpdateDlg(self, id) :
doc = documents.GetActiveDocument()
op = doc.GetActiveObjects(False)[0]
**if op.GetType() != 5100 :
self.Enable(1000,False)**
def CreateLayout(self) :
self.SetTitle("Texel Bake")
self.AddButton(1000, c4d.BFH_SCALEFIT, 0, 13, "Button")
return True
def InitValues(self) :
self.UpdateDlg(self.GetBool(1000))
return True
class MyPlugin(c4d.plugins.CommandData) :
def Execute(self, doc) :
global RunDLG
RunDLG = MyDLG()
RunDLG.Open(dlgtype=c4d.DLG_TYPE_ASYNC, defaultw=0, defaulth=0)
c4d.EventAdd()
return True
if __name__ == "__main__":
help = ""
icon = c4d.bitmaps.BaseBitmap()
dir, file = os.path.split(__file__)
fn = os.path.join(dir, "res", "icon.tif")
icon.InitWith(fn)
plugins.RegisterCommandPlugin(PLUGIN_ID, "My Plugin", 0, icon, help, MyPlugin())
Thanks.