PPG

Object Hierarchy | 関連する C++クラス:PPGEventContext

導入

v4.0

詳細

プロパティページのインスタンスです。このオブジェクトは、PPGLayoutに関連するイベント処理スクリプトコード内で操作できます(このイベント処理スクリプトは通常、「SPDL ロジック」と呼ばれます。前のバージョンでは、スクリプト コードを直接 spdl ファイルに入力することでのみ指定できたためです)。このオブジェクトは「PPG」というグローバル変数としてロジック コードで使用できます。(下位互換性を保つため、グローバル変数「PSet」を介して使用することもできます。また、下位互換性を保つために、このオブジェクトは Context からは派生しません。さらに、コールバックルーチンへの引数として渡されるのではなく、グローバル変数として使用されます)。

プロパティページから複数のオブジェクトを検証する方法は 2 つあります。1 つ目の方法として、複数のオブジェクトが異なるタイプのものである場合は、同じフレーム内に個別の PPg オブジェクトが表示されます。2 つ目の方法として、複数のオブジェクトが同じタイプのものである場合は、複数編集モードが使用され、PPg オブジェクトの 1 つのインスタンスが複数のオブジェクトを表します。このため、PPG.Inspected プロパティは、1 つのオブジェクトではなく配列を戻します。

このオブジェクトは、インスペクト対象オブジェクトの Parameter に直接アクセスするためのショートカットとなります。たとえば、xという名前のパラメータを持ったプロパティページの場合、この値を変更するVBScript のコードは"PPG.x.Value = 10"です。複数編集モードの場合、この方法では最初のインスペクト対象オブジェクトしか変更できません。

注:C++ API でこれに相当するオブジェクトは PPGEventContext です。

メソッド

Close Refresh    
       

プロパティ

CurrentTab Inspected InspectedObjects PPGLayout

JScript の例

/*

	This example shows how to build an extremely dynamic Custom Property using 

	the PPG object. It appears in two parts: 

	 * PART ONE writes the implementation to disk, loads it in Softimage, and

	   then displays the property editor.

	 * PART TWO is the code that implements the custom property

	Not only does the layout change but the actual underlying parameters are 

	rebuilt each time the Property Page is shown.

	Once this plugin is installed you can apply an instance of the custom 

	property via the Property Menu on the left side of the screen.  Then 

	each time you inspect the custom property it will regenerate its UI 

	so that there is a check box for each X3DObject parented under the scene 

	root.  You can pick which ones to select and then click apply.

	Normally a feature like this would probably be implemented as a custom 

	command that pops up a temporary, modal custom property which is deleted 

	after the fact.  However for the purpose of this example the custom 

	property remains in the scene for use whenever the user wants to change 

	selection.

	(This example was implemented by using the Custom Property wizard to 

	generate the initial plugin and then editing the code to add the dynamic 

	behavior)

*/

NewScene( null, false );

// ------------------------------------------------------------

//

//		PART ONE: Save Implementation to Disk and Open PPG

//

var filename = XSIUtils.BuildPath( Application.InstallationPath(siUserPath), 

	"Application", "Plugins", "DynParamDemo.js" );

// Write the contents of the Implementation functions below to DynParamDemo.js

var fso = new ActiveXObject( "Scripting.FileSystemObject" );

var ts = fso.CreateTextFile( filename, true );

ts.Write( XSILoadPlugin.toString() + "\n\n" );

ts.Write( DynParamDemo_Define.toString() + "\n\n" );

ts.Write( DynParamDemo_DefineLayout.toString() + "\n\n" );

ts.Write( DynParamDemo_OnInit.toString() + "\n\n" );

ts.Write( DynParamDemo_Apply_OnClicked.toString() );

ts.Close();

// Load the plugin 

Application.LoadPlugin( filename );

// Instantiate the custom property and display its property page

var oCustomProperty = Application.ActiveSceneRoot.AddProperty( "DynParamDemo" );

InspectObj( oCustomProperty );

// ------------------------------------------------------------

//

//		PART TWO: PPG Implementation

//

function XSILoadPlugin( in_reg )

{

	in_reg.Author = "Softimage";

	in_reg.Name = "DynParamDemoPlugin";

	in_reg.Major = 1;

	in_reg.Minor = 1;

	in_reg.RegisterProperty( "DynParamDemo" );

	return true;

}

function DynParamDemo_Define( io_Context )

{

	// No parameters are added here because we want the

	// data to be dynamic, see DynParamDemo_OnInit

}

function DynParamDemo_DefineLayout( io_Context )

{

	// Do nothing here because we want a dynamic layout.

	// The work is done inside DynParamDemo_OnInit instead.

}

function DynParamDemo_OnInit()

{

	// This example doesn't make sense in the case

	// of selection of more than one instance of the custom

	// property at a time, so we only look at the first inspected

	var oCustomProperty = PPG.Inspected.Item(0);

	// Remove any existing parameters

	for ( var i=oCustomProperty.Parameters.Count-1; i>=0; i-- ) {

		oCustomProperty.RemoveParameter( oCustomProperty.Parameters.Item(i) );

	}

	var oLayout = PPG.PPGLayout;

	oLayout.Clear();

	var oSceneChildren = Application.ActiveSceneRoot.Children; 

	for ( var j=0; j<oSceneChildren.Count; j++ ) {

		var oChild = oSceneChildren.Item(j);

		// Add a boolean parameter to represent this object

		oCustomProperty.AddParameter2( oChild.Name, siBool, false,

				null, null, null, null, 0, siPersistable );

		// Put this in the layout

		oLayout.AddItem( oChild.Name, "Select " + oChild.Name );		

	}

	oLayout.AddButton( "Apply" );

	PPG.Refresh();

}

function DynParamDemo_Apply_OnClicked()

{

	DeselectAll(); // Call Softimage Command

	var oCustomProperty = PPG.Inspected.Item(0);

	for ( var j=0; j<oCustomProperty.Parameters.Count; j++ ) {

		var oParam = oCustomProperty.Parameters.Item(j);

		if ( oParam.Value == true ) {

			// We used a naming sceme for the parameters that matches the object	

			AddToSelection( oParam.Name );	// Call Softimage Command

		}

	}

}

関連項目

PPGLayout.Logic ProjectItem Parameter Context InspectObj Property Host Callbacks