X3DObject.ActivePrimitive

Description

Returns the 3D object's active Primitive.

Note: Although the scene root is a kind of Model it does not support primitives. In this case this property return Nothing.

C# Syntax

// get accessor
Primitive rtn = X3DObject.ActivePrimitive;

Examples

1. JScript Example

/*
	This example illustrates how to get the active primitive object from an 
	X3DObject object and how to detect if the object supports primitives.
*/
var cone = Application.ActiveSceneRoot.AddGeometry( "Cone", "MeshSurface" );
TestPrimitive( cone ) ;
mynull = Application.ActiveSceneRoot.AddNull( "MyNull" )
TestPrimitive( mynull ) ;
TestPrimitive( Application.ActiveSceneRoot ) ;
function TestPrimitive( in_obj )
{
	if ( in_obj.ActivePrimitive != null )
	{
		Application.LogMessage( "\n\t" +
				"Name: " + in_obj.Name + "\n\t" +
				"Class: " + Application.ClassName(in_obj) + "\n\t" +
				"Type: " + in_obj.Type + "\n\t" +
				"Fullname: " + in_obj.FullName + "\n\t" +
				"Parent: " + in_obj.Parent.Name ) ;
	}
	else
	{
		Application.LogMessage( in_obj + " does not have a primitive" ) ;
	}
}
// Expected results:
//INFO : Sphere object's name: sphere
//INFO : 
//	Name: cone
//	Class: X3DObject
//	Type: polymsh
//	Fullname: cone
//	Parent: Scene_Root
//INFO : 
//	Name: MyNull
//	Class: Null
//	Type: null
//	Fullname: MyNull
//	Parent: Scene_Root
//INFO : Scene_Root does not have a primitive

2. Python Example

#
#	This example illustrates how to get the active primitive object from an 
#	X3DObject object and how to detect if the object supports primitives.
#
cone = Application.ActiveSceneRoot.AddGeometry( "Cone", "MeshSurface" )
if cone.ActivePrimitive :
	Application.LogMessage( "\n\tName: " + cone.Name + "\n\tClass: " +
	Application.ClassName(cone) + "\n\tType: " + cone.Type + "\n\tFullname: " +
	cone.FullName + "\n\tParent: " + cone.Parent.Name )
if not Application.ActiveSceneRoot.ActivePrimitive :
	Application.LogMessage( "The SceneRoot does not have a primitive." )
# Expected results:
#INFO : 
#	Name: cone
#	Class: X3DObject
#	Type: polymsh
#	Fullname: cone
#	Parent: Scene_Root
#INFO : The SceneRoot does not have a primitive.

3. VBScript Example

'
'	This example illustrates how to get the active primitive object from an 
'	X3DObject object and how to detect if the object supports primitives.
'
NewScene , false
set cone = Application.ActiveSceneRoot.AddGeometry( "Cone", "MeshSurface" )
if TypeName(cone.ActivePrimitive) <> "Nothing" then
	Application.LogMessage vbTab & "Name: " & vbTab & cone.Name, siComment 
	Application.LogMessage vbTab & "Class: " & vbTab & TypeName(cone), siComment 
	Application.LogMessage vbTab & "Type: " & vbTab & cone.Type, siComment 
	Application.LogMessage vbTab & "FullName: " & vbTab & cone.FullName, siComment 
	Application.LogMessage vbTab & "Parent: " & vbTab & cone.Parent.Name, siComment 
end if
if TypeName(Application.ActiveSceneRoot.ActivePrimitive) = "Nothing" then
	Application.LogMessage "The SceneRoot does not have a primitive.", siComment 
end if
' Expected results:
' 	Name: 	cone
' 	Class: 	X3DObject
' 	Type: 	polymsh
' 	Fullname: 	cone
' 	Parent: 	Scene_Root
' The SceneRoot does not have a primitive.