Пример #1
0
def callUserSetupMel():
    u"""
    最優先の MEL パスに在る ``userSetup.mel`` を呼び出す。
    """
    from maya.mel import eval as mel_eval
    if mel_eval('exists userSetup'):
        mel_eval('source userSetup')
        print('# userSetup.mel is done.')
Пример #2
0
 def Action_SelectBorder():
     maya_cmds.undoInfo(openChunk=True)
     try:
         maya_cmds.ConvertSelectionToEdges()
         maya_cmds.polySelectConstraint(mode=2, type=0x8000, where=1)
         mel_eval('resetPolySelectConstraint')
     except Exception as e:
         print >> stderr, str(e)
     maya_cmds.undoInfo(closeChunk=True)
Пример #3
0
    def Event_Act(self):
        text = self.window.Text_Results.textCursor().selectedText().strip()
        if text == '':
            return

        if self.window.Radio_Attributes.isChecked():
            print(
                '%s = %s' %
                (text,
                 maya_cmds.getAttr(self.window.Line_Attributes.text().strip() +
                                   '.' + text)))
        elif self.window.Radio_CommandsMel.isChecked(
        ) or self.window.Radio_CommandsPython.isChecked():
            try:
                print(maya_cmds.help(text))
            except RuntimeError:
                print(mel_eval('whatIs ' + text))
        elif self.window.Radio_VariablesMel.isChecked():
            print('%s = %s' % (text, mel_eval('$tmp=' + text)))
Пример #4
0
 def Action_SelectAngle(self):
     maya_cmds.undoInfo(openChunk=True)
     try:
         maya_cmds.polySoftEdge(caching=True,
                                angle=self.window.Float_SelectAngle.value())
         maya_cmds.polySelectConstraint(mode=2, type=0x8000, smoothness=1)
         mel_eval('resetPolySelectConstraint')
         maya_cmds.polySelectConstraint(mode=2, type=0x8000, propagate=4)
         mel_eval('resetPolySelectConstraint')
         setA = maya_cmds.sets()
         setB = maya_cmds.sets(
             maya_cmds.polyListComponentConversion(maya_cmds.ls(
                 selection=True, objectsOnly=True),
                                                   toEdge=True))
         maya_cmds.select(maya_cmds.sets(setA, subtract=setB))
         maya_cmds.delete(setA, setB)
     except Exception as e:
         print >> stderr, str(e)
     maya_cmds.undoInfo(closeChunk=True)
Пример #5
0
def initializePlugin(plugin):
    """Called when plugin is loaded.

    Args:
        plugin (MObject): The plugin.
    """
    plugin_fn = OpenMayaMPx.MFnPlugin(plugin)

    try:
        plugin_fn.registerNode(templateDeformer.type_name,
                               templateDeformer.type_id,
                               templateDeformer.creator,
                               templateDeformer.initialize,
                               OpenMayaMPx.MPxNode.kDeformerNode)
    except:
        print "failed to register node {0}".format(templateDeformer.type_name)
        raise

    # Load custom Attribute Editor GUI.
    mel_eval(gui_template)
Пример #6
0
    def __init__later(self):
        self.attributes = []
        self.commandsMel = sorted(maya_cmds.melInfo(),
                                  key=lambda sMel: sMel.lower())
        self.commandsPython = sorted(
            [s[0] for s in getmembers(maya_cmds, callable)],
            key=lambda sPyt: sPyt.lower())
        self.variables = sorted(mel_eval('env'), key=lambda sVar: sVar.lower())

        self.listPtr = self.commandsMel

        self.window.Label_CountAll.setText(str(len(self.commandsMel)))
        self.window.setEnabled(True)
