Public Member Functions
CustomProperty Class Reference

Detailed Description

The CustomProperty class represents a custom parameter set property object. A custom property holds a set of parameters which can be created by the user or via scripting/programming.

A custom property can be used to store user-defined data such as attributes for a game engine. A custom property can be accessed and modified just like any other Property object.

You should not use the custom property functions for adding and removing parameters in conjuction with the CustomProperty object since the parameter list will get out of sync.

See also:
SceneItem::AddCustomProperty
Example:
        using namespace XSI;
        Application app;
        Model root = app.GetActiveSceneRoot();

        Null null;
        root.AddNull( L"", null );

        CustomProperty cpset;
        null.AddCustomProperty(L"MyCustomPSet", false, cpset );

        Parameter x, y, bitfield, label, flag;

        cpset.AddParameter( L"x", CValue::siDouble, siAnimatable, L"Double", L"Double X", 10.0, 0.0, 100.0, 10.0, 90.0, x );
        cpset.AddParameter( L"y", CValue::siInt4, siAnimatable, L"Integer", L"Integer Y", (LONG)10, (LONG)0, (LONG)100, (LONG)10, (LONG)90, y );
        cpset.AddParameter( L"bitfield", CValue::siUInt1, siAnimatable, L"UByte", L"Bitfield", (UCHAR)32, bitfield );
        cpset.AddParameter( L"label", CValue::siString, siPersistable, L"Text", L"Text Field", L"Hello World", label );
        cpset.AddParameter( L"flag", CValue::siBool, siAnimatable, L"Flag", L"Boolean Field", true, flag );

#include <xsi_customproperty.h>

Inheritance diagram for CustomProperty:
Inheritance graph
[legend]

List of all members.

Public Member Functions

  CustomProperty ()
  ~CustomProperty ()
  CustomProperty (const CRef &in_ref)
  CustomProperty (const CustomProperty &in_obj)
bool  IsA (siClassID in_ClassID) const
siClassID  GetClassID () const
CustomProperty operator= (const CustomProperty &in_obj)
CustomProperty operator= (const CRef &in_ref)
CStatus  AddParameter (const CString &in_scriptname, CValue::DataType in_type, INT in_capabilities, const CString &in_name, const CString &in_description, const CValue &in_default, const CValue &in_min, const CValue &in_max, const CValue &in_suggestedmin, const CValue &in_suggestedmax, Parameter &io_parameter)
CStatus  AddParameter (const CString &in_scriptname, CValue::DataType in_type, INT in_capabilities, const CString &in_name, const CString &in_description, const CValue &in_default, Parameter &io_parameter)
Parameter  AddFCurveParameter (const CString &in_scriptname)
Parameter  AddGridParameter (const CString &in_scriptname)
CStatus  RemoveParameter (const Parameter &in_param)
CStatus  GetBinaryData (unsigned char *&io_buffer, UINT &io_size) const
CStatus  FreeBinaryData (unsigned char *&io_buffer) const
CStatus  PutBinaryData (const unsigned char *in_buffer, UINT in_size)
ProxyParameter  AddProxyParameter (Parameter in_ParamToProxy, const CString &in_ProxyScriptName=CString(), const CString &in_ProxyName=CString())
Parameter  AddParameterFromDef (const CRef &in_paramdef)

Constructor & Destructor Documentation

Default constructor.

Default destructor.

CustomProperty ( const CRef in_ref )

Constructor.

Parameters:
in_ref constant reference object.
CustomProperty ( const CustomProperty in_obj )

Copy constructor.

Parameters:
in_obj constant class object.

Member Function Documentation

bool IsA ( siClassID  in_ClassID ) const [virtual]

Returns true if a given class type is compatible with this API class.

Parameters:
in_ClassID class type.
Returns:
true if the class is compatible, false otherwise.

Reimplemented from Property.

siClassID GetClassID ( ) const [virtual]

Returns the type of the API class.

Returns:
The class type.

Reimplemented from Property.

CustomProperty& operator= ( const CustomProperty in_obj )

Creates an object from another object. The newly created object is set to empty if the input object is not compatible.

Parameters:
in_obj constant class object.
Returns:
The new CustomProperty object.
CustomProperty& operator= ( const CRef in_ref )

Creates an object from a reference object. The newly created object is set to empty if the input reference object is not compatible.

Parameters:
in_ref constant class object.
Returns:
The new CustomProperty object.

Reimplemented from Property.

CStatus AddParameter ( const CString in_scriptname,
CValue::DataType  in_type,
INT  in_capabilities,
const CString in_name,
const CString in_description,
const CValue in_default,
const CValue in_min,
const CValue in_max,
const CValue in_suggestedmin,
const CValue in_suggestedmax,
Parameter io_parameter 
)

