THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 26/04/2012 at 04:57, xxxxxxxx wrote:
Hello everybody,
some days ago I started paying attention to plugin-writing. After several attempts, where I've struggled with the basic structure, I'm trying now for quite some time to bring a test project about that I thought it was quite easy.
I want to create an information box in which the currently active object is always displayed. I began to try on CommandData and GeDialog, but unfortunately I didn't manage to update the dialog when the active object is changing. I've done it with ObjectData. Unfortunately, the update will only work as long as the dialog is in a window. If I integrate it into the layout of cinema, all the commands are executed correctly in the background (I´ve tried with 'print'), but the dialog isn't updated anymore. I think the cinemalayout itself has to be updated, because it works when I minimize cinema and then turn back to full-screen. How can I do that?
I work with R12, window7/64bit.
I hope anyone can help...
greetings
rown
import os
import math
import sys
import c4d
from c4d import plugins, utils, bitmaps, gui
# be sure to use a unique ID obtained from www.plugincafe.com
PLUGIN_ID = 1000001 # TestID only!!!!!!!!!!!
GR_T = 10001
TOBJ = 10002
OBJ = 10003
BOOL = 10050
# MyDialog class
class MyDialog(gui.GeDialog) :
name = "-"
def CreateLayout(self) :
self.SetTitle("rownTEST02")
self.GroupBegin(id=GR_T, flags=c4d.BFH_LEFT, cols=2)
self.GroupBorderSpace(10, 10, 10, 10)
self.AddStaticText(id=TOBJ, flags=c4d.BFH_LEFT, initw=133, inith=10, name="Active Object", borderstyle=c4d.BORDER_NONE)
self.AddStaticText(id=OBJ, flags=c4d.BFH_LEFT, initw=400, inith=10, name=self.name, borderstyle=c4d.BORDER_THIN_IN)
self.AddCheckbox(id=BOOL, flags=c4d.BFH_LEFT, initw=120, inith=10, name="")
self.GroupEnd()
return True
def InitValues(self) :
self.IsActiveObj()
self.SetString(OBJ, self.name)
return True
def Command(self, id, msg) :
return True
def IsActiveObj(self) :
obj = c4d.documents.GetActiveDocument().GetActiveObject()
if obj is None: self.name = "-"
else: self.name = obj.GetName()
class rownTEST02(plugins.ObjectData) :
dialog = None
def GetVirtualObjects(self, op, hierarchyhelp) :
dirty = op.CheckCache(hierarchyhelp) or op.IsDirty(c4d.DIRTY_DATA)
if dirty is False: return op.GetCache(hierarchyhelp)
def __init__(self) :
self.SetOptimizeCache(True)
def Init(self, node) :
return True
def Message(self, node, type, data) :
if type == c4d.MSG_MENUPREPARE:
if self.dialog is None:
self.dialog = MyDialog()
self.dialog.Open(dlgtype=c4d.DLG_TYPE_ASYNC, pluginid=PLUGIN_ID, defaultw=0, defaulth=0)
elif type == c4d.MSG_GETCUSTOMICON:
self.dialog.InitValues()
return True
if __name__ == "__main__":
dir, file = os.path.split(__file__)
icon = bitmaps.BaseBitmap()
icon.InitWith(os.path.join(dir, "res", "icon.tif"))
plugins.RegisterObjectPlugin(id=PLUGIN_ID, str="rownTEST02",
g=rownTEST02,
description="rownTEST02", icon=icon, info=c4d.OBJECT_GENERATOR)