Using a hidden parameter to store values


Here’s a simple self-installing property that shows how to use a “hidden” parameter to store a collection as a comma-separated string. I say the parameter is “hidden” because it is not shown on the property page (PPG).

function XSILoadPlugin( in_reg )
{
	in_reg.Author = "blairs";
	in_reg.Name = "SaveCollectionPlugin";
	in_reg.Major = 1;
	in_reg.Minor = 0;

	in_reg.RegisterProperty("SaveCollection");

	return true;
}

function XSIUnloadPlugin( in_reg )
{
	var strPluginName;
	strPluginName = in_reg.Name;
	Application.LogMessage(strPluginName + " has been unloaded.",siVerbose);
	return true;
}

function SaveCollection_Define( in_ctxt )
{
	var oCustomProperty;
	oCustomProperty = in_ctxt.Source;
	
	// Used to store the list of passes as a comma-separated string
	oCustomProperty.AddParameter2("Passes",siString,"",null,null,null,null,siClassifUnknown,siPersistable | siKeyable);
	
	return true;
}

function SaveCollection_DefineLayout( in_ctxt )
{
	var oLayout,oItem;
	oLayout = in_ctxt.Source;
	oLayout.Clear();
	oLayout.AddButton("Set");
	oLayout.AddButton("Get");
	return true;
}

// Save a list of passes in the Passes parameter
function SaveCollection_Set_OnClicked( )
{
	Application.LogMessage("SaveCollection_Test_OnClicked called",siVerbose);
	PPG.Passes.Value = ActiveProject.ActiveScene.Passes.GetAsText();
}

// Get the list of passes from the Passes parameter
function SaveCollection_Get_OnClicked( )
{
	Application.LogMessage("SaveCollection_Test_OnClicked called",siVerbose);

	// Split the string into an array
	var x = PPG.Passes.Value.split(",");
	for ( var i = 0; i < x.length; i++ )
	{
		LogMessage( x[i] );
	}

}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s