CollectionItem.SubComponent

Description

Returns the SubComponent object if the CollectionItem is a subelement container. Otherwise it will return "nothing". For example, if geometry components are selected, then Selection.Item returns a CollectionItem containing those subelements (points, edges, facets, etc.). By converting the CollectionItem into a SubComponent, you can use the SubComponent.ComponentCollection property to work with the specific geometry interfaces (ControlPoint, Vertex, Edge, NurbsCurve, etc.).

Examples

1. VBScript Example

'
'       This example demonstrates how to determine which edges are selected
'       in the UI by using the SubComponent object via the Selection
' 
NewScene , false
' Setup: create a polygon mesh and select some edges on it
set disc = Application.ActiveSceneRoot.AddGeometry( "Disc", "MeshSurface" )
Selection.Clear()
Selection.SetAsText( disc.Name & ".edge[113,115,117,119,121]" )
' When components are selected, the first member of the Selection
' is returned as a CollectionItem which can then be converted to a
' SubComponent object. From there, the ComponentCollection property
' converts it to the proper collection type (in this case an EdgeCollection)
set selected = Selection(0).SubComponent.ComponentCollection
for each sel in selected
        Application.LogMessage "edge[" & sel.Index & "] is selected." 
next
' Expected results:
'INFO : edge[113] is selected.
'INFO : edge[115] is selected.
'INFO : edge[117] is selected.
'INFO : edge[119] is selected.
'INFO : edge[121] is selected.

2. VBScript Example

set oRoot = Application.ActiveProject.ActiveScene.Root
set oObject = oRoot.AddGeometry("Cube", "MeshSurface", "MyCube")
set oItem = CreateObject("XSI.CollectionItem")
oItem.Value = oObject.FullName & "." & siVertexCluster & "[*]"
set oSubComponent = oItem.SubComponent

See Also

Selection