예제 #1
0
 def test_listReferences_options(self):
     expectedRefs = set([pm.FileReference(namespace='sphere1'),
                         pm.FileReference(namespace='sphere2'),
                         pm.FileReference(namespace='cube1'),
                         pm.FileReference(namespace='cone1'),
                        ])
     self._test_listReferences_options(expectedRefs, {})
예제 #2
0
    def createFailedEdits(self):
        # Animate the zombieAttrs
        for transform in [x.getParent() for x in pm.ls(type='mesh')]:
            try:
                zombie = transform.attr('zombieAttr')
            except pm.MayaAttributeError:
                continue
            zombie.setKey(t=1, v=1)
            zombie.setKey(t=2, v=2)
            zombie.setKey(t=3, v=4)

        # want to create another successful edit, so we can tell just by number of edits
        # whether we got failed, successful, or both
        #   failed = 1
        #   successful = 2
        #   both = 3
        pm.setAttr(self.sphereRef1.namespace + ':pSphere1.rotate', (30, 0, 0))

        self.masterFile = pm.saveAs(os.path.join(self.temp, 'master.ma'), f=1)

        # deleting the attr should give some failed ref edits in the master...
        pm.openFile(self.sphereFile, f=1)
        pm.SCENE.pSphere1.zombieAttr.delete()
        pm.saveFile(f=1)

        pm.openFile(self.masterFile, f=1)
        self.sphereRef1 = pm.FileReference(namespace='sphere1')
        self.sphereRef2 = pm.FileReference(namespace='sphere2')
        self.cubeRef1 = pm.FileReference(namespace='cube1')
        self.coneRef1 = pm.FileReference(namespace='cone1')
예제 #3
0
 def test_file_reference_creation(self):
     for ref in pm.listReferences(recursive=True):
         self.assertEqual(ref, pm.FileReference(pm.PyNode(ref.refNode)))
         self.assertEqual(ref, pm.FileReference(str(ref.refNode)))
         self.assertEqual(ref, pm.FileReference(pm.Path(ref.withCopyNumber())))
         self.assertEqual(ref, pm.FileReference(str(ref.withCopyNumber())))
         self.assertEqual(ref, pm.FileReference(namespace=ref.fullNamespace))
예제 #4
0
 def test_listReferences(self):
     self.assertEqual(set(pm.listReferences()),
                      set([pm.FileReference(namespace='sphere1'),
                           pm.FileReference(namespace='sphere2'),
                           pm.FileReference(namespace='cube1'),
                           pm.FileReference(namespace='cone1'),
                          ]))
예제 #5
0
    def test_parent(self):
        self.assertEqual(pm.FileReference(namespace='sphere1').parent(), None)
        self.assertEqual(pm.FileReference(namespace='sphere2').parent(), None)
        self.assertEqual(pm.FileReference(namespace='cube1').parent(), None)
        self.assertEqual(pm.FileReference(namespace='cone1').parent(), None)

        self.assertEqual(pm.FileReference(namespace='cube1:sphere').parent(),
                         pm.FileReference(namespace='cube1'))
        self.assertEqual(pm.FileReference(namespace='cone1:cubeInCone').parent(),
                         pm.FileReference(namespace='cone1'))
        self.assertEqual(pm.FileReference(namespace='cone1:cubeInCone:sphere').parent(),
                         pm.FileReference(namespace='cone1:cubeInCone'))
예제 #6
0
def toggleSecondaryRef():
    curscene = pm.workspace.path
    facialRig_file = curscene.__div__(
        'scenes/Model/CH/01_KG/_temp/facialRig/NS57_KG_facialRig.mb'
    )  # path to character facialRig file
    rootCtrl = pm.PyNode('CH_Ctrl_Reference')  # name of Root
    rootFacialAtr = rootCtrl.attr('Facial_Ref')  # name of customAttribute
    if rootCtrl.Secondary_Ref.get() is True:
        pm.FileReference(facialRig_file).load()
    elif rootCtrl.Secondary_Ref.get() is False:
        pm.FileReference(facialRig_file).unload()
    pm.select(rootCtrl)
