Getting ICE attributes through scripting


You can get at the ICE attributes of a point cloud through PointCloudGeometry.ICEAttributes or PointCloudGeometry.GetICEAttributeFromName.

To get the attribute values for every point in a point cloud, you get the DataArray of the attribute.

Here’s some sample JScript that shows how to get ICE attributes. Run it once, and then randomize the initial shapes of the particles and run the script again. See the difference? (Look at the difference in IsConstant and the contents of DataArray for the Shape attribute).

Remember that in the script editor you can double-click a method or property name (like “DataArray”) and press F1 to go to the SDK reference page.

var pc = Dictionary.GetObject( "PointCloud" );
var oPointCloudGeometry = pc.ActivePrimitive.Geometry;

// Get the NbPoints attribute
var oIceAttrib = oPointCloudGeometry.GetICEAttributeFromName( "NbPoints" );
logAttributeInfo( oIceAttrib );
logDataArray( oIceAttrib.DataArray );

// Get the Shape attribute
var oIceAttrib = oPointCloudGeometry.GetICEAttributeFromName( "Shape" );
logAttributeInfo( oIceAttrib );
logDataArray( oIceAttrib.DataArray );

// Utility functions
function logAttributeInfo( oIceAttrib )
{
    LogMessage( oIceAttrib.Name + "ICE attribute");
    LogMessage( "\tIsConstant=" + oIceAttrib.IsConstant );
    LogMessage( "\tContextType=" + oIceAttrib.ContextType );
    LogMessage( "\tDataType=" + oIceAttrib.DataType );
}

function logDataArray( dataArray )
{
    // DataArray is a safe array
    // So, convert it to a JScript array
    var a = new VBArray( dataArray ).toArray();
    LogMessage( "\tDataArray.length=" + a.length );
    for ( var i in a )
    {
        if ( typeof(a[i])=="object" )
        {
            LogMessage( "\tDataArray["+i+"].Type=" + a[i].Type );
			LogMessage( ClassName( a[i] ) );	// Shape
        }
        else
        {
            LogMessage( "\tDataArray["+i+"]=" + a[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