nr.c4d.structures¶
This package provides useful data structures that are commonly used in C4D plugin development.
nr.c4d.structures.ordereddict¶
-
class
nr.c4d.structures.ordereddict.OrderedDict(iterable=None)[source]¶ This class implements a dictionary that can treat non-hashable datatypes as keys. It is implemented as a list of key/value pairs, thus it is very slow compared to a traditional hash-based dictionary.
Access times are:
Best Average Worst O(1) O(n) O(n) Example:
import c4d from nr.c4d.utils import walk from nr.c4d.structures.ordereddict import OrderedDict def main(): mats = OrderedDict() for mat in doc.GetMaterials(): mats[mat] = 0 for obj in walk(doc.GetObjects()): for tag in obj.GetTags(): if tag.CheckType(c4d.Ttexture): mat = tag[c4d.TEXTURETAG_MATERIAL] count = mats.setdefault(mat, 0) mats[mat] = count + 1 for mat, count in mats.iteritems(): if count == 0: print "Unused Material:", mat.GetName() if __name__ == '__main__': main()
-
has_key(key)¶
-
nr.c4d.structures.treenode¶
This module provides the TreeNode class which can be used to build custom hierarchical datastructures.
-
class
nr.c4d.structures.treenode.TreeNode[source]¶ This class implements a tree datastructure very similar to the
c4d.BaseList2Dclass. It is most commonly used to represent a tree in ac4d.gui.TreeViewGui.-
append(node, index=None)[source]¶ Appends node at the specified index. If index is None, node will be inserted at the end of the children list. The index can not be a negative value as it would need to count the number of childrens first.
-
children¶
-
down¶
-
down_last¶
-
insert_after(node)[source]¶ Inserts self after node. self must be free (not in a hierarchy) and node must have a parent node, otherwise a RuntimeError is raised.
-
insert_before(node)[source]¶ Inserts self before node. self must be free (not in a hierarchy) and node must have a parent node, otherwise a RuntimeError is raised.
-
is_dangling()[source]¶ Returns True if the node is a dangling node, meaning it is not inserted in a hierarchy. A dangling node has no parent or neighbouring nodes.
-
iter_children()[source]¶ Iterator for the children of this node. It is safe to call
remove()on yielded nodes.
-
next¶
-
parent¶
-
pred¶
-
remove()[source]¶ Removes the node from the parent and neighbouring nodes. Does not detach child nodes.
-
root¶
-