def run():
    if pm.ls(sl=True):
        for x in pm.ls(sl=True):
            layers = td_tools.which_render_layers(x)
            ref_obj = td_tools.ReferenceObj(x)
            print layers
            ref = pm.FileReference(ref_obj.file)
            proxy_file = get_proxy_for_selected_reference(x)
            ref.remove()
            # import proxy
            dets = pft.PathDetails.parse_path(proxy_file)
            name_space = dets.shot
            try:
                pm.system.namespace(add=name_space)
            except RuntimeError:
                pass
            pm.system.namespace(set=name_space)
            pm.importFile(proxy_file)
            pm.system.namespace(set=':')
            sel = pm.PyNode('%s:ArnoldStandIn' % name_space)
            sel.rename('%s:%s_mdl' % (name_space, name_space))
            # add this to all the render layers.
            print 'trying to add this:  %s:%s_mdl' % (name_space, name_space)
            td_tools.set_render_layers('%s:%s_mdl' % (name_space, name_space),
                                       layers)
    else:
        pm.warning(u'请先选中需要替换的参考内容')
예제 #8
0
 def test_file_reference_remove_merge_namespace_parent(self):
     pm.openFile(self.masterFile, f=1)
     self.sphereRef1 = pm.FileReference(namespace='sphere1')
     pm.system.Namespace('sphere1').setCurrent()
     pm.system.Namespace.create('foobar')
     pm.system.Namespace('sphere1:foobar').setCurrent()
     pm.modeling.polyCube(n='testCube')
     self.tempRef1 = pm.system.createReference(self.sphereFile,
                                               namespace='foobar')
     pm.modeling.polyCube(n=':sphere1:foobar:foobar:bob')
     self.assertTrue(cmds.objExists(':sphere1:foobar:testCube'))
     self.assertTrue(cmds.objExists(':sphere1:foobar:foobar:bob'))
     self.assertFalse(cmds.objExists(':testCube'))
     self.assertFalse(cmds.objExists(':sphere1:testCube'))
     self.assertFalse(cmds.objExists(':sphere1:foobar1:testCube'))
     self.assertFalse(cmds.objExists(':sphere1:foobar:foobar:testCube'))
     self.assertFalse(cmds.objExists(':bob'))
     self.assertFalse(cmds.objExists(':sphere1:bob'))
     self.assertFalse(cmds.objExists(':sphere1:foobar:bob'))
     self.assertFalse(cmds.objExists(':sphere1:foobar1:bob'))
     pm.system.FileReference(
         self.tempRef1).remove(mergeNamespaceWithParent=1)
     self.assertTrue(cmds.objExists(':sphere1:foobar:testCube'))
     self.assertTrue(cmds.objExists(':sphere1:foobar:bob'))
     self.assertFalse(cmds.objExists(':testCube'))
     self.assertFalse(cmds.objExists(':sphere1:testCube'))
     self.assertFalse(cmds.objExists(':sphere1:foobar1:testCube'))
     self.assertFalse(cmds.objExists(':sphere1:foobar:foobar:testCube'))
     self.assertFalse(cmds.objExists(':bob'))
     self.assertFalse(cmds.objExists(':sphere1:bob'))
     self.assertFalse(cmds.objExists(':sphere1:foobar1:bob'))
     self.assertFalse(cmds.objExists(':sphere1:foobar:foobar:bob'))
예제 #9
0
 def test_file_reference_remove_force(self):
     pm.openFile(self.masterFile, f=1)
     self.sphereRef1 = pm.FileReference(namespace='sphere1')
     pm.system.Namespace('sphere1').setCurrent()
     pm.modeling.polyCube(n='testCube')
     pm.system.FileReference(self.sphereRef1).remove(force=True)
     self.assertFalse(pm.general.objExists('testCube'))
