ジャンプ先: 概要. 戻り値. フラグ. Python 例.
scriptedPanelType(
[string]
, [addCallback=string], [copyStateCallback=string], [createCallback=string], [customView=boolean], [defineTemplate=string], [deleteCallback=string], [exists=boolean], [hotkeyCtxClient=string], [initCallback=string], [label=string], [obsolete=boolean], [removeCallback=string], [retainOnFileOpen=boolean], [saveStateCallback=string], [unique=boolean], [useTemplate=string])
注: オブジェクトの名前と引数を表す文字列は、カンマで区切る必要があります。これはシノプシスに示されていません。
scriptedPanelType は、取り消し可能、照会可能、および編集可能です。
このコマンドは、スクリプト パネルのタイプに関するコールバックを定義します。このコマンドによって作成されるパネル タイプは、スクリプト パネルの作成時に使用されます。'scriptedPanel' コマンドも参照してください。
| string | スクリプト パネル タイプの名前です。 |
照会モードでは、戻り値のタイプは照会されたフラグに基づきます。
addCallback, copyStateCallback, createCallback, customView, defineTemplate, deleteCallback, exists, hotkeyCtxClient, initCallback, label, obsolete, removeCallback, retainOnFileOpen, saveStateCallback, unique, useTemplate
| ロング ネーム(ショート ネーム) |
引数タイプ |
プロパティ |
|
addCallback(acb)
|
string
|
 
|
|
このフラグは、パネルを特定のコントロール レイアウトに追加するためのコールバック プロシージャを指定します。プロシージャがコールされると、必ず親レイアウトが現在の既定レイアウトになります。親レイアウトの名前が必要な場合は、「setParent -q」を使用して検索できます。エディタはすべてここでペアレント化する必要があります。次のとおりです: global proc procName (string $panelName) { .... }
|
|
copyStateCallback(ocb)
|
string
|
 
|
|
このフラグは、パネルのティアオフ コピーが作成されたときにパネルの状態をコピーするコールバック プロシージャを指定します。コールバック プロシージャの書式は次のとおりです: global proc procName(string $panelName, string $newPanelName) { .... } このプロシージャは、addCallback プロシージャの実行が終了した直後に実行されます。この時点で、コピーされたパネルは完全に作成されてアクセス可能になっており、パネル設定のコピーが容易になります。注: addCallback プロシージャは、createCallback プロシージャがコールされた後でコールされます。
|
|
createCallback(ccb)
|
string
|
 
|
|
このフラグは、まず最初にパネル オブジェクトを作成するためのコールバック プロシージャを指定します。ここでは UI は作成されません。パネルによって所有されるエディタは、ここではペアレント化されずに作成されます。コールバック プロシージャの書式は次のとおりです: global proc procName(string $panelName) { .... }
|
|
customView(cv)
|
boolean
|
 
|
|
このフラグは、このビューが MPx3dModelView タイプに対するカスタム 3D ビューであるかどうかを指定します。このフラグは、MPx3dModelView タイプについてのみ使用してください。
|
|
defineTemplate(dt)
|
string
|
|
|
他の任意のフラグと引数を解析し、かつ引数で指定したコマンド テンプレートに追加するモードに、コマンドのモードを変更します。 templateName が現在のテンプレートとして設定されていれば、その後コマンドが実行されるたびに、この引数が既定の引数として使用されます。
|
|
deleteCallback(dcb)
|
string
|
 
|
|
このフラグは、最後にパネルを削除するためのコールバック プロシージャを指定します。コールバック プロシージャの書式は次のとおりです: global proc procName(string $panelName) { .... }
|
|
exists(ex)
|
boolean
|
|
|
指定したオブジェクトが存在するかどうかを返します。他のフラグは無視されます。
|
|
hotkeyCtxClient(hkc)
|
string
|
 
|
|
このフラグは、このパネル タイプに対するホットキー コンテキスト クライアントの名前を指定するために使用されます。既定では、パネル タイプと同じです。
|
|
initCallback(icb)
|
string
|
 
|
|
このフラグは、初期化コールバックのためのコールバック プロシージャを指定します。このプロシージャは必要に応じてファイル> 新規(File > New)とファイル > 開く(File > Open)でコールされ、パネルは開始状態に再初期化されます。この場合、パネルはペアレント化されることもされないこともあります。コールバック プロシージャの書式は次のとおりです: global proc procName(string $panelName) { .... }
|
|
label(l)
|
string
|
 
|
|
|
obsolete(o)
|
boolean
|
 
|
|
このフラグは、このタイプが Maya で使用されなくなったことを指定します。
|
|
removeCallback(rcb)
|
string
|
 
|
|
このフラグは、パネルを現在のコントロール レイアウトから除去するためのコールバック プロシージャを指定します。すべてのエディタをここでペアレント化解除します。コールバック プロシージャの書式は次のとおりです: global proc procName(string $panelName) { .... }
|
|
retainOnFileOpen(rfo)
|
boolean
|
 
|
|
このフラグは、ファイルを開く際にパネル設定を復元した後もこのタイプを保持するかどうかを指定します。既定は false です。
|
|
saveStateCallback(scb)
|
string
|
 
|
|
このフラグは、パネルの状態を保存するためのコールバック プロシージャを指定します。コールバック プロシージャの書式は次のとおりです: global proc stringprocName(string $panelName) { .... } proc は文字列を返すことに注意してください。この文字列は createCallback がコールされた後で実行され、パネルの状態を容易に復元できるようにします。
|
|
unique(u)
|
boolean
|
 
|
|
このフラグは、所定の時間に存在できるこのタイプのパネルのインスタンスを 1 つにするかどうかを指定します。
|
|
useTemplate(ut)
|
string
|
|
|
コマンドに、現在のものとは異なるコマンド テンプレートを使用するように強制します。
|
|
フラグはコマンドの作成モードで表示できます
|
フラグはコマンドの編集モードで表示できます
|
フラグはコマンドの照会モードで表示できます
|
フラグに複数の引数を指定し、タプルまたはリストとして渡すことができます。
|
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.
#