Filtering object selection by volume


Here’s an addon that uses the ICE Volume attribute to filter object selections. The Volume attribute is always defined (so you don’t need to Show Values or anything for this filter to work).

Note that you have to freeze scaling to get the right volume for an object.

For simplicity, I’m using a custom property (on the scene root) to hold the preferences for the filter.

The filter itself is simple. It just gets the Volume attribute value and compares it to the range of values specified in the PPG.

# Match callback for the psCustomFilters custom filter.
def ObjbyVolume_Match( in_ctxt ):
	Application.LogMessage("ObjbyVolume_Match called",constants.siVerbose)

	in_object = in_ctxt.GetAttribute( "Input" );

	obj = Get3DObject( in_object );
	if ( Application.ClassName(obj) != "X3DObject" ):
		return false;
	
	v = obj.ActivePrimitive.ICEAttributes("Volume").DataArray[0]

	filterProp = GetFilterProp( )
	if filterProp.Filter_by_range.Value == True:
		bMatch = filterProp.Volume_Min.Value <= v <= filterProp.Volume_Max.Value
	else: # Filter by value with an epsilon
		min = filterProp.Value.Value - filterProp.Epsilon.Value
		max = filterProp.Value.Value + filterProp.Epsilon.Value
		bMatch = min <= v <= max
		
	return bMatch