Point.SubComponent operator

Introduced

v3.0

Description

Creates a SubComponent from this point. The new SubComponent allows you to access the specific type of Geometry, such as a Vertex for a PolygonMesh object vs. a ControlPoint for a NurbsSurfaceMesh.

C# Syntax

// get accessor
SubComponent rtn = Point.SubComponent;

Examples

1. Python Example

#
# This example demonstrates how to work with a subset of points on a polygon mesh
#
app = Application
app.NewScene( "", 0 )
oObj = app.ActiveSceneRoot.AddGeometry( "Cube","MeshSurface" )
oPointColl = oObj.ActivePrimitive.Geometry.Points
oSubComponent = oPointColl(2).SubComponent
app.LogMessage( "%s has %s components of type %s" % ( oSubComponent.FullName , len(oSubComponent.ElementArray)+1, \
	app.ClassName(oSubComponent.ComponentCollection(0)) ) )
oObj = app.ActiveSceneRoot.AddGeometry( "Cube","MeshSurface" )
oSubComponent = oObj.ActivePrimitive.Geometry.Points(2).SubComponent
oSubComponent.AddElement(3)
app.LogMessage( "%s has %s components of type %s" % ( oSubComponent.FullName , len(oSubComponent.ElementArray)+1, \
	app.ClassName(oSubComponent.ComponentCollection(0)) ) )
# Expected results:
#INFO : cube.pnt[2] has 2 components of type Vertex
#INFO : cube1.pnt[2,3] has 3 components of type Vertex

2. JScript Example

/*
	This example demonstrates how to access a NURBS-specific property
	on a NurbsSurfaceMesh. First it starts out getting the generic
	Points collection. From the PointCollection it creates a SubComponent.
	From the SubComponent, it gets the NURBS-specific ControlPointCollection
*/
NewScene( null, false );
// Setup: create a NURBS mesh and get its point collection
var grid = Application.ActiveSceneRoot.AddGeometry( "Grid", "NurbsSurface" );
var pnts = grid.ActivePrimitive.Geometry.Points;
// Convert it to SubComponent and just for fun, consider only ten points 
// chosen at random
var subcmp = pnts.SubComponent;
var subset = new Array(13, 92, 24, 65, 11, 2, 4, 64, 100, 111);
subcmp.ElementArray = subset;
// Now convert the SubComponent to a ControlPointCollection using the
// SubComponent.ComponentCollection property and then loop through the 
// array, checking to see if we have any boundaries
var ctrlpnts = subcmp.ComponentCollection;
for (var i=0; i<ctrlpnts.Count; i++) {
	var results = ( ctrlpnts(i).IsBoundary ) ? "" : "NOT ";
	Application.LogMessage( "CtrlPnt[" + i + "] is at index " + ctrlpnts(i).Index 
		+ " on the NurbsSurface and is " + results + " a boundary." );
}
// Expected results:
//INFO : CtrlPnt[0] is at index 13 on the NurbsSurface and is NOT  a boundary.
//INFO : CtrlPnt[1] is at index 92 on the NurbsSurface and is NOT  a boundary.
//INFO : CtrlPnt[2] is at index 24 on the NurbsSurface and is NOT  a boundary.
//INFO : CtrlPnt[3] is at index 65 on the NurbsSurface and is  a boundary.
//INFO : CtrlPnt[4] is at index 11 on the NurbsSurface and is  a boundary.
//INFO : CtrlPnt[5] is at index 2 on the NurbsSurface and is  a boundary.
//INFO : CtrlPnt[6] is at index 4 on the NurbsSurface and is  a boundary.
//INFO : CtrlPnt[7] is at index 64 on the NurbsSurface and is NOT  a boundary.
//INFO : CtrlPnt[8] is at index 100 on the NurbsSurface and is NOT  a boundary.
//INFO : CtrlPnt[9] is at index 111 on the NurbsSurface and is  a boundary.

3. VBScript Example

'
' This example demonstrates how to determine which points are selected
' in the UI by using the SubComponent object via the Selection
' 
NewScene , false
' Setup: create a polygon mesh and select some vertices on it
set torus = Application.ActiveSceneRoot.AddGeometry( "Torus", "MeshSurface" )
Selection.Clear
Selection.SetAsText torus.Name & ".pnt[2-7,17,18,21-23,26,29,47,51,55]" 
' 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 a VertexCollection)
set selected = Selection(0).SubComponent.ComponentCollection
for each sel in selected 
	Application.LogMessage "edge[" & sel.Index & "] is selected."
next
' Expected results:
'INFO : edge[2] is selected.
'INFO : edge[3] is selected.
'INFO : edge[4] is selected.
'INFO : edge[5] is selected.
'INFO : edge[6] is selected.
'INFO : edge[7] is selected.
'INFO : edge[17] is selected.
'INFO : edge[18] is selected.
'INFO : edge[21] is selected.
'INFO : edge[22] is selected.
'INFO : edge[23] is selected.
'INFO : edge[26] is selected.
'INFO : edge[29] is selected.
'INFO : edge[47] is selected.
'INFO : edge[51] is selected.
'INFO : edge[55] is selected.