예제 #10
0
 def import_reference_delete_namespace(self):
     import pymel.core as pm
     for r in pm.listReferences():
         print r.fullNamespace
         pm.FileReference(namespace=r.fullNamespace).importContents(
             removeNamespace=True)
     print('References imported\nNamespace deleted')
예제 #11
0
def analizeVersions():
    brunch = analizeShotSC()['brunch']
    # Check ASSETS VERSIONS
    wrongVersions = []
    listRefAssets = pm.getReferences().keys(
    )  # Get CODES of referenced FILES in current scene
    print 'dnaCore.analizeVersions [ listRefAssets ]: {}'.format(listRefAssets)
    for i in listRefAssets:  # For ecah REFERENCE: Check existing VER, check VER in FTRACK. IF missmatch : ADD to << wrongVersions variable>>
        pathRef = pm.FileReference(namespace=i)
        dataFileName = fileActs(pathRef)  # Get DATA from file PATH
        verLoad = dataFileName['fileVresion']  # Version in SCENE
        assetType = dataFileName['assetType']
        assetNameFull = i
        if assetNameFull:  # Check if assetNameFull is NOT empty
            if not buildAssetDic(
                    i) == None:  # Check if ASSET exists in DATABASE
                if assetType == 'environments':  # Fix KEY for environments
                    brunch = 'GEO'
                pathRefFT = buildAssetDic(i)[brunch]
                print 'dnaCore.analizeVersions [ pathRefFT ]: {}'.format(
                    pathRefFT)
                verFT = pathRefFT.split('_')[-1].split('.')[0]
                if not verLoad == verFT:
                    wrongVersions.append(i)
    return wrongVersions
예제 #12
0
 def test_file_reference_remove_merge_namespace_root(self):
     pm.openFile(self.masterFile, f=1)
     self.sphereRef1 = pm.FileReference(namespace='sphere1')
     pm.system.Namespace('sphere1').setCurrent()
     pm.modeling.polyCube(n='testCube')
     pm.system.FileReference(
         self.sphereRef1).remove(mergeNamespaceWithRoot=1)
     self.assertIn('testCube', pm.system.namespaceInfo(':', ls=1))
예제 #13
0
def delAsset():
    brunch = analizeShotSC()['brunch']
    dataShotSC = analizeShotSC()  # Get SHOT data from SCENE
    dataShotFT = analizeShotFT()  # Get SHOT data from DATABASE
    extraAssets = set(dataShotSC['scn_AST']) - set(dataShotFT['ftr_AST'])
    for i in extraAssets:
        a = pm.FileReference(namespace=i).remove()
        print '<<  DELETED ASSET: {}  >>'.format(i)
예제 #14
0
def delete(node):
	if pm.referenceQuery(node, inr = True):
		refFile = pm.referenceQuery(node, f = True)
		ref = pm.FileReference(refFile)
		ref.remove()
		return
	for child in node.listRelatives(c=True):
		delete(child)
	pm.delete(node)
예제 #15
0
    def deleteAsset(self, refNodes):
        namespace = refNodes[0].associatedNamespace(baseName=False)

        for ref in refNodes:
            pm.FileReference(ref).remove()

        # remove the namespace and any nodes that may still exist in it
        if pm.namespace(exists=namespace):
            pm.namespace(dnc=True, rm=namespace)
예제 #16
0
 def getRefNodes(self):
     nodes = []
     for node in pc.ls(type=pc.nt.Reference):
         if not node.referenceFile():
             continue
         try:
             nodes.append(pc.FileReference(node))
         except:
             pass
     return nodes
예제 #17
0
    def remap_paths(self):

        for ref in self.refs:

            if ref['type'] == 'reference':
                r = pm.FileReference(ref['node'])

                r.unload()
                r.replaceWith(os.path.normpath(ref['path']).replace(os.path.normpath(self.project_path), '$' + self.project_env_var), loadReferenceDepth='none')
                r.load()
