On 29/11/2016 at 08:40, xxxxxxxx wrote:
Here's an example:
#This is an example how to hide node based descriptions using the GetDDescription() method added in R18
#The GetDEnabling() method added in R15 is used here to grey out the descriptions if desired
import c4d
from c4d import bitmaps, documents, plugins
PLUGIN_ID = 100000 #Be sure to use a unique ID obtained from www.plugincafe.com
class MyObject(plugins.ObjectData) :
def Init(self, node) :
data = node.GetDataInstance()
data.SetBool(1111, False);
data.SetString(2222, "default");
return True
def GetDDescription(self, node, description, flags) :
data = node.GetDataInstance()
#load the parameters from the description resource
if not description.LoadDescription(node.GetType()) : return False
singleID = description.GetSingleDescID()
### Use this code block to hide/unhide the gizmo depending on the state of the checkbox gizmo ###
#groupID = c4d.DescID(c4d.DescLevel(c4d.ID_OBJECTPROPERTIES, c4d.DTYPE_GROUP, node.GetType())) #The default group
groupID = c4d.DescID(c4d.DescLevel(1000, c4d.DTYPE_GROUP, node.GetType()))
paramID = c4d.DescID(c4d.DescLevel(2222))
if singleID is None or paramID.IsPartOf(singleID)[0]:
bc = c4d.GetCustomDataTypeDefault(c4d.DTYPE_STRING)
bc.SetString(c4d.DESC_NAME, "My String")
if data.GetBool(1111) == True: bc.SetBool(c4d.DESC_HIDE, True)
if data.GetBool(1111) == False: bc.SetBool(c4d.DESC_HIDE, False)
if not description.SetParameter(paramID, bc, groupID) : return False
#Shorter version using GetParameterI() if preferred
#bc = description.GetParameterI(paramID, None)
#if data.GetBool(1111) == True: bc.SetBool(c4d.DESC_HIDE, True)
#if data.GetBool(1111) == False: bc.SetBool(c4d.DESC_HIDE, False)
#Use this to change the text in the string gizmo depending on the state of the checkbox gizmo
if data.GetBool(1111) == True: data.SetString(2222, "")
else: data.SetString(2222, "Not default")
return (True, flags | c4d.DESCFLAGS_DESC_LOADED)
#Use this to grey out the string type gizmo if the checkbox is enabled
"""def GetDEnabling(self, node, id, t_data, flags, itemdesc) :
data = node.GetDataInstance()
paramID = id[0].id
if data.GetBool(1111) == True:
if paramID == 2222: return False
else:
if paramID == 2222: return True
return True"""
def GetBubbleHelp(self, node) :
return "Plugin Bubble Help"
if __name__ == "__main__":
plugins.RegisterObjectPlugin(id=PLUGIN_ID, str="Hide/disable Description",
g=MyObject,
description="myobject", icon=bitmaps.InitResourceBitmap(c4d.Onull),
info=c4d.OBJECT_GENERATOR)
### .res file ###
CONTAINER myobject
{
NAME myobject;
INCLUDE Obase;
//Use this for the default group
//GROUP ID_OBJECTPROPERTIES
//{
// BOOL MY_CHECKBOX { }
// STRING MY_STRING { }
//}
GROUP MY_GROUP
{
DEFAULT 1; //Makes is open by default
BOOL MY_CHECKBOX { }
STRING MY_STRING { }
}
}
### .h file ###
#ifndef _myobject_H_
#define _myobject_H_
enum
{
MY_GROUP = 1000,
MY_CHECKBOX = 1111,
MY_STRING = 2222,
};
#endif
### .str file ###
STRINGTABLE myobject
{
myobject "Hide/disable Attributes";
MY_GROUP "My Group Tab";
MY_CHECKBOX "Toggle Me";
MY_STRING "My String";
}
-ScottA