예제 #1
0
 def add(self):
     """Add the transform to the catalog."""
     cmds.colorManagementCatalog(
         addTransform=self.name,
         type=self.type(),
         path=self.path,
         transformConnection=self.transformConnection)
예제 #2
0
파일: core.py 프로젝트: chiaxin/shaderSpace
def _setColorProfileNew(filenode, colorProfile):
    if colorProfile in mc.colorManagementCatalog(ltc=True, type="input"):
        mc.setAttr(filenode + ".colorSpace", colorProfile, typ="string")
    else:
        mc.warning("The {0} is not in color transforms".format(colorProfile))
예제 #3
0
class Dialog(object):

    _dirSrc = maya.stringTable['y_customTransformUI.kColorMgtDirSrc']
    _dirDst = maya.stringTable['y_customTransformUI.kColorMgtDirDst']
    _extensions = cmds.colorManagementCatalog(listSupportedExtensions=True)

    def __init__(self, path='', name='', transformConnection=''):

        self.path = path
        self.name = name
        self.transformConnection = transformConnection
        self._pathWidget = None
        self._nameWidget = None
        self._transformConnectionWidget = None

    def show(self):

        titleString = maya.stringTable[
            'y_customTransformUI.kColorMgtCustomTransformUI'] % self.title()

        return cmds.layoutDialog(ui=self.build, title=titleString)

    def build(self):

        # Get the layoutDialog's formLayout.
        #
        form = cmds.setParent(q=True)

        # layoutDialog's are unfortunately not resizable, so hard code a size
        # here, to make sure all UI elements are visible.
        #
        cmds.formLayout(form, e=True, width=500)

        self._pathWidget = cmds.textFieldGrp(
            ad2=2,
            label=maya.stringTable[
                'y_customTransformUI.kColorMgtCustomTransformFilePath'],
            text=self.path)

        browseIcon = cmds.symbolButton(image="navButtonBrowse.png",
                                       command=self.onPathBrowse)

        self._nameWidget = cmds.textFieldGrp(
            ad2=2,
            label=maya.
            stringTable['y_customTransformUI.kColorMgtCustomTransformName'],
            text=self.name)

        transformConnectionLabel = maya.stringTable['y_customTransformUI.kColorMgtTransformConnection' ]\
                          % self.direction()
        self._transformConnectionWidget = cmds.optionMenuGrp(
            ad2=2, label=transformConnectionLabel)

        transformConnections = cmds.colorManagementCatalog(
            listTransformConnections=True, type=self.type())
        for transformConnection in transformConnections:
            cmds.menuItem(label=transformConnection)
        cmds.setParent('..', menu=True)

        saveBtn = cmds.button(
            label=maya.stringTable['y_customTransformUI.kSave'],
            command=partial(self.onDismissButton, msg='save'))

        cancelBtn = cmds.button(
            label=maya.stringTable['y_customTransformUI.kCancel'],
            command=partial(self.onDismissButton, msg='cancel'))

        vSpc = 10
        hSpc = 10
        rSpc = 50

        cmds.formLayout(
            form,
            edit=True,
            attachForm=[(self._pathWidget, 'top', vSpc),
                        (self._pathWidget, 'left', 0),
                        (browseIcon, 'top', vSpc), (browseIcon, 'right', 0),
                        (self._nameWidget, 'left', 0),
                        (self._nameWidget, 'right', rSpc),
                        (self._transformConnectionWidget, 'left', 0),
                        (self._transformConnectionWidget, 'right', rSpc),
                        (saveBtn, 'bottom', vSpc), (cancelBtn, 'bottom', vSpc),
                        (cancelBtn, 'right', hSpc)],
            attachControl=[
                (self._pathWidget, 'right', 0, browseIcon),
                (self._nameWidget, 'top', vSpc, self._pathWidget),
                (self._transformConnectionWidget, 'top', vSpc,
                 self._nameWidget),
                (saveBtn, 'top', vSpc, self._transformConnectionWidget),
                (cancelBtn, 'top', vSpc, self._transformConnectionWidget),
                (saveBtn, 'right', hSpc, cancelBtn)
            ])

    def onPathBrowse(self, data):
        # No documentation for symbolButton command script argument in
        # Python, but it is of type boolean, and Python complains of
        # missing argument if omitted.

        multiFilter = maya.stringTable['y_customTransformUI.kTransformFiles']
        multiFilter += ' ('
        for extension in Dialog._extensions:
            multiFilter += ' *.' + extension
        multiFilter += ')'

        selectedPath = cmds.fileDialog2(fileMode=1, fileFilter=multiFilter)

        if selectedPath is not None and len(selectedPath[0]) > 0:
            cmds.textFieldGrp(self._pathWidget,
                              edit=True,
                              text=selectedPath[0])

    def onDismissButton(self, data, msg):
        # Same comment for data argument as for onPathBrowse() method.

        # Copy widget data.
        self.path = cmds.textFieldGrp(self._pathWidget, query=True, text=True)
        self.name = cmds.textFieldGrp(self._nameWidget, query=True, text=True)
        self.transformConnection = cmds.optionMenuGrp(
            self._transformConnectionWidget, query=True, value=True)

        cmds.layoutDialog(dismiss=msg)

    def add(self):
        """Add the transform to the catalog."""
        cmds.colorManagementCatalog(
            addTransform=self.name,
            type=self.type(),
            path=self.path,
            transformConnection=self.transformConnection)

    def remove(self):
        """Remove the transform from the catalog."""
        cmds.colorManagementCatalog(removeTransform=self.name,
                                    type=self.type())
