def printtree_rec(treeobj, depth=0):
name = treeobj.get_name(False)
if treeobj.is_device:
deviceid = treeobj.get_device_identification()
print("{0} - {1} {2}".format("--"*depth, name, deviceid))
for child in treeobj.get_children(False):
printtree_rec(child, depth+1)
def printTree(proj):
for obj in proj.get_children():
printtree_rec(obj)
Comes from a forum user, who didn't define a license:
https://forum.codesys.com/viewtopic.php?t=7626