예제 #18
0
 def test_listReferences_recursive(self):
     self.assertEqual(set(pm.listReferences(recursive=True)),
                      set([pm.FileReference(namespace='sphere1'),
                           pm.FileReference(namespace='sphere2'),
                           pm.FileReference(namespace='cube1'),
                           pm.FileReference(namespace='cone1'),
                           pm.FileReference(namespace='cube1:sphere'),
                           pm.FileReference(namespace='cone1:cubeInCone'),
                           pm.FileReference(namespace='cone1:cubeInCone:sphere'),
                          ]))
예제 #19
0
 def test_listReferences_options_recursive(self):
     expectedRefs = set([pm.FileReference(namespace='sphere1'),
                         pm.FileReference(namespace='sphere2'),
                         pm.FileReference(namespace='cube1'),
                         pm.FileReference(namespace='cone1'),
                         pm.FileReference(namespace='cube1:sphere'),
                         pm.FileReference(namespace='cone1:cubeInCone'),
                         pm.FileReference(namespace='cone1:cubeInCone:sphere'),
                        ])
     self._test_listReferences_options(expectedRefs, {'recursive':True})
예제 #20
0
def Import():

    loadAlembic()

    directory = pm.workspace.path

    fileFilter = "Alembic Files (*.abc)"
    files = pm.fileDialog2(fileFilter=fileFilter,
                           dialogStyle=1,
                           fileMode=4,
                           dir=directory)

    if files:
        for f in files:
            filename = os.path.splitext(os.path.basename(f))[0]
            groupname = filename + '_grp'
            newNodes = cmds.file(f,
                                 reference=True,
                                 namespace=filename,
                                 groupReference=True,
                                 groupName=groupname,
                                 returnNewNodes=True)
            refNode = pm.FileReference(f).refNode
            print refNode

            assets = set()
            new_namespace = 'assets'
            for node in newNodes:
                node = pm.PyNode(node)
                if node.hasAttr('assetid'):
                    assetid = node.assetid.get()
                    asset_name = assetid.split('/')[0]
                    assets.add(asset_name)

            if len(assets) == 1:
                asset = list(assets)[0]
                i = 1
                while pm.namespace(
                        ex='{}_{}'.format(asset, (str(i).zfill(2)))):
                    i += 1
                new_namespace = '{}_{}'.format(asset, (str(i).zfill(2)))
                new_group = new_namespace + '_grp'
                ns = filename.replace('.', '_')
                pm.namespace(ren=(ns, new_namespace))
                pm.rename(groupname, new_group)
                refNode.unlock()
                pm.rename(refNode, new_namespace + 'RN')
                refNode.lock()

            for node in newNodes:
                if node == '|NewReference':
                    pm.rename('%s:grp' % filename)
예제 #21
0
 def test_file_reference_remove_merge_namespace_parent(self):
     pm.openFile(self.masterFile, f=1)
     self.sphereRef1 = pm.FileReference(namespace='sphere1')
     pm.system.Namespace('sphere1').setCurrent()
     pm.system.Namespace.create('foobar')
     pm.system.Namespace('sphere1:foobar').setCurrent()
     pm.modeling.polyCube(n='testCube')
     self.tempRef1 = pm.system.createReference(self.sphereFile,
                                               namespace='foobar')
     pm.system.FileReference(
         self.tempRef1).remove(mergeNamespaceWithParent=1)
     self.assertIn('sphere1:testCube',
                   pm.system.namespaceInfo('sphere1', ls=1))