Adds a new custom parameter to the CustomProperty object. The recommended parameter types are: siString, siBool, siInt4, siUByte, and siDouble.

The supported types are: siString, siBool, siDouble, siFloat, siInt4, siInt2, siUInt4, siUInt2, siByte, siUByte

Parameters:
in_scriptname The script name for the new Parameter object.
in_type The data type of the new Parameter object.
in_capabilities The capabilities of the parameter. This is a mask of siCapabilities values and is used to determine where the parameter is read-only or animatable etc.
in_name The name of the Parameter object. This is the string that will be displayed in the scene explorer (unless Show Script Names is enabled). If this argument is not specified then the ScriptName argument will be visible to users as the parameter's name. (See SIObject::GetName and Parameter::GetScriptName). This string will appear as the parameter label when the CustomProperty is inspected, unless a specific label is specified in the PPGLayout (see PPGItem::PutLabel).
in_description This string is optional and does not appear in the user interface.
in_default The default value of the custom parameter. A default value is required for parameter types other than siString and siBool.
in_min Minimum value of the custom parameter. A value is required for parameter types other than siString and siBool.
in_max Maximum value of the custom parameter. A value is required for parameter types other than siString and siBool.
in_suggestedmin Suggested minimum value of the custom parameter. The minimum value will be used if this parameter is not specified. The suggested minimum should be equal or larger than the minimum. This value is used to configure the range of UI controls.
in_suggestedmax Suggested maximum value of the custom parameter. The maximum value will be used if this parameter is not specified. The suggested maximum should be equal or smaller than the Maximum. This value is used to configure the range of UI controls.
io_parameter New Parameter object.
Returns:
CStatus::OK success
CStatus::Fail failure
CStatus AddParameter ( const CString in_scriptname,
CValue::DataType  in_type,
INT  in_capabilities,
const CString in_name,
const CString in_description,
const CValue in_default,
Parameter io_parameter 
)

Adds a new custom parameter to the CustomProperty object using the default min and max for the specified type. The min/max for siDouble, siInt4 and siUByte are as follows:

siDouble
 -1.7976931348623158e+308..1.7976931348623158e+308 
siInt4
 -2147483648..2147483647 
siUByte
 0..255 

The recommended parameter types are: siString, siBool, siInt4, siUByte, and siDouble.

The supported types are: siString, siBool, siDouble, siFloat, siInt4, siInt2, siUInt4, siUInt2, siByte, siUByte

Parameters:
in_scriptname The script name for the new Parameter object.
in_type The data type of the new Parameter object.
in_capabilities The capabilities of the parameter. This is a mask of siCapabilities values and is used to determine where the parameter is read-only or animatable etc.
in_name The name of the Parameter object. This is the string that will be displayed in the scene explorer (unless Show Script Names is enabled). If this argument is not specified then the ScriptName argument will be visible to users as the parameter's name. (See SIObject::GetName and Parameter::GetScriptName). This string will appear as the parameter label when the CustomProperty is inspected, unless a specific label is specified in the PPGLayout (see PPGItem::PutLabel).
in_description This string is optional and does not appear in the user interface.
in_default The default value of the custom parameter. A default value is required for parameter types other than siString and siBool.
io_parameter New Parameter object.
Returns:
CStatus::OK success
CStatus::Fail failure
Parameter AddFCurveParameter ( const CString in_scriptname )

Adds an FCurve parameter to the CustomProperty. An FCurve of this type is often called a Profile Curve because, unlike most FCurves, this curve does not animate any parameter, but instead is available for use in any fashion the plug-in developer or user wishes.

Unlike parameters that have simple types like an Integer or a String, this Parameter is an instance of an FCurve. It uses units of frames for its X axis, but because it does not directly animate any object this axis can actually be interpreted in any fashion. An example use of an FCurve parameter can be found on the Bulge Operator (see bulgeop ).

You can get the FCurve object via Parameter::GetValue. This should not be confused with the function for retrieving an FCurve that is animating a basic parameter (Parameter::GetSource).

To view the FCurve on the Property Page for the CustomProperty use PPGLayout::AddFCurve.

Parameters:
in_scriptname Script name of the new parameter
Returns:
The new Parameter object.
Since:
4.0
Parameter AddGridParameter ( const CString in_scriptname )

Adds a Grid parameter to the CustomProperty. The grid is a convenient way to store 1- or 2-dimensional arrays and the user can view and edit this data via the ::siControlGrid (see ::siPPGControlType enum).

To change the contents of the grid via scripting use the GridData object, which is accessible via Parameter::GetValue.

To include the Grid in the Property Page of the CustomProperty use PPGLayout::AddItem.

