A None
report happened when modify Fieldlist
in R 2023 , ss a bug or I missed something ?
More :
None report seems happened in R 2023 , It would work actually , but It report a bug like this :
The same code runs well in S26.107 without bug report :
Here is the code :
import c4d
def get_field_layers(op):
""" Returns all field layers that are referenced in a field list.
"""
def flatten_tree(node):
""" Listifies a GeListNode tree.
"""
res = []
while node:
res.append(node)
for child in node.GetChildren():
res += flatten_tree(child)
node = node.GetNext()
return res
# get the GeListHead for the FieldList
root = op.GetLayersRoot()
if root is None:
return []
# Get the first node under the GeListHead
first = root.GetFirst()
if first is None:
return []
# traverse the graph
return flatten_tree(first)
def main():
fieldlists = [value for id, value in op.GetData()
if isinstance(value, c4d.FieldList)]
if not fieldlists:
return
opname = op.GetName()
doc.StartUndo()
for layer in get_field_layers(fieldlists[0]):
obj = layer.GetLinkedObject(doc)
print(obj)
doc.AddUndo(c4d.UNDOTYPE_CHANGE,obj)
obj.SetBit(c4d.BIT_ACTIVE)
#obj.do somethings
doc.EndUndo()
if __name__=='__main__':
main()
c4d.EventAdd()