예제 #22
0
        def loadedRefPermutations(parentReference=None):
            '''Returns dicts mapping from namespaces to whether they are loaded
            or not

            Returns all possible such dicts, taking into account the fact that
            if a ref is unloaded, all it's subrefs will also be unloaded (and,
            in fact, won't even seem to exist)
            '''
            finalPermutations = []

            namespaces = pm.listReferences(parentReference=parentReference,
                                           namespaces=True,
                                           references=False)

            # now, get all the possible permutations for each sub-ref, assuming
            # that sub-ref is loaded

            subPermutationsByNS = {}
            for namespace in namespaces:
                subsForNS = loadedRefPermutations(
                    parentReference=pm.FileReference(namespace=namespace))
                if subsForNS:
                    subPermutationsByNS[namespace] = subsForNS

            # Now get all loaded/unloaded permutations for top namespaces...
            for loadedVals in itertools.product((True, False),
                                                repeat=len(namespaces)):
                topByNamespace = dict(zip(namespaces, loadedVals))

                # then, find any sub-permutations for refs which are loaded
                possibleSubPermutations = []
                for ns, loaded in topByNamespace.iteritems():
                    if loaded and ns in subPermutationsByNS:
                        possibleSubPermutations.append(subPermutationsByNS[ns])

                # finally, if we iterate over all the products of all possible
                # sub-perms, and combine all the resulting dicts, we should
                # get all the final permutations...
                if possibleSubPermutations:
                    for subPermSelections in itertools.product(
                            *possibleSubPermutations):
                        topCopy = dict(topByNamespace)
                        for subPermItem in subPermSelections:
                            topCopy.update(subPermItem)
                        finalPermutations.append(topCopy)
                else:
                    # there are no sub-permutations, just append the current
                    # permutation for top-level refs
                    finalPermutations.append(topByNamespace)
            return finalPermutations
예제 #23
0
def getCombinedMesh(ref):
    '''returns the top level meshes from a reference node'''
    meshes = []
    if ref:
        for node in pc.FileReference(ref).nodes():
            if type(node) == pc.nt.Mesh:
                try:
                    node.firstParent().firstParent()
                except pc.MayaNodeError:
                    if not node.isIntermediate():
                        meshes.append(node.firstParent())
                except Exception as ex:
                    print 'Error: %r: %r' % (type(ex), ex)
    return meshes
예제 #24
0
 def test_file_reference_remove_merge_namespace_parent(self):
     pm.openFile(self.masterFile, f=1)
     self.sphereRef1 = pm.FileReference(namespace='sphere1')
     pm.system.Namespace('sphere1').setCurrent()
     pm.system.Namespace.create('foobar')
     pm.system.Namespace('sphere1:foobar').setCurrent()
     pm.modeling.polyCube(n='testCube')
     self.tempRef1 = pm.system.createReference(self.sphereFile,
                                               namespace='foobar')
     pm.modeling.polyCube(n=':sphere1:foobar:foobar:bob')
     self.assertTrue(cmds.objExists(':sphere1:foobar:testCube'))
     self.assertTrue(cmds.objExists(':sphere1:foobar:foobar:bob'))
     self.assertFalse(cmds.objExists(':testCube'))
     self.assertFalse(cmds.objExists(':sphere1:testCube'))
     self.assertFalse(cmds.objExists(':sphere1:foobar1:testCube'))
     self.assertFalse(cmds.objExists(':sphere1:foobar:foobar:testCube'))
     self.assertFalse(cmds.objExists(':bob'))
     self.assertFalse(cmds.objExists(':sphere1:bob'))
     self.assertFalse(cmds.objExists(':sphere1:foobar:bob'))
     self.assertFalse(cmds.objExists(':sphere1:foobar1:bob'))
     pm.system.FileReference(
         self.tempRef1).remove(mergeNamespaceWithParent=1)
     # Before maya 2018, there was a bug where removing the ref, which lives
     # in "sphere1:foobar:foobar", would also delete "sphere1:foobar" -
     # leaving just "sphere1:", where everything was moved into...
     if pymel.versions.current() < pymel.versions.v2018:
         # when it deletes sphere1:foobar, it tries to move sphere1:foobar:foobar
         # to sphere1:foobar... but apparently that causes a name conflict,
         # so it makes sphere1:foobar1 instead
         self.assertTrue(cmds.objExists(':sphere1:testCube'))
         self.assertTrue(cmds.objExists(':sphere1:foobar1:bob'))
         self.assertFalse(cmds.objExists(':testCube'))
         self.assertFalse(cmds.objExists(':sphere1:foobar:testCube'))
         self.assertFalse(cmds.objExists(':sphere1:foobar1:testCube'))
         self.assertFalse(cmds.objExists(':sphere1:foobar:foobar:testCube'))
         self.assertFalse(cmds.objExists(':bob'))
         self.assertFalse(cmds.objExists(':sphere1:bob'))
         self.assertFalse(cmds.objExists(':sphere1:foobar:bob'))
         self.assertFalse(cmds.objExists(':sphere1:foobar:foobar:bob'))
     else:
         self.assertTrue(cmds.objExists(':sphere1:foobar:testCube'))
         self.assertTrue(cmds.objExists(':sphere1:foobar:bob'))
         self.assertFalse(cmds.objExists(':testCube'))
         self.assertFalse(cmds.objExists(':sphere1:testCube'))
         self.assertFalse(cmds.objExists(':sphere1:foobar1:testCube'))
         self.assertFalse(cmds.objExists(':sphere1:foobar:foobar:testCube'))
         self.assertFalse(cmds.objExists(':bob'))
         self.assertFalse(cmds.objExists(':sphere1:bob'))
         self.assertFalse(cmds.objExists(':sphere1:foobar1:bob'))
         self.assertFalse(cmds.objExists(':sphere1:foobar:foobar:bob'))
