Groups (Model)

Description

Returns a GroupCollection containing all Group objects in the model.

C# Syntax

// get accessor
GroupCollection rtn = Model.Groups;

Examples

VBScript Example

'----------------------------------------------------------
'
'  This example demonstrates 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
'
'  NB: The Model.Groups property has a limitation of only 
'      getting the immediate children of that model 
'      (whereas you can get every all models in all 
'      generations with the X3DObject.Models property).
'

'----------------------------------------------------------
'
'  SETUP
'
NewScene , false

' Set up a scene with 4 objects
set oRoot = ActiveSceneRoot
set oMbr1 = oRoot.AddGeometry( "Disc", "MeshSurface" )
set oMbr2 = oRoot.AddGeometry( "Torus", "MeshSurface" )
set oMbr3 = oRoot.AddGeometry( "Sphere", "MeshSurface" )
set oMbr4 = oRoot.AddNull()

' Create a group under the root 
oRoot.AddGroup oMbr1, "RootGroup"

' Create a new model and another group under the new model 
set oMdl = oRoot.AddModel( oMbr2, "ChildModel" )
oMdl.AddGroup oMbr2, "ChildGroup" 

' Add another model to the root 
set oMdl = oRoot.AddModel( oMbr3, "AnotherChildModel" )
oMdl.AddGroup oMbr3, "AnotherChildGroup"

' Nest yet another model under the second child model
set 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
   set oGrps = in_model.Groups

   for each g in oGrps 
       LogMessage g.FullName & " contains these members:"

       for each m in g.Members
          LogMessage vbTab & m.Name
       next
   next
end function


'----------------------------------------------------------
' Finds all groups under a specific model (recursive). Since
' we can get every model recursively (except the one we 
' started with) start with listing the groups under the 
' current model and then get 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
   for each mdl in in_model.Models
       FindGroupsUnderModel mdl
   next
end function


Autodesk Softimage v7.5