SIObject.IsClassOf
 
 
 

SIObject.IsClassOf operator

Introduced

v5.0

Description

Returns true if the object implements the class identified by the siClassID. The method allows you to test which classes an object can implement and reflects the hierarchy illustrated in the object's documentation. For example, the ProxyParameter class supports its own properties and methods, but also the properties and methods of the Parameter class and the SIObject class. This means that IsClassOf returns true for siProxyParameterID, siParameterID and siObjectID. On the other hand, a proxy parameter is not a X3DObject, so IsClassOf would return false for siX3DObjectID.

This method is very similar to the Application.ClassName method with the exception that it takes an siClassID instead of a string and you can test for all the classes implemented by a class.

Note: The VBScript TypeName() function and JScript typeof() function can also be used to report the type name of simple data types such as a string or integer. For objects, the TypeName() function will give the same result as the Application.ClassName method but the typeof() function will only return 'object', the typeof() function will also return 'object' for variables set to 'null'.

The C++ API has an equivalent methods: SIObject::IsA and SIObject::IsA and take exactly the same siClassID constant.

C# Syntax

Boolean SIObject.IsClassOf( siClassID );

Scripting Syntax

oBoolean = SIObject.IsClassOf( ClassID );

Return Value

Boolean

Parameters

Parameter Type Description
ClassID siClassID The classid to compare with

Examples

1. JScript Example

// 
// Demonstrates how to test an object for its implementation classes
// 
var oModel = ActiveSceneRoot.AddModel();
Application.LogMessage( "Is object a model: " + oModel.IsClassOf(siModelID) );
Application.LogMessage( "Is object an x3dobject: " + oModel.IsClassOf(siX3DObjectID) );
Application.LogMessage( "Is object a scene item: " + oModel.IsClassOf(siSceneItemID) );
Application.LogMessage( "Is object a project item: " + oModel.IsClassOf(siProjectItemID) );
Application.LogMessage( "Is object an siobject: " + oModel.IsClassOf(siSIObjectID) );
Application.LogMessage( "Is object a null: " + oModel.IsClassOf(siNullID) );
// Expected result:
//INFO : "Is object a model: True"
//INFO : "Is object an x3dobject: True"
//INFO : "Is object a scene item: True"
//INFO : "Is object a project item: True"
//INFO : "Is object an siobject: True"
//INFO : "Is object a null: False"

2. JScript Example

/*
        The SIObject.IsClassOf() method can be very useful in determining whether
        the selection contains a 3DObject.
*/
newscene(null, false);
CreateModel(null, null, null, null);
Application.LogMessage( "Is the selected "+selection(0).name+" object a 3dobject? " + selection(0).IsClassOf(siX3DObjectID) );
CreatePrim("Sphere", "MeshSurface", null, null);
var obj = selection(0);
Application.LogMessage( "Is the selected "+selection(0).name+" object a 3dobject? " + selection(0).IsClassOf(siX3DObjectID) );
SelectGeometryComponents("sphere.pnt[1,6-8,14,15,22,29,35,36,40-43,47-50,54-LAST]");
CreateCluster(null);
Application.LogMessage( "Is the selected "+selection(0).name+" object a 3dobject? " + selection(0).IsClassOf(siX3DObjectID) );
// Expected result:
//INFO : Is the selected Model object a 3dobject? true
//INFO : Is the selected sphere object a 3dobject? true
//INFO : Is the selected Point object a 3dobject? false