예제 #25
0
def listReferences(**kwargs):

    bSelected = kwargs.pop("selected", kwargs.pop("sl", False))
    bLocked = kwargs.pop("locked", None)
    bLoaded = kwargs.pop("loaded", None)
    bTopRef = kwargs.pop("topReference", kwargs.pop("top", True))
    excludeFunc = kwargs.pop("exclude", None)

    if bSelected:
        searchList = mc.ls(sl=True , dag=True, referencedNodes=True)
        sRefNodeList = mc.ls(sl=True, type="reference")
        if sRefNodeList:
            searchList.extend(sRefNodeList)
    else:
        searchList = pm.iterReferences(recursive=(not bTopRef))

    sRefNodeList = []
    oFileRefList = []

    for each in searchList:

        oFileRef = None
        if bSelected:
            sRefNode = mc.referenceQuery(each, referenceNode=True, topReference=bTopRef)
        else:
            sRefNode = each.refNode.name()
            oFileRef = each

        if sRefNode in sRefNodeList:
            continue

        sRefNodeList.append(sRefNode)

        if bLocked is not None:
            if (mc.getAttr(sRefNode + ".locked") != bLocked):
                continue

        if bLoaded is not None:
            if (mc.referenceQuery(sRefNode, isLoaded=True) != bLoaded):
                continue

        if not oFileRef:
            oFileRef = pm.FileReference(sRefNode)

        if excludeFunc and excludeFunc(oFileRef):
            continue

        oFileRefList.append(oFileRef)

    return oFileRefList
예제 #26
0
        def doTestForRefPermuation(loadedByNS):
            self.setUp()

            # Note that we always need to track by namespace... we cannot use
            # persistant FileReferences objects, since they are tied to
            # a reference node... and if a parent reference node is unloaded,
            # they may be come invalid

            for ns, loaded in loadedByNS.iteritems():
                if not loaded:
                    ref = pm.FileReference(namespace=ns)
                    if not loaded:
                        print "unloading: %r" % ns
                        ref.unload()

            pprint(loadedByNS)

            # All files should now be set up with the appropriate
            # loaded/unloaded refs... confirm
            for ns, loaded in loadedByNS.iteritems():
                try:
                    wasLoaded = pm.FileReference(namespace=ns).isLoaded()
                except RuntimeError:
                    wasLoaded = False
                self.assertEqual(loaded, wasLoaded)

            doTestForKwargPermutation(None, None, 'all')
            doTestForKwargPermutation(None, True, 'unloaded')
            doTestForKwargPermutation(None, False, 'loaded')

            doTestForKwargPermutation(True, None, 'loaded')
            doTestForKwargPermutation(True, True, 'all')
            doTestForKwargPermutation(True, False, 'loaded')

            doTestForKwargPermutation(False, None, 'unloaded')
            doTestForKwargPermutation(False, True, 'unloaded')
            doTestForKwargPermutation(False, False, 'none')
