Facet.SubComponent

Facet.SubComponent operator

導入

v2.0

詳細

このファセットから SubComponent を作成します。新しい SubComponent により、PolygonMesh オブジェクトの PolygonFaceNurbsSurfaceMesh オブジェクトの NurbsSurface など、特別なタイプの Geometry へのアクセスが可能になります。

C#構文

// get accessor

SubComponent rtn = Facet.SubComponent;

1. VBScript の例

'

' This example demonstrates how to work with a subset of facets on a polygon mesh

'

NewScene , false

dim oObj, oSubComponent 

set oObj = Application.ActiveSceneRoot.AddGeometry("Cube","MeshSurface")

set oFacetColl = oObj.ActivePrimitive.Geometry.Facets

set oSubComponent = oFacetColl(2).SubComponent

Application.LogMessage oSubComponent & " has " & UBound(oSubComponent.ElementArray)+1 & _

	" components of type " & TypeName(oSubComponent.ComponentCollection(0))

set oObj = Application.ActiveSceneRoot.AddGeometry("Cube","MeshSurface")

set oSubComponent = oObj.ActivePrimitive.Geometry.Facets(2).SubComponent

oSubComponent.AddElement 3

Application.LogMessage oSubComponent & " has " & UBound(oSubComponent.ElementArray)+1 & _

	" components of type " & TypeName(oSubComponent.ComponentCollection(0))

' Expected results:

'INFO : cube.poly[2] has 1 components of type PolygonFace

'INFO : cube1.poly[2,3] has 2 components of type PolygonFace

2. JScript の例

/*

	This example demonstrates how to access a PolygonMesh-specific property.

	First it starts out getting the generic Facets collection. From the 

	FacetCollection it creates a SubComponent. From the SubComponent, it gets 

	the PolygonMesh-specific PolygonFaceCollection

*/

NewScene( null, false );

// Setup: create a PolygonMesh and get its facet collection

var grid = Application.ActiveSceneRoot.AddGeometry( "Grid", "MeshSurface" );

var fcs = grid.ActivePrimitive.Geometry.Facets;

// Convert it to SubComponent and just for fun, consider only four facets 

var subcmp = fcs.SubComponent;

var subset = new Array(27,28,35,36);

subcmp.ElementArray = subset;

// Now convert the SubComponent to a PolygonFaceCollection using the

// SubComponent.ComponentCollection property and then loop through the 

// list of PolygonFaces, getting its adjacent neighbors

var polyfaces = subcmp.ComponentCollection;

for (var i=0; i<polyfaces.Count; i++) {

	Application.LogMessage( "PolygonFace[" + i + "] at index " + polyfaces(i) + " is next to..." );

	var adjacent = polyfaces(i).NeighborPolygons();

	for (var j=0; j<adjacent.Count; j++) {

		Application.LogMessage( "\t...the PolygonFace at index " + adjacent(j).Index );

	}

}

// Expected results:

//INFO : PolygonFace[0] at index PolygonFace is next to...

//INFO : 	...the PolygonFace at index 19

//INFO : 	...the PolygonFace at index 28

//INFO : 	...the PolygonFace at index 35

//INFO : 	...the PolygonFace at index 26

//INFO : PolygonFace[1] at index PolygonFace is next to...

//INFO : 	...the PolygonFace at index 20

//INFO : 	...the PolygonFace at index 29

//INFO : 	...the PolygonFace at index 36

//INFO : 	...the PolygonFace at index 27

//INFO : PolygonFace[2] at index PolygonFace is next to...

//INFO : 	...the PolygonFace at index 27

//INFO : 	...the PolygonFace at index 36

//INFO : 	...the PolygonFace at index 43

//INFO : 	...the PolygonFace at index 34

//INFO : PolygonFace[3] at index PolygonFace is next to...

//INFO : 	...the PolygonFace at index 28

//INFO : 	...the PolygonFace at index 37

//INFO : 	...the PolygonFace at index 44

//INFO : 	...the PolygonFace at index 35

3. Python の例

#

# This example demonstrates how to determine which polygons are selected

# in the UI by using the SubComponent object via the Selection

# 

app = Application

app.NewScene( "", 0 )

# Setup: create a polygon mesh and select some polygons on it

disc = app.ActiveSceneRoot.AddGeometry( "Sphere", "MeshSurface" )

app.Selection.Clear()

app.Selection.SetAsText( disc.Name + ".poly[20,3,47,0,16,34,22]" );

# 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 

# PolygonFaceCollection)

selected = app.Selection(0).SubComponent.ComponentCollection

for sel in selected :

	app.LogMessage( "poly[%s] is selected." % (sel.Index) )

# Expected results:

#INFO : poly[20] is selected.

#INFO : poly[3] is selected.

#INFO : poly[47] is selected.

#INFO : poly[0] is selected.

#INFO : poly[16] is selected.

#INFO : poly[34] is selected.

#INFO : poly[22] is selected.