SubComponent

Object Hierarchy | 関連する C++クラス:SubComponent

継承

SIObject

サブコンポーネント

導入

v2.0

詳細

X3DObjectGeometryのサブエレメントにアクセスできます。SubComponent オブジェクトの最も一般的な用途には、次のものがあります。

- 選択されたコンポーネントへのアクセス(「CollectionItem.SubComponent」および「Selection.Item」を参照)

- オブジェクト上でのジオメトリに固有のコンポーネントのコレクションへのアクセス(「SubComponent.ComponentCollection」を参照)

- コンポーネントのサブセットとの動的な操作(「SubComponent.AddElement」および「SubComponent.RemoveElement」を参照)

メソッド

AddElement CreateCluster IsClassOfオペレータ IsEqualToオペレータ
RemoveElement      
       

プロパティ

Application Categories ClusterType ComponentCollectionオペレータ
ElementArray FullNameオペレータ Help Nameオペレータ
NestedObjects Origin OriginPath Parent
Parent3DObject Typeオペレータ Type  
       

1. JScript の例

/*
        This example demonstrates how to determine which edges are selected
        in the UI by using the SubComponent object via the Selection
*/ 
NewScene( null, false );
// Setup: create a polygon mesh and select some edges on it
var 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)
var selected = Selection(0).SubComponent.ComponentCollection;
for (var i=0; i<selected.Count; i++) {
        var sel = selected(i);
        Application.LogMessage( "edge[" + sel.Index + "] is selected." );
}
// 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. Python の例

#
# 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
# 
app = Application
app.NewScene( "", 0 )
# Setup: create a NURBS mesh and get its point collection
grid = app.ActiveSceneRoot.AddGeometry( "Grid", "NurbsSurface" )
pnts = grid.ActivePrimitive.Geometry.Points
# Convert it to SubComponent and just for fun, consider only ten points 
# chosen at random
subcmp = pnts.SubComponent
subset = [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
for ctrlpnt in subcmp.ComponentCollection :
        msg = "CtrlPnt[" + str(ctrlpnt.Index) + "]"
        if ctrlpnt.IsBoundary :
                msg += " on the NurbsSurface and is a boundary." 
        else :
                msg += " on the NurbsSurface and is NOT a boundary." 
        app.LogMessage( msg )
# Expected results:
#INFO : CtrlPnt[13] on the NurbsSurface and is NOT a boundary.
#INFO : CtrlPnt[92] on the NurbsSurface and is NOT a boundary.
#INFO : CtrlPnt[24] on the NurbsSurface and is NOT a boundary.
#INFO : CtrlPnt[65] on the NurbsSurface and is a boundary.
#INFO : CtrlPnt[11] on the NurbsSurface and is a boundary.
#INFO : CtrlPnt[2] on the NurbsSurface and is a boundary.
#INFO : CtrlPnt[4] on the NurbsSurface and is a boundary.
#INFO : CtrlPnt[64] on the NurbsSurface and is NOT a boundary.
#INFO : CtrlPnt[100] on the NurbsSurface and is NOT a boundary.
#INFO : CtrlPnt[111] on the NurbsSurface and is a boundary.

3. JScript の例

// Create a sample scene and select four points on a grid
var oGrid = ActiveSceneRoot.AddGeometry( "Grid", "NurbsSurface" ) ;
SelectObj( oGrid ) ;
ActivateVertexSelTool();
AddToSelection(oGrid.Name+".pnt[(0,0),(1,0),(2,0),(3,0)]", null, true);
// Print out information that is available from the OM
Application.LogMessage( ClassName( Selection(0) ) ) ;
var oSubComponent = Selection(0).SubComponent ;
Application.LogMessage( oSubComponent.Parent3DObject ) ;
Application.LogMessage( oSubComponent.Type ) ;
Application.LogMessage( ClassName( oSubComponent.ComponentCollection ) ) ;
Application.LogMessage( oSubComponent.ComponentCollection.Count ) ;
// Result of running this script:
//INFO : "CollectionItem"
//INFO : "grid"
//INFO : "pntSubComponent"
//INFO : "PointCollection"
//INFO : "4"

関連項目

PointCollection.SubComponent SegmentCollection.SubComponent FacetCollection.SubComponent CollectionItem.SubComponent Geometry.CreateSubComponent Cluster.CreateSubComponent ClusterTypes