示例#1
0
    def importRef(self):

        if not self.refExists():
            m.warning('{}: {}: Reference does not exists. Import skipped.'.format(self.refLocator.shape, self.refFilename))
            return

        if not m.objExists(self.importSource):
            self.createRefImportSource()

        importedRefGroup = '{}_{}'.format(REF_IMPORTED_GROUP, self.refShortName)
        obj = m.duplicate(
            self.importSource,
        )
        m.rename(obj[0], importedRefGroup)

        impGroup = '|{}|{}'.format(IMPORT_SOURCE_GROUP, importedRefGroup)

        m.addAttr(
            impGroup,
            dt='string',
            shortName=ATTR_REF_SOURCE_PATH_NAMES[0],
            longName=ATTR_REF_SOURCE_PATH_NAMES[1],
            niceName=ATTR_REF_SOURCE_PATH_NAMES[2]
        )

        m.setAttr('{}.{}'.format(impGroup, ATTR_REF_SOURCE_PATH), self.refFilename, typ='string')
        impGroup = parentAPI(impGroup, self.refLocator.transform, absolute=False)
        refLocatorParents = self.refLocator.getParents()
        refLocatorParent = refLocatorParents[0] if refLocatorParents else None
        parentAPI(impGroup, refLocatorParent)

        m.delete(self.refLocator.transform)
示例#2
0
    def activate(self):
        if self.active:
            return

        if not self.refExists():
            m.warning('{}: {}: Reference does not exists. Activation skipped.'.format(self.refLocator.shape, self.refFilename))
            return

        if not m.objExists(self.instanceSource):
            self.createRefSource()

        m.instance(
            self.instanceSource,
            name=REF_INST_NAME
        )

        inst = '|{}|{}'.format(INSTANCES_SOURCE_GROUP, REF_INST_NAME)
        m.setAttr(inst + '.overrideEnabled', True)
        m.setAttr(inst + '.overrideDisplayType', 2)
        lockTransformations(inst, visibility=True)
        parentAPI(inst, self.refLocator.transform, absolute=False)
        m.connectAttr(self.refNode + '.message', self.refLocator.shape + '.refNodeMessage', force=True)

        self.active = True