예제 #27
0
def removeHigh(rigs=None, warn=True):
    """
    Removes the high-poly references.

    Args:
        rigs (list): Rigs to remove high-poly from. If None given will use selected or find rigs in scene.

        warn (boolean): If True, will warn user if no high-poly references of given rigs found.

    Returns:
        (list): File references removed.
    """
    references = set()
    skinned_meshes = set()
    skeleton_meshes = rig.getSkeletonMeshes(rigs=rigs)

    for mesh, data in skeleton_meshes.items():
        reference = pm.FileReference(namespace=mesh.namespace())

        if not reference.namespace.startswith(pcfg.high_poly_namespace):
            continue

        references.add(reference)
        pm.parent(mesh, world=True)
        shapes = mesh.getShapes(
        )  # deformed shape is made when creating deformer, must delete
        shapes = [shape for shape in shapes if not shape.isReferenced()]
        pm.delete(shapes)
        skinned_meshes.add(data['skinned_mesh'])

    for skinned_mesh in skinned_meshes:
        to_delete = skinned_mesh.wraps.get()
        to_delete = json.loads(to_delete)
        pm.delete(
            to_delete[0]
        )  # index 0 is group, rest are proximity deformers that were deleted with deformer shapes
        skinned_mesh.wraps.set('')

    # remove references
    [reference.remove() for reference in references]

    # final display
    if references:
        pm.displayInfo('Removed ' + str(len(references)) +
                       ' high-poly references')
    elif warn:
        pm.warning('No high-poly references found!')

    return references
예제 #28
0
    def fix(self):
        """Update the references."""

        for each in self.errorNodes:
            path = self._make_platform_independent(each['path'])
            ref = pm.FileReference(each['node'])
            try:
                ref.load(path)
            except RuntimeError as e:
                # A RuntimeError gets raised when the reference has nodes
                # from a plugin that is not currently loaded. We can safely
                # ignore this (But we still want to print out the message
                # in case anything goes wrong.
                print e.message

        self.run()
예제 #29
0
def duplicateReference():
	'''
	Duplicate Reference and snap it to position of original
	'''
	item = pm.selected()[0]
	if pm.referenceQuery(item, inr=True)
		ref_node = pm.referenceQuery(item, rfn=True)
		ref_path = pm.FileReference(ref_node).path

		ref_ns = pm.referenceQuery(item, ns=True)
		ref_dup = pm.createReference(ref_path, ns=ref_ns + '1')
		# get root node
		ref_dup.selectAll()
		root_node = pm.selected()[0].root()
		# snap
		pm.delete(pm.parentConstraint(item, root_node, mo=0))
예제 #30
0
    def update_scene(self):
        rx = QtCore.QRegExp("Row_*")
        rx.setPatternSyntax(QtCore.QRegExp.Wildcard)
        for child in self.ui.findChildren(QtWidgets.QWidget, rx):
            asset_file = child.whatsThis()
            version = child.findChild(QtWidgets.QComboBox).currentText()
            reference_file = asset_file.replace(asset_file[-7:-3], version)
            reference_node = child.toolTip()

            if reference_node:  # asset already referenced in scene
                pm.FileReference(
                    refnode=reference_node).replaceWith(reference_file)
            else:
                pm.createReference(reference_file, namespace=":")
        print ">> references loaded/updated",
        self.ui.close()
        return