anatools.lib.ana_object module¶
- class AnaBaseObject(object_type)¶
Bases:
ABC
Base class for Ana objects
- dump_annotations(calculate_obstruction=False)¶
Generate annotations for the object.
- dump_metadata()¶
Convert object to a JSON serializable representation. Sub classes add metadata by implementing the dump_metadata method as follows:
- def dump_metadata(self):
meta = super().dump_metadata() return {**meta, “subclass-attribute”: subclass-value, …}
- load(**kwargs)¶
Default loader - Load the object from a file
- When overriding this method in your subclass you must do all of the following
set self.root = the loaded object
set self.loaded = True
- next_instance = 1¶
- class AnaObject(object_type)¶
Bases:
ABC
Base class for Ana objects
- dump_annotations(calculate_obstruction=False)¶
Generate annotations for the object.
- dump_metadata()¶
Convert object to a JSON serializable representation. Sub classes add metadata by implementing the dump_metadata method as follows:
- def dump_metadata(self):
meta = super().dump_metadata() return {**meta, “subclass-attribute”: subclass-value, …}
- find_object(qname)¶
Recursively search the object hierarchy for a child object where qname is a list of object base names from the original hierarchy.
For example, given this object hierarchy in the original blender file:
- Aircraft
- Left_Wing
Flap
- Right_Wing
Flap.001
To find the right wing flap in a loaded instance of this object you would do the following, assuming “aircraft” is the AnaObject instance.
obj = aircraft.find_object([“Right_Wing”, “Flap”])
IMPORTANT CAVEAT:
This will not work if an object in the hierarchy has two children with the same base name, e.g.
- Aircraft
- Left_Wing
Flap Flap.001
- Right_Wing
Flap.002 Flap.003
To solve this problem you need to modify the original file to follow the “no two children with the same base name” rule
- load(**kwargs)¶
Default loader - Load the object from a file
- If you override this method in your subclass you must do all of the following
create the object hierarchy with a single root object
create the object collection
link all objects to the collection
link the collection to the current scene
set self.collection = the collection datablock
set self.root = the root object datablock
set self.loaded = True
- next_instance = 1¶