def create_representations(): """creates the representations of the scene """ from anima.env import mayaEnv m_env = mayaEnv.Maya() v = m_env.get_current_version() if not v: return if Representation.repr_separator in v.take_name: return # skip if it is a Character skip_types = ['character', 'animation', 'previs', 'vehicle'] for t in v.naming_parents: for st in skip_types: if t.type and t.type.name.lower().startswith(st): return from anima.env.mayaEnv import repr_tools gen = repr_tools.RepresentationGenerator(version=v) gen.generate_all() # re-open the original scene m_env = mayaEnv.Maya() current_version = m_env.get_current_version() if current_version != v: m_env.open(v, force=True, skip_update_check=True)
def generate_repr_of_all_references(cls, generate_gpu=True, generate_ass=True, generate_rs=True, skip_existing=False): """generates all representations of all references of this scene """ from anima.ui.progress_dialog import ProgressDialogManager from anima.env.mayaEnv import Maya, repr_tools, auxiliary reload(auxiliary) reload(repr_tools) paths_visited = [] versions_to_visit = [] versions_cannot_be_published = [] # generate a sorted version list # and visit each reference only once from anima.env.mayaEnv import MayaMainProgressBarWrapper wrp = MayaMainProgressBarWrapper() pdm = ProgressDialogManager(dialog=wrp) use_progress_window = False if not pm.general.about(batch=1): use_progress_window = True all_refs = pm.listReferences(recursive=True) pdm.use_ui = use_progress_window caller = pdm.register(len(all_refs), 'List References') for ref in reversed(all_refs): ref_path = str(ref.path) caller.step(message=ref_path) if ref_path not in paths_visited: v = ref.version if v is not None: paths_visited.append(ref_path) versions_to_visit.append(v) response = pm.confirmDialog( title='Do Create Representations?', message='Create all Repr. for all %s FileReferences?' % len(versions_to_visit), button=['Yes', 'No'], defaultButton='No', cancelButton='No', dismissString='No' ) if response == 'No': return # register a new caller caller = pdm.register(max_iteration=len(versions_to_visit), title='Generate Reprs') m_env = Maya() source_version = m_env.get_current_version() gen = repr_tools.RepresentationGenerator() # open each version from stalker import Version for v in versions_to_visit: local_generate_gpu = generate_gpu local_generate_ass = generate_ass local_generate_rs = generate_rs # check if this is a repr if '@' in v.take_name: # use the parent v = v.parent if not v: continue if skip_existing: # check if there is a GPU or ASS repr # generated from this version child_versions = Version.query.filter(Version.parent == v).all() for cv in child_versions: if local_generate_gpu is True and '@GPU' in cv.take_name: local_generate_gpu = False if local_generate_ass is True and '@ASS' in cv.take_name: local_generate_ass = False if local_generate_rs is True and '@RS' in cv.take_name: local_generate_rs = False gen.version = v # generate representations if local_generate_gpu: try: gen.generate_gpu() except RuntimeError: if v not in versions_cannot_be_published: versions_cannot_be_published.append(v) if local_generate_ass: try: gen.generate_ass() except RuntimeError: if v not in versions_cannot_be_published: versions_cannot_be_published.append(v) if local_generate_rs: try: gen.generate_rs() except RuntimeError: if v not in versions_cannot_be_published: versions_cannot_be_published.append(v) caller.step() # now open the source version again m_env.open(source_version, force=True, skip_update_check=True) # and generate representation for the source gen.version = source_version # generate representations if not versions_cannot_be_published: if generate_gpu: gen.generate_gpu() if generate_ass: gen.generate_ass() if generate_rs: gen.generate_rs() else: pm.confirmDialog( title='Error', message='The following versions can not be published ' '(check script editor):\n\n%s' % ( '\n'.join( map(lambda x: x.nice_name, versions_cannot_be_published) ) ), button=['OK'], defaultButton='OK', cancelButton='OK', dismissString='OK' ) pm.error( '\n'.join( map(lambda x: x.absolute_full_path, versions_cannot_be_published) ) )
def generate_repr_of_scene(cls, generate_gpu=True, generate_ass=True, generate_rs=True, skip_existing=False): """generates desired representations of this scene """ from anima.ui.progress_dialog import ProgressDialogManager from anima.env.mayaEnv import Maya, repr_tools, auxiliary reload(auxiliary) reload(repr_tools) response = pm.confirmDialog( title='Do Create Representations?', message='Create all Repr. for this scene?', button=['Yes', 'No'], defaultButton='No', cancelButton='No', dismissString='No' ) if response == 'No': return # register a new caller from anima.env.mayaEnv import MayaMainProgressBarWrapper wrp = MayaMainProgressBarWrapper() pdm = ProgressDialogManager(dialog=wrp) m_env = Maya() source_version = m_env.get_current_version() gen = repr_tools.RepresentationGenerator() # open each version from stalker import Version if skip_existing: # check if there is a GPU or ASS repr # generated from this version child_versions = \ Version.query.filter(Version.parent == source_version).all() for cv in child_versions: if generate_gpu is True and '@GPU' in cv.take_name: generate_gpu = False if generate_ass is True and '@ASS' in cv.take_name: generate_ass = False if generate_rs is True and '@RS' in cv.take_name: generate_rs = False total_number_of_reprs = generate_gpu + generate_ass + generate_rs caller = pdm.register(total_number_of_reprs, title='Generate Reprs') gen.version = source_version # generate representations if generate_gpu: gen.generate_gpu() caller.step() if generate_ass: gen.generate_ass() caller.step() if generate_rs: gen.generate_rs() caller.step() # now open the source version again m_env.open(source_version, force=True, skip_update_check=True)