移動先: 概要 戻り値 フラグ. Python 例.

概要

scriptedPanel( [panelName] , [control=boolean], [copy=string], [defineTemplate=string], [docTag=string], [exists=boolean], [init=boolean], [isUnique=boolean], [label=string], [menuBarVisible=boolean], [needsInit=boolean], [parent=string], [popupMenuProcedure=string], [replacePanel=string], [tearOff=boolean], [tearOffCopy=string], [type=string], [unParent=boolean], [useTemplate=string])

注意: オブジェクト名や引数を表す文字列はカンマで区切ります。これは概要には示されていません。

scriptedPanel は 「元に戻す」が可能、「照会」が可能、「編集」が可能 です。

このコマンドは、指定した scriptedPanelType のインスタンスを作成します。パネルはグループ化された UI オブジェクト(ボタン、フィールド、グラフィカル ビュー)の集合で、アプリケーション インタフェース内をグループとして移動する、切り離して独自のウィンドウにすることなどができます。パネルが再配置または再作成される場合、その UI の状態は維持されます。スクリプト パネルは MEL で定義されたパネルで、要求されるすべてのコールバックを MEL プロシージャとして使用できます。

戻り値

stringスクリプト パネルの名前です。

戻り値の型は照会モードでは照会フラグが基になります。

フラグ

control, copy, defineTemplate, docTag, exists, init, isUnique, label, menuBarVisible, needsInit, parent, popupMenuProcedure, replacePanel, tearOff, tearOffCopy, type, unParent, useTemplate
ロング ネーム(ショート ネーム) 引数型 プロパティ
exists(ex) boolean create
指定したオブジェクトが存在するかどうかによって、 true または false を返します。他のフラグは無視されます。
defineTemplate(dt) string create
他の任意のフラグと引数を解析し、かつ引数で指定したコマンド テンプレートに 追加するモードに、コマンドのモードを変更します。 templateName がカレントのテンプレートとして設定されていれば、 その後コマンドが実行されるたびに、この引数がデフォルトの引数として使用されます。
useTemplate(ut) string create
コマンドに、カレント以外のコマンド テンプレートの使用を強制します。
init(init) boolean createedit
パネルのデフォルトの状態を初期化します。これは、file -new と file -open によって自動的に実行されます。
label(l) string queryedit
ユーザが読みやすいパネル用ラベルを指定します。
copy(cp) string edit
このパネルを指定したパネルのコピーにします。両方のパネルは同じタイプである必要があります。
control(ctl) boolean query
このパネルの最上位のコントロールを返します。 通常は、親を取得してポップアップ メニューをアタッチするために使用します。 注意: パネルにはコントロールがないことがあります。コントロールが存在しない場合、このフラグは "" を返します。
isUnique(iu) boolean query
このパネル タイプのインスタンスが 1 つだけ許可されている場合、true を返します。
parent(p) string create
このパネルの親のレイアウトを指定します。
popupMenuProcedure(pmp) string queryedit
パネルのポップアップ メニューを作成するために呼び出されるプロシージャを指定します。 デフォルト値は「buildPanelPopupMenu」です。
unParent(up) boolean edit
パネルをそのレイアウトから削除するように指定します。 照会には使用できません。
replacePanel(rp) string edit
指定したパネルをこのパネルと置き換えます。ターゲット パネルが同じレイアウト内にある場合、入れ替えを実行します。
tearOff(to) boolean queryedit
このパネルを切り離し、パネルの親としての paneLayout を持つフローティング ウィンドウにします。照会すると、パネルが独自のウィンドウに切り離されたかどうかを返します。
tearOffCopy(toc) string create
このパネルを、指定したソース パネルのコピーを切り離したウィンドウとして作成します。
menuBarVisible(mbv) boolean createqueryedit
パネルのメニュー バーを表示するかどうかを制御します。
needsInit(ni) boolean queryedit
(内部)On Edit は、初期化が必要なものとしてパネルをマークします。 照会すると、初期化が必要なものとしてパネルがマークされているかどうかを返します。file -new と file -open で使用されます。
docTag(dtg) string createqueryedit
Maya のパネルにタグをアタッチします。
type(typ) string createquery
このフラグは、作成するスクリプト パネルのタイプを指定します。

: コマンドの作成モードで使用可能なフラグ : コマンドの編集モードで使用可能なフラグ
: コマンドの照会モードで使用可能なフラグ : タプルまたはリストとして渡された複数の引数を持てるフラグ

Python 例

import maya.cmds as cmds

// NOTE: The scriptedPanelType command does not support python
// 		 callbacks; these callbacks must be MEL.


global proc sampleCreateCallback(string $panelName) {
//
//  Description:
//      Create any editors unparented here and do
//      any other initialization required.
//
//      In this example we will only declare a global array to
//        maintain some state information.
//
    global float $gSampleState[5];

}


global proc sampleInitCallback(string $panelName) {
//
//  Description:
//      Re-initialize the panel on file -new or file -open.
//
//      In this example we will only re-init the global array.
//
    global float $gSampleState[];

       $gSampleState[0] = 20.2;
       $gSampleState[1] = 50.5;
       $gSampleState[2] = 34.7;
       $gSampleState[3] = 2.0;
       $gSampleState[4] = 1.0;

}

