Group

Object Hierarchy | Related C++ Class: Group

Inheritance

SIObject

ProjectItem

SceneItem

Group

Introduced

v1.0

Description

A group is a collection of related objects.

Methods

AddCustomOp AddCustomProperty AddICEAttribute AddMaterial
AddMember AddProperty AddScriptedOp AddScriptedOpFromFile
AnimatedParameters2 ApplyEnvelope BelongsTo operator EvaluateAt
GetICEAttributeFromName GetLocalPropertyFromName GetLocalPropertyFromName2 GetPropertyFromName
GetPropertyFromName2 IsA IsAnimated2 IsClassOf operator
IsEqualTo operator IsKindOf IsLocked operator IsMember
IsSelected operator LockOwners RemoveAllMembers RemoveICEAttribute
RemoveMember SetAsSelected operator SetCapabilityFlag operator SetLock
SetMaterial TaggedParameters UnSetLock  
       

Properties

Application BranchFlag operator Capabilities operator Categories
Envelopes EvaluationID ExpandedMembers Families operator
FullName operator Help HierarchicalEvaluationID ICEAttributes
LocalProperties LockLevel operator LockMasters operator LockType operator
Material Members Model Name operator
NestedObjects ObjectID Origin OriginPath
Owners PPGLayout operator Parameters operator Parent
Parent3DObject Properties Selected operator Type operator

Examples

1. VBScript Example

set oRoot = Application.ActiveProject.ActiveScene.Root
set oGroup = oRoot.AddGroup
set oCube = oRoot.AddGeometry( "Cube", "MeshSurface" )
oGroup.AddMember oCube
for each oMember in oGroup.Members
	LogMessage oMember.Name & " is a member of the " & oGroup.Name
next

2. JScript Example

/* ----------------------------------------------------------
	This example shows how to find groups under the
	scene root or under a specific model given the 
	following structure:
Scene_Root                        Model    Group
+ RootGroup                              *
+ ChildModel                    *
+ ChildGroup                         *
+ AnotherChildModel             *
+ AnotherChildGroup                  *
+ GrandChildModel           *
+ GrandChildGroup                *
=====    =====
3        4
	Note: The Model.Groups property gets only 
		the immediate children of a model 
		(unlike the X3DObject.Models property, which gets all
		nested models.
*/
// ----------------------------------------------------------
//
//	SETUP
//
NewScene( null, false );
// Set up a scene with 4 objects
var oRoot = ActiveSceneRoot;
var oMbr1 = oRoot.AddGeometry( "Disc", "MeshSurface" );
var oMbr2 = oRoot.AddGeometry( "Torus", "MeshSurface" );
var oMbr3 = oRoot.AddGeometry( "Sphere", "MeshSurface" );
var oMbr4 = oRoot.AddNull();
// Create a group under the root 
oRoot.AddGroup( oMbr1, "RootGroup" );
// Create a new model and another group under the new model 
var oMdl = oRoot.AddModel( oMbr2, "ChildModel" );
oMdl.AddGroup( oMbr2, "ChildGroup" );
// Add another model to the root 
var oMdl = oRoot.AddModel( oMbr3, "AnotherChildModel" );
oMdl.AddGroup( oMbr3, "AnotherChildGroup" );
// Nest yet another model under the second child model
var oMdl = oMdl.AddModel( oMbr4, "GrandChildModel" );
oMdl.AddGroup( oMbr4, "GrandChildGroup" );
//----------------------------------------------------------
//
//	SEARCH
//
// Find all groups under the scene root
LogMessage( "******** GROUPS UNDER " + oRoot.Name + " ********" );
FindGroupsUnderModel( oRoot );
// Find all groups under 'AnotherChildModel' 
LogMessage( "******** GROUPS UNDER " + oMdl.Name + " ********" );
FindGroupsUnderModel( oMdl );
// Now find all groups in the scene
RecursiveGroupSearch( oRoot );
//----------------------------------------------------------
//
//	RESULTS
//
//INFO : "******** GROUPS UNDER Scene_Root ********"
//INFO : "RootGroup contains these members:"
//INFO : "	disc"
//INFO : "******** GROUPS UNDER GrandChildModel ********"
//INFO : "GrandChildModel.GrandChildGroup contains these members:"
//INFO : "	null"
//INFO : "******** FINDING ALL GROUPS IN THE SCENE ********"
//INFO : "# of models under the root: 3"
//INFO : "RootGroup contains these members:"
//INFO : "	disc"
//INFO : "ChildModel.ChildGroup contains these members:"
//INFO : "	torus"
//INFO : "AnotherChildModel.AnotherChildGroup contains these members:"
//INFO : "	sphere"
//INFO : "GrandChildModel.GrandChildGroup contains these members:"
//INFO : "	null"
//----------------------------------------------------------
//
//	HELPERS
//
// Finds all groups under a specific model (not recursive)
function FindGroupsUnderModel( in_model )
{
	// Find all groups under the specified model
	var oGrps = in_model.Groups;
	for (var g=0; g<oGrps.Count; g++) 
	{
		LogMessage( oGrps(g).FullName + " contains these members:" );
		var m = new Enumerator( oGrps(g).Members );
		for ( ; !m.atEnd(); m.moveNext() )
		{
			LogMessage( "\t" + m.item().Name );
		}
	}
}
//----------------------------------------------------------
// Recursively finds all groups under a model. Because
// we can get every model recursively (except for our starting point, the 
// current model), we start by listing the groups under the 
// current model and then the groups for each model under
// it, calling FindGroupsUnderModel for each one.
function RecursiveGroupSearch( in_model )
{
	LogMessage( "******** FINDING ALL GROUPS IN THE SCENE ********" );
	LogMessage( "# of models under the root: " + in_model.Models.Count );
	// First print out the groups info for the current model
	FindGroupsUnderModel( in_model );
	// Then iterate over every model contained inside the
	// current model, printing the groups info for each one
	var mdl = new Enumerator( in_model.Models );
	for ( ; !mdl.atEnd(); mdl.moveNext() ) 
	{
		FindGroupsUnderModel( mdl.item() );
	}
}