On 04/01/2017 at 13:37, xxxxxxxx wrote:
Hello there,
I have two questions concerning the script below:
import c4d, os
from c4d import plugins, bitmaps
PLUGIN_ID = 1938333
def CreateUDGroup(obj, name, parentGroup=None, columns=None, titlebar=1, shortname=None) :
...
def CreateUDText(obj, name, parentGroup=None, CustomGUI=None, val=None, shortname=None) :
...
class Text(plugins.ObjectData) :
def GetVirtualObjects(self, op, hierarchyhelp) :
**UD = op.GetUserDataContainer()
if UD == [] :**
TexelGroup = CreateUDGroup(op,"Text",c4d.DescID(0))
text = CreateUDText(op,"Text", TexelGroup, c4d.CUSTOMGUI_STRINGMULTI, "Text")
if __name__ == "__main__":
dir, file = os.path.split(__file__)
help = ""
icon = bitmaps.BaseBitmap()
icon.InitWith(os.path.join(dir, "res", "Text.tif"))
plugins.RegisterObjectPlugin(id=PLUGIN_ID, str="Text",
g=Text,
description="TGP", icon=icon,
info=c4d.OBJECT_GENERATOR)
Frst question : when the object "Text" is generated the default opened menu is "Basic", How I can set the menu "Text" to default. (See screenshot below)
Second question: I have added the condition below to prevent the adding user data every time when I select my object in object manager.
UD = op.GetUserDataContainer()
if UD == [] :
Is there other way to do that?
Thanks.