NOTE: Not talking about updating to new version but updating the execution of the plug-in.
I have a test plug-in that prints out "There are no objects in the scene" or "There are # objects in the scene".
It works as expected upon initial open of the plug-in but not through-out.
You can see an illustration of the problem here:
https://www.dropbox.com/s/6j0aqtvgg6o2vg6/c4d131_automatic_update-plug-in.mp4?dl=0
Thank you for looking at my problem
P.S. I need the LayoutFLushGroup
and LayoutChanged
in the code since I'm planning to list all objects and all their parameters.
You can see the illustration code here:
import c4d
import os
from c4d import gui, plugins, bitmaps, utils, documents
PLUGIN_ID = 1011321
class MyDialog(gui.GeDialog):
def get_all_objects(self, op):
output = []
while op:
output.append(op)
self.get_all_objects(op.GetDown())
op = op.GetNext()
return output
def CreateLayout(self):
doc = c4d.documents.GetActiveDocument()
self.object_count = len(self.get_all_objects(doc.GetFirstObject()))
self.GroupBegin(id=1000, flags=c4d.BFH_FIT, cols=0, rows=4, title="Rigging")
if self.object_count == 0:
self.LayoutFlushGroup(1001)
self.AddStaticText(0, c4d.BFH_CENTER, name="There are no objects in the scene")
self.LayoutChanged(1001)
if self.object_count > 0 :
self.LayoutFlushGroup(1001)
self.AddStaticText(0, c4d.BFH_CENTER, name="There are %s objects in the scene" %self.object_count)
self.LayoutChanged(1001)
self.GroupEnd()
return True
def Command(self, id, msg):
return True
class MyMenuPlugin(plugins.CommandData):
dialog = None
def Execute(self, doc):
if self.dialog is None:
self.dialog = MyDialog()
return self.dialog.Open(dlgtype=c4d.DLG_TYPE_ASYNC, pluginid=PLUGIN_ID, defaultw=200, defaulth=150, xpos=-1, ypos=-1)
if __name__ == "__main__":
plugins.RegisterCommandPlugin(PLUGIN_ID, "BT Utilities",0, None, "Python Menu", MyMenuPlugin())