Item (MappedItemCollection) *

Description

Sets or returns a member of the collection by index or key. If the collection is empty, this property returns "Nothing", which you can use to trap errors.

Note: This property is only operator-compliant if the property used to get this collection is also operator-compliant.

Parameters

Parameter

Type

Description

key

String or Integer

An expression that specifies the position or the name of a member of the collection.

Note: To identify the collection item by name, use the SIObject.Name value as the key, unless you are working with the ParameterCollection. With Parameters you can use the Parameter.ScriptName value. For example, oConstraints.Item("Direction Cns") will work, but oConstraints.Item("dircns") will not.

Examples

1. VBScript Example

' Set up the example using a mesh grid, cube, cone, and a nurbs cube:
set oRoot = activesceneroot
oRoot.addgeometry "grid", "meshsurface"
oRoot.addgeometry "cube", "meshsurface"
oRoot.addgeometry "cone", "meshsurface"
oRoot.addgeometry "cube", "nurbssurface"

set oGeoms = oRoot.findchildren( ,,siGeometryFamily)
logmessage "The collection of geometry from the root is a " & typename( oGeoms ) 
logmessage "There are " & oGeoms.count & " geometry objects under the root." 
logmessage ""


' Use error trapping ( if you get an empty collection, you will 
' see this error message: 'ERROR : "Object required: 'oCube1'" )
if typename( oGeoms ) = "Nothing" then
   logmessage "Collection is empty"
else 
   logmessage "Collection has " & oGeoms.count & " member(s)."
   for i = 0 to oGeoms.count - 1
       set oGeomItem = oGeoms.item(i)
       logmessage oGeomItem.name & " is a " & oGeomItem.type & " " & typename( oGeomItem )
       set oGeomItem = Nothing
   next
end if


' Output of above script is:
'INFO : "The collection of geometry from the root is a X3DObjectCollection"
'INFO : "There are 4 geometry objects under the root."
'INFO : ""
'INFO : "Collection has 4 member(s)."
'INFO : "grid is a polymsh X3DObject"
'INFO : "cube is a polymsh X3DObject"
'INFO : "cone is a polymsh X3DObject"
'INFO : "cube1 is a surfmsh X3DObject"

2. VBScript Example

'VBScript example
set oRoot = Application.ActiveProject.ActiveScene.Root
set oGrid = oRoot.AddGeometry("Grid","MeshSurface")
set oCluster = oGrid.ActivePrimitive.Geometry.AddCluster(siPolygonCluster, "PolygonClusterOnGrid", array(59,60,61))
for i = 0 to (oCluster.Elements.Count - 1)
   LogMessage "Element(" & i & ") = " & oCluster.Elements(i)
next


Autodesk Softimage v7.5