@zipit So I have tried implementing your check for DESC_DEFAULT and I am still not getting values for default.
#.....Snippet from my script, full code at bottom of post.
#Process tag parameters
desc = o.GetDescription(c4d.DESCFLAGS_DESC_0)
for bc, paramid, groupid in desc:
#Check if current value matches default value
is_default = bc[c4d.DESC_DEFAULT] == o[paramid]
#print both values for visual comparison
print "DEBUG:: " + str(bc[c4d.DESC_DEFAULT]) + " == " + str(o[paramid]) + " --> " + str(is_default)
if is_default is not True:
#.....
As an example I am currently using a simple Null object for testing the default functionality. Changing only the Object > Display parameter to see if my code catches if it is set to default or not. The print output is like this so far. For simplicity I've only posted the Object Properties results.
Object Properties
DEBUG:: None == 0 --> False
Display 0
DEBUG:: None == 10.0 --> False
Radius 10.0
DEBUG:: None == 10.0 --> False
Aspect Ratio 10.0
DEBUG:: None == 0 --> False
Orientation 0
I would expect this debug result to read as this since all parameters are at their defaults.
Object Properties
DEBUG:: 0 == 0 --> True
DEBUG:: 10.0 == 10.0 --> True
DEBUG:: 10.0 == 10.0 --> True
DEBUG:: 0 == 0 --> True
#...
...but bc[c4d.DESC_DEFAULT] is continuously returning None for some reason. What am I missing here? Thanks again for any assistance on this.
Here is my full script code currently. I cleaned up a lot from previous build as it was getting very messy. The param name/value retrieval is now it's own function (def):
import c4d
from c4d import gui
# Main function
def main():
o = op
if o is not None:
recurse(o)
def getParamData(o):
try:
#misc var
grpName = ""
#Process tag parameters
desc = o.GetDescription(c4d.DESCFLAGS_DESC_0)
for bc, paramid, groupid in desc:
#Check if current value matches default value
is_default = bc[c4d.DESC_DEFAULT] == o[paramid]
#print both values for visual comparison
print "DEBUG:: " + str(bc[c4d.DESC_DEFAULT]) + " == " + str(o[paramid]) + " --> " + str(is_default)
if is_default is not True:
isgroup = paramid[0].dtype==c4d.DTYPE_GROUP
if isgroup:
#handle blank names
if bc[c4d.DESC_NAME] is not "":
grpName = bc[c4d.DESC_NAME]
print grpName
#check for param name and ident
if bc[c4d.DESC_NAME] and bc[c4d.DESC_IDENT]:
try:
#Adjust color float to 255 range
vec = o[paramid]
if "Color" in bc[c4d.DESC_NAME] and "Vector" in str(vec):
vec = o[paramid]
val = "Vector(" + str(vec[0]*255) + ", " + str(vec[1]*255) + ", " + str(vec[2]*255) + ")"
else:
#Strip None values out
blank = o[paramid]
if blank == None:
val = ""
else:
val = str(o[paramid])
#handle group name duplicates in results
if bc[c4d.DESC_NAME] == grpName:
pass
else:
print "\t" + bc[c4d.DESC_NAME] + "\t" + val
except:
print "\t" + bc[c4d.DESC_NAME] + ": PARAMETER REQUIRES MANUAL EXTRACTION"
except:
print "--UNKNOWN PARAMETER--"
def recurse(o):
obj = o
if obj is not None:
#Misc variables
tab = "\t"
#Header
print "Name\tParameter\tValue\tParam ID"
#Print object name
on = obj.GetName()
print on
#Get object data
#data = obj.GetData()
#Get param name and value
getParamData(obj)
#Get object tags
tags = obj.GetTags()
#Loop tags
for t in tags:
tn = t.GetTypeName()
if tn is not "" or None:
#Add spacer in output
print ""
#Get tag name
print t.GetTypeName()
#Get param name and value
getParamData(t)
#Check for child object
d = obj.GetDown()
if d is not None:
recurse(d)
#Get next object
n = obj.GetNext()
if n is not None:
recurse(n)
else:
print "Error: Select one starting object first."
# Execute main()
if __name__=='__main__':
main()