Really weird results.
Okay so I have these functions am using to create this user data's 😒.
def CreateUserDataGroup(obj, name, parentGroup=None, columns=None, shortname=None, defaultopen=None, scale=None ):
if obj is None: return False
if shortname is None: shortname = name
bc = c4d.GetCustomDatatypeDefault(c4d.DTYPE_GROUP)
bc[c4d.DESC_NAME] = name
bc[c4d.DESC_SHORT_NAME] = shortname
bc[c4d.DESC_DEFAULT] = 0
bc[c4d.DESC_TITLEBAR] = 1
bc[c4d.DESC_GROUPSCALEV] = 0
if parentGroup is not None:
bc[c4d.DESC_PARENTGROUP] = parentGroup
if columns is not None:
#DESC_COLUMNS VALUE IS WRONG IN 15.057 - SHOULD BE 22
bc[22] = columns
if defaultopen != None:
bc[c4d.DESC_DEFAULT] = 1
if scale != None:
bc[c4d.DESC_GROUPSCALEV] = 1
return obj.AddUserData(bc)
def CreateUserDataLink(obj, name, link, parentGroup=None, shortname=None):
if obj is None: return False
if shortname is None: shortname = name
bc = c4d.GetCustomDatatypeDefault(c4d.DTYPE_BASELISTLINK)
bc[c4d.DESC_NAME] = name
bc[c4d.DESC_SHORT_NAME] = shortname
if link is None:
pass
else:
bc[c4d.DESC_DEFAULT] = link
bc[c4d.DESC_ANIMATE] = c4d.DESC_ANIMATE_OFF
bc[c4d.DESC_SHADERLINKFLAG] = True
if parentGroup is not None:
bc[c4d.DESC_PARENTGROUP] = parentGroup
element = obj.AddUserData(bc)
obj[element] = link
return element
def CreateUserDataInteger(obj, name, parentGroup=None, shortname=None, text=None):
if obj is None: return False
if shortname is None: shortname = name
bc = c4d.GetCustomDatatypeDefault(c4d.DTYPE_LONG)
bc[c4d.DESC_NAME] = name
bc[c4d.DESC_SHORT_NAME] = shortname
bc[c4d.DESC_ANIMATE] = 0
bc[c4d.DESC_CUSTOMGUI] = c4d.CUSTOMGUI_CYCLEBUTTON
if parentGroup is not None:
bc[c4d.DESC_PARENTGROUP] = parentGroup
if text is not None:
#Create a list of names and put them into a container
names = c4d.BaseContainer()
# for x in text.split(","):
count = 0
for x in text:
names.SetString(int(count), str(x))
count += 1
bc.SetContainer(c4d.DESC_CYCLE, names)
bc[c4d.DESC_DEFAULT] = 0
element = obj.AddUserData(bc)
return element
def CreateUserDataString(obj, name, parentGroup=None, shortname=None, text=None):
if obj is None: return False
if shortname is None: shortname = name
bc = c4d.GetCustomDatatypeDefault(c4d.DTYPE_STRING)
bc[c4d.DESC_NAME] = name
bc[c4d.DESC_SHORT_NAME] = shortname
bc[c4d.DESC_ANIMATE] = 0
bc[c4d.DESC_CUSTOMGUI] = c4d.CUSTOMGUI_STRINGMULTI
if parentGroup is not None:
bc[c4d.DESC_PARENTGROUP] = parentGroup
if text is not None:
bc[c4d.DESC_DEFAULT] = text
element = obj.AddUserData(bc)
return element
but when I do Groups work fine so do links But all the others are glitched out.
Until I manually go into the user data and fix make a random edit then the integer works But as you can see in the gif Multiline string does not get fixed as shown in the image below
I still plan on adding "Scale V" to the string Userdata so help on that would be helpful
Below is the Simplified version of my code if you just want to copy and paste as see it for yourself
import c4d
from c4d import gui
from random import randint
# Welcome to the world of Python
def randomColor():
r = randint(0,255) / 256.0
g = randint(0,255) / 256.0
b = randint(0,255) / 256.0
color = c4d.Vector(r,g,b)
return color
def CreateUserDataGroup(obj, name, parentGroup=None, columns=None, shortname=None, defaultopen=None, scale=None ):
if obj is None: return False
if shortname is None: shortname = name
bc = c4d.GetCustomDatatypeDefault(c4d.DTYPE_GROUP)
bc[c4d.DESC_NAME] = name
bc[c4d.DESC_SHORT_NAME] = shortname
bc[c4d.DESC_DEFAULT] = 0
bc[c4d.DESC_TITLEBAR] = 1
bc[c4d.DESC_GROUPSCALEV] = 0
if parentGroup is not None:
bc[c4d.DESC_PARENTGROUP] = parentGroup
if columns is not None:
#DESC_COLUMNS VALUE IS WRONG IN 15.057 - SHOULD BE 22
bc[22] = columns
if defaultopen != None:
bc[c4d.DESC_DEFAULT] = 1
if scale != None:
bc[c4d.DESC_GROUPSCALEV] = 1
return obj.AddUserData(bc)
def CreateUserDataLink(obj, name, link, parentGroup=None, shortname=None):
if obj is None: return False
if shortname is None: shortname = name
bc = c4d.GetCustomDatatypeDefault(c4d.DTYPE_BASELISTLINK)
bc[c4d.DESC_NAME] = name
bc[c4d.DESC_SHORT_NAME] = shortname
if link is None:
pass
else:
bc[c4d.DESC_DEFAULT] = link
bc[c4d.DESC_ANIMATE] = c4d.DESC_ANIMATE_OFF
bc[c4d.DESC_SHADERLINKFLAG] = True
if parentGroup is not None:
bc[c4d.DESC_PARENTGROUP] = parentGroup
element = obj.AddUserData(bc)
obj[element] = link
return element
def CreateUserDataInteger(obj, name, parentGroup=None, shortname=None, text=None):
if obj is None: return False
if shortname is None: shortname = name
bc = c4d.GetCustomDatatypeDefault(c4d.DTYPE_LONG)
bc[c4d.DESC_NAME] = name
bc[c4d.DESC_SHORT_NAME] = shortname
bc[c4d.DESC_ANIMATE] = 0
bc[c4d.DESC_CUSTOMGUI] = c4d.CUSTOMGUI_CYCLEBUTTON
if parentGroup is not None:
bc[c4d.DESC_PARENTGROUP] = parentGroup
if text is not None:
#Create a list of names and put them into a container
names = c4d.BaseContainer()
# for x in text.split(","):
count = 0
for x in text:
names.SetString(int(count), str(x))
count += 1
bc.SetContainer(c4d.DESC_CYCLE, names)
bc[c4d.DESC_DEFAULT] = 0
element = obj.AddUserData(bc)
return element
def CreateUserDataString(obj, name, parentGroup=None, shortname=None, text=None):
if obj is None: return False
if shortname is None: shortname = name
bc = c4d.GetCustomDatatypeDefault(c4d.DTYPE_STRING)
bc[c4d.DESC_NAME] = name
bc[c4d.DESC_SHORT_NAME] = shortname
bc[c4d.DESC_ANIMATE] = 0
bc[c4d.DESC_CUSTOMGUI] = c4d.CUSTOMGUI_STRINGMULTI
if parentGroup is not None:
bc[c4d.DESC_PARENTGROUP] = parentGroup
if text is not None:
bc[c4d.DESC_DEFAULT] = text
element = obj.AddUserData(bc)
return element
def CreateUserDataPopUP(obj, name, parentGroup=None, shortname=None):
if obj is None: return False
if shortname is None: shortname = name
bc = c4d.GetCustomDatatypeDefault(c4d.DTYPE_POPUP)
def SmartCheckSelectedObjs():
objs = doc.GetActiveObjects(1)
if objs is None:
return None
elif len(objs) == 2:
print ("In here 222")
fixedobjs = []
FoundAParent = False
count = 0
for x in objs:
GetParent = x
if x.GetUp() != None:
while GetParent != None:
count = count + 1
if count == 100:
print ("Count break: " + count)
print ("Inside whileLOop")
GetParent = GetParent.GetUp()
print (GetParent)
# count = count + 1
if GetParent == None:
print ("Yesttt ")
else:
GetParentPrev = GetParent
# print ("This should neva happen")
FoundAParent =True
if FoundAParent == True:
fixedobjs.append(GetParentPrev)
else:
fixedobjs.append(x)
else:
fixedobjs.append(x)
for elem in fixedobjs:
if fixedobjs.count(elem) > 1:
print ("Duplicate found")
return None
return fixedobjs
elif len(objs) <= 2 or len(objs) > 15:
return None
else:
print ("Fuck it all broken")
def main():
CheckRun = doc.SearchObject("EaZyRetarget")
if CheckRun == None:
CreateER=c4d.BaseObject(c4d.Onull)
CreateER[c4d.ID_BASELIST_NAME]="EaZyRetarget"
CreateER()[c4d.ID_BASELIST_ICON_FILE] = "300000157"
CreateER[c4d.ID_BASELIST_ICON_COLORIZE_MODE] = 1
CreateER()[c4d.ID_BASELIST_ICON_COLOR] = randomColor()
doc.InsertObject(CreateER)
layerGroup = CreateUserDataGroup(CreateER,"EaZyRetargetMain",c4d.DescID(0), "EaZyRetarget", defaultopen=True, scale=True)
FsubGroup = CreateUserDataGroup(CreateER,"From",layerGroup,2,defaultopen=True)
ListOfSupportedRigTypes = [
" EaZyRig_Game\n"
"1; EaZYRig_Standard\n"
"2; EaZYRig_Full\n"
"-1; "
"3; AccuRig\n"
"4; Mixamo\n"
"5; Rococo\n"
"6; Cascadeur\n"
"7; UE5\n"
"8; Custom\n"
]
fromCycleButton = CreateUserDataInteger(CreateER,"From",FsubGroup, None, ListOfSupportedRigTypes)
try:
print ("IN try")
checkobjs = SmartCheckSelectedObjs()[0]
print (checkobjs)
print ("No try error")
except:
print ("Yeppp totally")
checkobjs = SmartCheckSelectedObjs()
# checkobjs = None
fromCycleLink = CreateUserDataLink(CreateER,"From", checkobjs,FsubGroup, None)
TsubGroup1 = CreateUserDataGroup(CreateER,"To",layerGroup,2, defaultopen=True)
ToCyclebutton = CreateUserDataInteger(CreateER,"To",TsubGroup1, None, ListOfSupportedRigTypes)
try:
checkobjs = SmartCheckSelectedObjs()[1]
print (checkobjs)
except:
checkobjs = SmartCheckSelectedObjs()
# checkobjs = None
ToCycleLink = CreateUserDataLink(CreateER,"To", checkobjs,TsubGroup1, None)
QUickGuidesubGroup = CreateUserDataGroup(CreateER,"Quick Guide for Custom",layerGroup,2,defaultopen=False,scale=True)
msg = "WIP Disclamer:\n This could go Bad really Really Fast\n\n \
You want to make sure the Same Number of\n \
lines are avail on both include & exclude.\n\n\
If there is nothing to exclude just make that line\n\
a None in the exclude userdata"
QuickGuideVar = CreateUserDataString(CreateER,"Quick Guide for Custom",QUickGuidesubGroup,msg)
CustomsubGroup1 = CreateUserDataGroup(CreateER,"Custom Rigs",layerGroup,2, defaultopen=False,scale=True)
# bc = c4d.GetCustomDataTypeDefault(c4d.DTYPE_GROUP) # Create default container
# bc[c4d.DESC_NAME] = "EaZyRetargetMain"
# bc[c4d.DESC_SHORT_NAME] = "EaZyRetarget"
# bc[c4d.DESC_VERSION] = 3
# bc[c4d.DESC_ANIMATE] = 0
# bc[c4d.DESC_COLUMNS] = 1
# bc[c4d.DESC_TITLEBAR] = True
# bc[c4d.DESC_DEFAULT] = 1
# # pass empty DescID
# bc[c4d.DESC_PARENTGROUP] = c4d.DescID()
# element = CreateER.AddUserData(bc) # Add userdata container
# bc1 = c4d.GetCustomDataTypeDefault(c4d.DTYPE_STRING) # Create default container
# bc1[c4d.DESC_NAME] = "Name" # Rename the entry
# bc1[c4d.DESC_ANIMATE] = 0
# bc1[c4d.DESC_PARENTGROUP] = element
message = "I have created a simple 'EaZyRetarget' object.\n\n\
All you need to do is drag the Parent of your Rig 'DOes not matter if it is a \
Null or your hipBone or the Rootbone' Inside the 'From' and 'To' link userdata\n\n\
and Rerun this Script We will work the work for you "
gui.MessageDialog(message)
else:
print("AAAAA")
# for descId, bc in CheckRun.GetUserDataContainer():
# print ("*"*5,descId,"*"*5)
# for key, val in bc:
# for txt, i in c4d.__dict__.iteritems():
# if key == i and txt[:5]=="DESC_":
# print (txt,"=",val)
# break
# else:
# print (key,"=",val)
# Execute main()
if __name__=='__main__':
main()
c4d.EventAdd()