v3.0
このセグメントから SubComponent を作成します。新しい SubComponent を使用すると、特定のタイプの Geometry(PolygonMesh オブジェクトの場合は Edge)にアクセスできます。
// get accessor SubComponent rtn = Segment.SubComponent; |
' ' This example demonstrates how to work with a subset of segments on a polygon mesh ' NewScene , false dim oObj, oSubComponent set oObj = Application.ActiveSceneRoot.AddGeometry("Cube","MeshSurface") set oSegColl = oObj.ActivePrimitive.Geometry.Edges set oSubComponent = oSegColl(4).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.Edges(7).SubComponent oSubComponent.AddElement 4 Application.LogMessage oSubComponent & " has " & UBound(oSubComponent.ElementArray)+1 & _ " components of type " & TypeName(oSubComponent.ComponentCollection(0)) ' Expected results: 'INFO : cube.edge[4] has 1 components of type Edge 'INFO : cube1.edge[4,7] has 2 components of type Edge |
/* This example demonstrates how to access a PolygonMesh-specific property. First it starts out getting the generic Segments collection. From the SegmentCollection it creates a SubComponent. From the SubComponent, it gets the PolygonMesh-specific EdgeCollection */ NewScene( null, false ); // Setup: create a PolygonMesh and get its segment collection var cyl = Application.ActiveSceneRoot.AddGeometry( "Disc", "MeshSurface" ); var fcs = cyl.ActivePrimitive.Geometry.Segments; // Convert it to SubComponent and just for fun, select edges in the middle var subcmp = fcs.SubComponent; var subset = new Array(23,40,31,12,6,15,22,39); subcmp.ElementArray = subset; // Now convert the SubComponent to a EdgeCollection using the // SubComponent.ComponentCollection property and then loop // through the list of Edges, finding whether it is a boundary var edgs = subcmp.ComponentCollection; for (var i=0; i<edgs.Count; i++) { var results = ( edgs(i).IsBoundary ) ? "" : "NOT "; Application.LogMessage( "Edge[" + i + "] at index " + edgs(i).Index + " is " + results + "a boundary." ); } // Expected results: //INFO : Edge[0] at index 23 is a boundary. //INFO : Edge[1] at index 40 is a boundary. //INFO : Edge[2] at index 31 is NOT a boundary. //INFO : Edge[3] at index 12 is NOT a boundary. //INFO : Edge[4] at index 6 is NOT a boundary. //INFO : Edge[5] at index 15 is NOT a boundary. //INFO : Edge[6] at index 22 is NOT a boundary. //INFO : Edge[7] at index 39 is NOT a boundary. |
# # This example demonstrates how to determine which edges 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 edges on it disc = app.ActiveSceneRoot.AddGeometry( "Disc", "MeshSurface" ) app.Selection.Clear() app.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) selected = app.Selection(0).SubComponent.ComponentCollection for sel in selected : app.LogMessage( "edge[%s] is selected." % (sel.Index) ) # 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. |