def getReferencePath(self, node): filepath = '' if isinstance(node, type('')): try: node = pm.PyNode(node) except: pm.warning('Can not figure out what '+str(node)+' is, ignored!') return filepath if pm.referenceQuery(node, isNodeReferenced=True): filepath = pm.referenceQuery(node, filename=True, wcn=True).replace('\\', '/') elif node.nodeType() == 'assemblyReference': l_rep_names = pm.assembly(node, query = True, listRepresentations= True) if not l_rep_names: return '' rep_name = pm.assembly(node, query = True, active = True) if rep_name in l_rep_names: if not rep_name.endswith('.locator'): i = l_rep_names.index(rep_name) filepath = pm.getAttr(node.name() + '.rep['+str(i)+'].rda') else: # Choose locator filepath = node.getAttr('definition') else: # Choose None if self.checkLeveL(node): filepath = node.getAttr('definition') return filepath
def get_angle(self, cam, l_frames): self.d_angles = {} for m in self.l_masters + self.l_unload_ar + self.l_asset_ar: self.d_angles[m.fullPath()] = {'angle':[], 'distance':[]} for frame in l_frames: pm.currentTime(frame) for master in self.l_masters: if pm.objExists(master.name()[:-7] + ':hi'): a, d = self.get_angle_on_cam(master.name()[:-7] + ':hi', cam) else: a, d = self.get_angle_on_cam(master, cam) self.d_angles[master.fullPath()]['angle'].append(a) self.d_angles[master.fullPath()]['distance'].append(d) for ar in self.l_asset_ar + self.l_unload_ar: n = ar active = pm.assembly(ar, query = True, active = True) if active.endswith('.ma'): l_ar_nodes = pm.listRelatives(ar, c=True) for c in l_ar_nodes: if c.name().endswith(':master') and pm.objExists(c.name()[:-7] + ':hi'): n = c.name()[:-7] + ':hi' a, d = self.get_angle_on_cam(n, cam) self.d_angles[ar.fullPath()]['angle'].append(a) self.d_angles[ar.fullPath()]['distance'].append(d) return
# -*- coding: utf-8 -*- """ """ from __future__ import division from __future__ import print_function from __future__ import absolute_import __author__ = 'timmyliang' __email__ = '*****@*****.**' __date__ = '2020-09-27 22:20:18' import os from pymel import core as pm path = pm.sceneName() DIR = os.path.dirname(path) for f in os.listdir(DIR): if not f.endswith(".ma") and not f.endswith(".mb"): continue elif f == os.path.basename(path): continue assembly = pm.ls(sl=1, type="assemblyDefinition") pm.assembly(assembly, edit=True, createRepresentation='Scene', input=f.replace('\\', '/'))
def get_current_representation(self, assembly_name): ''' ''' return pm.assembly(assembly_name, query=True, active=True)