global proc sampleAddCallback(string $panelName) {
//
//  Description:  Create UI and parent any editors.
//
    global float $gSampleState[];

    columnLayout -adj true topCol;
    separator -style "none" -h 10;
        frameLayout -l "Sliders" -mw 10;
            columnLayout -adj true sampleCol;
                separator -style "none" -h 10;

                floatSliderGrp -l "Property A" -f true
                    -v $gSampleState[0]
                    fsg1;
                floatSliderGrp -l "Property B" -f true
                    -v $gSampleState[1]
                    fsg2;
                floatSliderGrp -l "Property C" -f true
                    -v $gSampleState[2]
                    fsg3;
                separator -style "none" -h 10;
            setParent ..;
        setParent ..;

        separator -style "none" -h 10;
        frameLayout -l "Radio Buttons" -mw 10;
            columnLayout sampleCol2;
                separator -style "none" -h 10;
                radioButtonGrp -nrb 3
                    -l "Big Options"
                    -la3 "Option 1" "Option 2" "Option 3"
                    -select $gSampleState[3]
                    rbg;
                radioButtonGrp -nrb 3
                    -l "Little Options"
                    -la3 "Option 4" "Option 5" "Option 6"
                    -select $gSampleState[4]
                    rbg2;
                separator -style "none" -h 10;

}

global proc sampleRemoveCallback(string $panelName) {
//
//  Description:
//        Unparent any editors and save state if required.
//
        global float $gSampleState[];
       //  Scope the control names to this panel.
       //
       string $control = `scriptedPanel -q -control $panelName`;
       setParent $control;

       $gSampleState[0] = `floatSliderGrp -q -v fsg1`;
       $gSampleState[1] = `floatSliderGrp -q -v fsg2`;
       $gSampleState[2] = `floatSliderGrp -q -v fsg3`;
       $gSampleState[3] = `radioButtonGrp -q -sl rbg`;
       $gSampleState[4] = `radioButtonGrp -q -sl rbg2`;
}

global proc sampleDeleteCallback(string $panelName) {
//
//  Description:
//        Delete any editors and do any other cleanup required.

}

global proc string sampleSaveStateCallback(string $panelName) {
//
//  Description:
//        Return a string that will restore the current state
//        when it is executed.

        global float $gSampleState[];
       $indent = "\n\t\t\t";

       return ($indent+"$gSampleState[0]="+$gSampleState[0]+";" +
               $indent+"$gSampleState[1]="+$gSampleState[1]+";" +
               $indent+"$gSampleState[2]="+$gSampleState[2]+";" +
               $indent+"$gSampleState[3]="+$gSampleState[3]+";" +
               $indent+"$gSampleState[4]="+$gSampleState[4]+";" +
               $indent+"setSamplePanelState $panelName;\n" );
}

global proc setSamplePanelState( string $whichPanel ) {
//
//  Description:
//        This is a convenience proc to set the panel state from the
//        global array

        global float $gSampleState[];

       //  Scope the control names to this panel.
       //
       string $control = `scriptedPanel -q -control $whichPanel`;
       if ("" != $control) {
              setParent $control;

              floatSliderGrp -e -v $gSampleState[0] fsg1;
              floatSliderGrp -e -v $gSampleState[1] fsg2;
              floatSliderGrp -e -v $gSampleState[2] fsg3;
              if (0 != $gSampleState[3]) {
               radioButtonGrp -e -sl $gSampleState[3] rbg;
              };
           if (0 != $gSampleState[4]) {
               radioButtonGrp -e -sl $gSampleState[4] rbg2;
           }
       }
}

# Below is the python code to create and use scriptedPanelType and scriptedPanel using the MEL
# callbacks defined above.

# Use unique flag as we don't want two panels sharing the same global data.
cmds.scriptedPanelType( 'sampleScriptedPanelType', ccb='sampleCreateCallback', icb='sampleInitCallback', acb='sampleAddCallback', rcb='sampleRemoveCallback', dcb='sampleDeleteCallback', scb='sampleSaveStateCallback', unique=True )

#  This script will create an unparented scripted panel, place it
#  in one window, remove it, and place it in another window then
#  return it to the first window.
#
#
#  Create unparented scripted panel
#
cmds.scriptedPanel( 'sampleScriptedPanel', unParent=True, type='sampleScriptedPanelType', label='Sample' )

#    Create a couple of windows and parent the scripted panel to the first.
#
cmds.window( 'sampleWin' )
cmds.frameLayout( 'frm', lv=False, bv=False )
cmds.scriptedPanel( 'sampleScriptedPanel', e=True, parent='sampleWin|frm' )
cmds.showWindow()

cmds.window( 'sampleWin2', w=cmds.window('sampleWin', q=True, w=True), h=cmds.window('sampleWin', q=True, h=True) )
cmds.frameLayout( 'frm', lv=False, bv=False )
cmds.showWindow()

#    Reparent the scripted panel to the second window.
#
cmds.scriptedPanel( 'sampleScriptedPanel', e=True, unParent=True )
cmds.scriptedPanel( 'sampleScriptedPanel', e=True, parent='sampleWin2|frm' )

#    Reparent the scripted panel back to the first window.
#
cmds.scriptedPanel( 'sampleScriptedPanel', e=True, unParent=True )
cmds.scriptedPanel( 'sampleScriptedPanel', e=True, parent='sampleWin|frm' )

#    Close both windows
#
cmds.window( 'sampleWin', e=True, visible=False )
cmds.window( 'sampleWin2', e=True, visible=False )

#    The scripted panel should appear in the Panel menu.  Select
#    Panels->Panel->Sample and the panel should appear in the main window.
#