@bentraje said in [Unusual "NoneType" Error for GetDeformCache()]
RE: caches can contain caches.
Just want to clarify.
Cache (GetCache()
) can contain Caches and Deform Caches (GetDeformCache
)
But Deform Cache can't contain Caches or othe Deform Caches.
Is this assessment correct? I'm basing this on a sample image in this documentation.
Yeah, deform caches are sort of flat. But they are often (when the deformer does not directly act on a PointObject
) imbedded within a cache. It will look something like the tree below which represents the example of the docs, but with only one cloned cube. The problem is that this is not a monohierarchical structure which cannot be described very well with a (monohierarchical) taxonomy (i.e. the image in the docs or what I have done below). You can test this yourself with [1].
# The actual array node.
Array/Array
Array/Array returns for GetCache:
# The null object holding all parametric cubes in the cache
Null/Array
# A null object has no cache
Null/Array returns 'None' for GetCache.
# And also no deform cache
Null/Array returns 'None' for GetDeformCache.
# But some children
children of Null/Array:
# A parametric cube as child of the cache.
Cube/Cube.1
# The cache of that part of the cache of the node :o
Cube/Cube.1 returns for GetCache:
# The actual polygonal data created by the GVO of the
# parametric cube object.
Polygon/Cube.1
Polygon/Cube.1 returns 'None' for GetCache.
Polygon/Cube.1 returns for GetDeformCache:
# The deformed polygonal data generated by
# the deformer reaching deep into the cache
# of the array object.
Polygon/Cube.1
Polygon/Cube.1 returns 'None' for GetCache.
Polygon/Cube.1 returns 'None' for GetDeformCache.
Polygon/Cube.1 has no children.
Polygon/Cube.1 has no children.
# No deform cache here, since this is the paramteric cube
# not its polygonal cache.
Cube/Cube.1 returns 'None' for GetDeformCache.
Cube/Cube.1 has no children.
# Has no deformed cache since its cache is a null object (which has
# stuff attached to it.)
Array/Array returns 'None' for GetDeformCache.
# The actual children of the actual array object.
children of Array/Array:
Cube/Cube
# This one is quite surprising I didn't know either, it seems
# like that at least the array object *mutes* its input objects
# to avoid overhead.
Cube/Cube returns 'None' for GetCache.
Cube/Cube returns 'None' for GetDeformCache.
Cube/Cube has no children.
Bend/Bend
Bend/Bend returns 'None' for GetCache.
Bend/Bend returns 'None' for GetDeformCache.
Bend/Bend has no children.
RE: "flat" caches.
Just to clarify, by flat caches, I guess you meant objects with no stacking parent/child hierarchies?
I meant caches that do not contain caches. A cache that is a null to which multiple other nulls are parented would be flat in this sense, as the nulls will have no further caches. If it were parametric cubes parented instead, it would not be no longer flat, since each cube had its own cache.
Cheers,
zipit
[1]
"""Prints the cache hierarchy of a selected object.
"""
import c4d
def walk_cache(node, indent=0):
"""
"""
if node is None:
return
node_name = node.GetTypeName() + "/" + node.GetName()
is_controlobject = node.GetBit(c4d.BIT_CONTROLOBJECT)
print("{}{} (BIT_CONTROLOBJECT: {})".format("\t" * indent,
node_name,
is_controlobject))
for f in [node.GetCache, node.GetDeformCache]:
cache = f()
msg = ("{}{} returns for {}:" if cache else
"{}{} returns 'None' for {}.")
print(msg.format("\t" * (indent + 1), node_name, f.__name__))
if cache:
walk_cache(cache, indent + 2)
children = node.GetChildren()
no_children = len(children) == 0
msg = "{}{} has no children." if no_children else "{}children of {}:"
print(msg.format("\t" * (indent + 1), node_name))
for child in children:
walk_cache(child, indent + 2)
def main():
"""
"""
if op is None:
raise ValueError("Please select an object.")
walk_cache(op)
if __name__ == "__main__":
main()