Пример #7
0
def initMels(userPrefs=True, startup=True, plugins=False, namedCommand=True):
    u"""
    各種初期化MELを呼び出す(source する)。

    Maya の設定に依存する処理をしないなら、呼び出さなくても問題はない。

    一度呼び出したMELは繰り返し呼び出さないので、
    この関数を繰り返し呼び出しても問題はない。

    :param `bool` userPrefs:
        ユーザープリファレンスに関連するMELを呼び出すかどうか。
        plugins=True のときは True になる。

    :param `bool` startup:
        initStartup.mel を呼び出すかどうか。
        plugins=True のときは True になる。

    :param `bool` plugins:
        プラグインをオートロードするかどうか。

        プラグインは、シーンの requires で動的に解決されるし、
        バッチ処理で必要な場合は明示的にロードするようにすべきであり、
        処理負荷も大きいので、デフォルトでは False としている。

    :param `bool` namedCommand:
        ネームドコマンドを生成するかどうか。
        ホットキーに mel コードを結びつけるための概念であるため、
        UI が無ければ通常は不要なはずだが、処理負荷は大きくはないため、
        pymelに倣いデフォルトは True としてる。
    """
    #plugins = plugins and ('plugins' not in _initializedMels)
    if plugins:
        userPrefs = True
        startup = True
    userPrefs = userPrefs and ('userPrefs' not in _initializedMels)
    startup = startup and ('startup' not in _initializedMels)
    namedCommand = namedCommand and ('namedCommand' not in _initializedMels)

    try:
        # 呼び出す MEL リスト。
        upAxis = None
        prefs = getUserPrefsDir()
        mels = [
            #### 'defaultRunTimeCommands.mel',  # sourced automatically
            #### prefs + '/userRunTimeCommands.mel',  # sourced automatically
            userPrefs and 'createPreferencesOptVars.mel',
            userPrefs and 'createGlobalOptVars.mel',
            userPrefs and (prefs + '/userPrefs.mel'),
            startup and 'initialStartup.mel',

            #### $HOME/Documents/maya/projects/default/workspace.mel
            plugins and 'initialPlugins.mel',
            plugins and (prefs + '/pluginPrefs.mel'),

            #### 'initialGUI.mel',  # GUI
            #### 'initialLayout.mel',  # GUI
            #### prefs + '/windowPrefs.mel',  # GUI
            #### prefs + '/menuSetPrefs.mel',  # GUI
            #### 'hotkeySetup.mel',  # GUI
            namedCommand and 'namedCommandSetup.mel',
            namedCommand and (prefs + '/userNamedCommands.mel'),

            ####'initAfter.mel',  # GUI
        ]

        # 各 MEL の呼び出し。
        import maya.cmds as cmds
        from maya.mel import eval as mel_eval
        for f in mels:
            if f and (not _os_path_isabs(f) or _os_path_isfile(f)):
                # initialStartup.mel の実行で upAxis の変更が無いセットの warning が出るのを防ぐ。
                if f == 'initialStartup.mel':
                    upAxis = cmds.optionVar(q='upAxisDirection')
                    if upAxis == 'y':
                        cmds.upAxis(axis='z', rv=True)

                try:
                    #print('# ' + f)
                    mel_eval('source "' + f + '"')
                except:
                    pass

    finally:
        # upAxis のセットがうまくいかなかった場合の修復。
        if upAxis and upAxis != cmds.upAxis(q=True, axis=True):
            cmds.upAxis(axis=upAxis, rv=True)

        # 呼び出し済みのやつを記録。
        if plugins:
            _initializedMels.add('plugins')
        if userPrefs:
            _initializedMels.add('userPrefs')
        if startup:
            _initializedMels.add('startup')
        if namedCommand:
            _initializedMels.add('namedCommand')
Пример #8
0
 def Action_LR_Pattern_3():
     maya_cmds.undoInfo(openChunk=True)
     mel_eval('polySelectEdgesPattern edgeRingPattern')
     maya_cmds.undoInfo(closeChunk=True)
Пример #9
0
 def Action_LR_Standart_3(self):
     maya_cmds.undoInfo(openChunk=True)
     mel_eval('polySelectEdgesEveryN edgeRing %d' %
              (self.window.Int_LR_Standart.value()))
     maya_cmds.undoInfo(closeChunk=True)