Attaching Binary Use r Data to Objects

Raw binary user data on objects is available to plug-in developers through the object model as the UserDataBlob object. You can attach a user data blob to any object that supports the SceneItem.AddProperty method.

The UserDataBlob is similar to the UserDataMap, but supports storing object level binary data rather than per-component binary data. For example, if some user data is meant to apply to every point in a vertex cluster then it should be stored in a UserDataBlob, whereas, if the user data is meant to apply only to a single vertex, it should be stored at the correct index in a UserDataMap.

C++ Example: Applying a UserDataBlob to the scene root

    // C++ example (using the C++ API) giving an overview of applying user data
    // to a scene object (the scene root)

       using namespace XSI;

       Application app ;
       Model root = app.GetActiveSceneRoot();

       UserDataBlob myBlob ;
       root.AddProperty( L"UserDataBlob", false, L"udb", myBlob ) ;

       // This is the structure that we would like to save inside Softimage
       struct ExampleData
       {
           double x ;
           int    y ;
           int    z ;
       } ;

       // Save the structure
       ExampleData data ;
       data.x = 90.1 ;
       data.y = 12 ;
       data.z = 14 ;

       myBlob.PutValue( (unsigned char*)&data, sizeof( ExampleData ) ) ;

       // Retrieve the structure again
       unsigned char * pBuffer = NULL ;
       unsigned int cntBuffer = 0 ;

       myBlob.GetValue( pBuffer, cntBuffer ) ;

       // We can conveniently read the contents of the user data
       // by casting back to the structure
       ExampleData * pData = (ExampleData*)pBuffer ;

       // Update our structure based on what is already on the userdatablob
       data.x = 3.15 + pData->x ;
       data.y = 12 + pData->y ;
       data.z = 0 ;

       // Save our updated values
       myBlob.PutValue( (unsigned char*)&data, sizeof( ExampleData ) ) ;

Autodesk Softimage v7.5