예제 #4
0
 def remove(self):
     """Remove the transform from the catalog."""
     cmds.colorManagementCatalog(removeTransform=self.name,
                                 type=self.type())
예제 #5
0
    def build(self):

        # Get the layoutDialog's formLayout.
        #
        form = cmds.setParent(q=True)

        # layoutDialog's are unfortunately not resizable, so hard code a size
        # here, to make sure all UI elements are visible.
        #
        cmds.formLayout(form, e=True, width=500)

        self._pathWidget = cmds.textFieldGrp(
            ad2=2,
            label=maya.stringTable[
                'y_customTransformUI.kColorMgtCustomTransformFilePath'],
            text=self.path)

        browseIcon = cmds.symbolButton(image="navButtonBrowse.png",
                                       command=self.onPathBrowse)

        self._nameWidget = cmds.textFieldGrp(
            ad2=2,
            label=maya.
            stringTable['y_customTransformUI.kColorMgtCustomTransformName'],
            text=self.name)

        transformConnectionLabel = maya.stringTable['y_customTransformUI.kColorMgtTransformConnection' ]\
                          % self.direction()
        self._transformConnectionWidget = cmds.optionMenuGrp(
            ad2=2, label=transformConnectionLabel)

        transformConnections = cmds.colorManagementCatalog(
            listTransformConnections=True, type=self.type())
        for transformConnection in transformConnections:
            cmds.menuItem(label=transformConnection)
        cmds.setParent('..', menu=True)

        saveBtn = cmds.button(
            label=maya.stringTable['y_customTransformUI.kSave'],
            command=partial(self.onDismissButton, msg='save'))

        cancelBtn = cmds.button(
            label=maya.stringTable['y_customTransformUI.kCancel'],
            command=partial(self.onDismissButton, msg='cancel'))

        vSpc = 10
        hSpc = 10
        rSpc = 50

        cmds.formLayout(
            form,
            edit=True,
            attachForm=[(self._pathWidget, 'top', vSpc),
                        (self._pathWidget, 'left', 0),
                        (browseIcon, 'top', vSpc), (browseIcon, 'right', 0),
                        (self._nameWidget, 'left', 0),
                        (self._nameWidget, 'right', rSpc),
                        (self._transformConnectionWidget, 'left', 0),
                        (self._transformConnectionWidget, 'right', rSpc),
                        (saveBtn, 'bottom', vSpc), (cancelBtn, 'bottom', vSpc),
                        (cancelBtn, 'right', hSpc)],
            attachControl=[
                (self._pathWidget, 'right', 0, browseIcon),
                (self._nameWidget, 'top', vSpc, self._pathWidget),
                (self._transformConnectionWidget, 'top', vSpc,
                 self._nameWidget),
                (saveBtn, 'top', vSpc, self._transformConnectionWidget),
                (cancelBtn, 'top', vSpc, self._transformConnectionWidget),
                (saveBtn, 'right', hSpc, cancelBtn)
            ])