Parameters:
in_scriptname Script name of the new parameter
Since:
4.0
CStatus RemoveParameter ( const Parameter in_param )

Removes the specified custom parameter from the custom property object.

Note:
Beginning with v4.2 it is possible to remove ProxyParameters using this function.
Parameters:
in_param Parameter to remove.
Returns:
CStatus::OK success
CStatus::Fail failure
CStatus GetBinaryData ( unsigned char *&  io_buffer,
UINT &  io_size 
) const

Returns the binary representation of the CustomProperty.

This data is a compact representation, encoded in a unsigned char*. Unlike a Preset, only the actual values are stored in the binary representation, this is done for memory efficiency.

In the case of animated parameters the value recorded in the binary representation is the value at the current frame. Similarly, the current value of any proxy parameters is recorded in the binary representation.

Normally SDK developers will not need to be concerned with the internal format of this binary data. However, the following information may be useful in cases where the data will be generated or processed outside of XSI. The binary representation begins with a two-byte header that serve as a magic number for error-handling purposes. The rest of the buffer is a concatenation of the raw values of the properties of the custom property, in exactly the order they were originally added to the custom property, and stored in little-endian byte order. For example, a double takes up 8 bytes, a float 4 bytes and an unsigned char (siUByte) takes 1 byte. Strings start with a 32-bit count of the number of characters, followed by the 16-bit unicode representation of each character, with no string termination character.

Parameters:
io_buffer This is a byte string, containing binary data. This string does not necessarily contain human readable text. Callers are responsible for freeing this string with CustomProperty::FreeBinaryData.
io_size The size of the binary data in bytes.
Returns:
CStatus::OK success
CStatus::Fail failure
CStatus FreeBinaryData ( unsigned char *&  io_buffer ) const

Deallocates the memory that was allocated by a call to CustomProperty::GetBinaryData. Calling this function with a NULL pointer will fail with CStatus::InvalidArgument.

Parameters:
io_buffer Memory location
Returns:
CStatus::OK success
CStatus::InvalidArgument
CStatus::Fail failure
CStatus PutBinaryData ( const unsigned char *  in_buffer,
UINT  in_size 
)

Sets the binary representation of the CustomProperty.

This data is a compact representation, encoded in a unsigned char*. Unlike a Preset, only the actual values are stored in the binary representation, this is done for memory efficiency.

You should not attempt to set the binary representation on a custom property object which is different from the custom property from which the binary representation was retrieved. In particular the number of parameters, the order of the parameters and the type of the parameters must match. If the custom property is different the API call will fail or will result in the custom property set being filled with bogus values. However it is possible to rearrange the order in which parameters are displayed on the property page for a CustomProperty (by editing the SPDL file "Layout" section) without any incorrect results.

Normally SDK developers do not need to be concerned with the internal format of this binary data. However, the following information may be useful in cases where the data will be generated or processed outside of XSI. The binary representation begins with a two-byte header that serve as a magic number for error handling purposes. The rest of the buffer is a concatenation of the raw values of the properties of the custom property, in exactly the order they were originally added to the custom property, and stored in little-endian byte order. For example, a double takes up 8 bytes, a float 4 bytes and a unsigned char (siUByte) takes 1 byte. Strings start with a 32-bit count of the number of characters, followed by the 16-bit unicode representation of each character, with no string termination character.

Parameters:
in_buffer Byte string containing binary data.
in_size The size of the binary data in bytes.
Returns:
CStatus::OK success
CStatus::Fail failure
ProxyParameter AddProxyParameter ( Parameter  in_ParamToProxy,
const CString in_ProxyScriptName = CString(),
const CString in_ProxyName = CString() 
)

Adds a ProxyParameter to the CustomProperty.

Parameters:
in_ParamToProxy Parameter to which the new ProxyParameter will be connected.
in_ProxyScriptName A script name for the new ProxyParameter. If not specified a name is generated based on the fullname of the in_ParamToProxy argument.
in_ProxyName A name to use for the new ProxyParameter. If not specified a name is generated based on the fullname of the in_ParamToProxy argument.
Returns:
Newly created ProxyParameter
Since:
v4.2
Parameter AddParameterFromDef ( const CRef in_paramdef )

Creates a Parameter from a parameter definition.

Parameter definitions contain the definition of a parameter from which you can create new parameters on the fly for one or more property sets or operators. For example, you may want to use a double with the same min/max range and use it on multiple property sets or you may simply want a quick way to add parameters to a runtime custom operator. You can create new parameter definitions from the Factory class.

Parameters:
in_paramdef Parameter definition object
Returns:
Parameter new parameter
See also:
Factory::CreateParamDef, Factory::CreateFCurveParamDef, Factory::CreateGridParamDef
Since:
v5.0

The documentation for this class was generated from the following file: