def getRefHandles(refShapes): res = [] for refShape in refShapes: refHandle = RefHandle() refHandle.loadFromRefLocatorShape(refShape) res.append(refHandle) return res
def doReplacement(replaceDB): notExistingSources = set() createdRefs = [] for tr, path in replaceDB.items(): if path in notExistingSources: continue if not os.path.exists(os.path.expandvars(path)): notExistingSources.add(path) log.logAppend('Path does not exists: {}. Replacement skipped.'.format(path)) continue refHandle = RefHandle() refHandle.createNew(path) createdRefs.append(refHandle) worldRP = m.xform(tr, q=True, rotatePivot=True, worldSpace=True) m.xform(refHandle.refLocator.transform, translation=worldRP, absolute=True, worldSpace=True) transformParent = getParent(tr) if transformParent: newRefLocTransform = getLongName(m.parent(refHandle.refLocator.transform, transformParent)[0]) refHandle.setRefLocator(TransformHandle(transform=newRefLocTransform)) rotation = m.xform(tr, q=True, rotation=True, objectSpace=True) scale = m.xform(tr, q=True, scale=True, objectSpace=True, relative=True) shear = m.xform(tr, q=True, shear=True, objectSpace=True, relative=True) m.xform(refHandle.refLocator.transform, rotation=rotation, scale=scale, shear=shear) if m.objExists(tr): m.delete(tr) return createdRefs
def createRef(refFilename): refHandle = RefHandle() refHandle.createNew(refFilename) return refHandle.refLocator.transform