This week, I am mostly working in my own little world to develop some tools for our productions. I never want to repeat last week again, so I am automating as much as I can with python. Here are some snippets:
# The character Class is the main container for all information relevant to the character. It takes the parameter from
# the xml element tree and then builds the character from that. It calls on two other classes, collection and
# mayaObjects. These should not be constructed directly. If the xml dom is not formatted correctly, this will fail.
# Setter functions are not necessary since the object is constructed from the xml and should not be changed through this process
# script.
class Character:
def __init__(self, element):
self.charName = element.get("name")
self.charAltName = element.get("altName")
self.collections = []
self.mayaObjects = []
for col in element.findall("collection"):
self.collections.append(_Collection(col))
for mobj in element.findall("mayaObject"):
self.mayaObjects.append(_MayaObject(mobj))
def __str__(self):
return "{0}, {1}, {2}, {3}".format(self.charName, self.charAltName, self.collections, self.mayaObjects)
def __repr__(self):
return str(self)
# ---------------------------------------------------
# Getters
# ---------------------------------------------------
def get_charName(self):
return self.charName
def get_charAltName(self):
return self.charAltName
def get_collections(self):
return self.collections
def get_mayaObjects(self):
return self.mayaObjects
def get_hairMayaFile_by_version(self, version):
return self._col_by_version(version).hairMayaFile
def get_xgenFile_by_version(self, version):
return self._col_by_version(version).get_xgenFile
def get_default_collection(self):
for col in self.collections:
if col.get_version() == "default":
return col
# If no matches found
return self.collections[0]
def get_default_mayaObjects(self):
for mobj in self.mayaObjects:
if mobj.get_version() == "default":
return mobj
# If no matches found
return self.mayaObjects[0]
# ---------------------------------------------------
# Helpers
# ---------------------------------------------------
def _col_by_version(self, version):
for col in self.collections:
if col.get_version() == version:
return col
# If no matches found
return None
def _mobj_by_version(self, version):
for mobj in self.mayaObjects:
if mobj.get_version() == version:
return mobj
# If no matches found
return None
# Generates character objects from the xml file
# Returns a list of all of the character classes
def generate_characters(xml_file):
xml_tree = ET.parse(xml_file)
root = xml_tree.getroot()
character_objs = []
for child in root:
character_objs.append(Character(child))
return character_objs
Hours Breakdown:
- Compositing – 7:30
- Website Admin – 0:30
- Technical Directing – 21:00
- Adviser Meeting – 3:00
- Group Meeting – 0:30
Total: 22:30