オブジェクトの親(SIObject から派生するオブジェクト)を、次のように戻します。
シーン ルートの Parent プロパティを呼び出す場合は(Model)、Parent プロパティ自身を戻します。
その他の X3DObject の Parent プロパティを呼び出す場合は、その X3DObject の親が戻されます。
Property の Parent プロパティを呼び出す場合は、そのプロパティを所有する X3DObject が戻されます。
Parameter の Parent プロパティを呼び出す場合は、そのパラメータが直接含まれる ProjectItem が戻されます。ProjectItem.Parameters コレクションには子オブジェクト内のパラメータが含まれていることがよくあります。たとえば、X3DObject には、実際に Kinematics やその他のネストされているプロパティからきたパラメータが含まれていることがあります。このため、Parent プロパティはパラメータがどこから来たものかを判断する上で、非常に役立ちます。この概念は、以下の例に表されています。
ジオメトリコンポーネント(Point、Geometry、または Segment)の Parent プロパティを呼び出す場合は、親 Facet が戻されます。
SubComponent の Parent プロパティを呼び出した場合は、親ジオメトリが戻されます。これは、SubComponent オブジェクトにはジオメトリコンポーネントへの参照が含まれているためです(サブコンポーネントの親である実際の X3DObject を取得するには、SubComponent.Parent3DObject を使用します)。
Primitive 上の Parent プロパティを呼び出す場合は、親 Cluster が戻されます。
Operator 上の Parent プロパティを呼び出す場合は、オペレータの最初の OutputPort のターゲットが戻されます。
モデルの下のActionSourceの Parent プロパティを呼び出すと、Modelが戻されます。SimulationEnvironment キャッシュ上の Parent プロパティを呼び出すと、SimulationEnvironment が戻されます。この変更は v5.0 によるものです。以前のリリースでは、Mixer オブジェクトが戻されていました。
- 親を持たない Application オブジェクト(オブジェクトなど)の Parent プロパティを呼び出すと、オブジェクトが親として戻されます。
Command のような単純なオブジェクトは、親として XSIApplication を戻します。
ヒント:共用されているMaterialのように、オブジェクトの中には実際に複数の親を持つものもあります。そして中には、同じオブジェクトがシーンエキスプローラ内やグラフ内の複数の場所に現れるという場合もあります。このような場合は、ProjectItem.Owners プロパティを使用してすべての「親」にアクセスできます。
注:現在、SIObject のすべてのネストされた子を見つけるための、同様なプロパティは存在しません。代わりに、これらの子は、タイプ(X3DObject.Children、ProjectItem.Parameters、ParticleCloudPrimitive.Particles、X3DObject.Primitives など)に応じてさまざまなコレクションで使用できます。EnumElements コマンドは、タイプに関らず、すべての子を見つける方法の 1 つです。
// get accessor Object rtn = SIObject.Parent; |
'
' This example displays the name of the object's parent
'
set oObj = ActiveProject.ActiveScene.Root.AddGeometry("Sphere", "NurbsSurface")
Application.LogMessage oObj.Parent.Name |
set oObject = ActiveSceneroot.AddGeometry("Cube","MeshSurface","MyCube")
set oCluster = oObject.ActivePrimitive.Geometry.AddCluster(siVertexCluster,"MyCluster",Array(3,4,5))
set oSubComponent = oCluster.CreateSubComponent
set oClusterGeometry = oSubComponent.Parent
set oObjectGeometry = oObject.Parent
Application.LogMessage "The parent of " & oSubComponent & " is " & oClusterGeometry
Application.LogMessage "The parent of the " & oObject & " is " & oObjectGeometry
' OUTPUT OF ABOVE SCRIPT IS:
'INFO : "The parent of MyCube.pnt[3-5] is polymsh"
'INFO : "The parent of the MyCube is Scene_Root" |
#
# This Python example demonstrates how the Parent property can
# be used to travel from a child SIObject to its parent
#
# Expected results: each line in the scripted history should print "True"
# Prepare a simple scene and collect some object model
# references to objects inside it
Application.NewScene( "", 0 )
oSceneRoot = Application.ActiveSceneRoot
oNull = oSceneRoot.AddNull()
oNullLocalKine = oNull.Kinematics.Local
oNestedCone = oNull.AddGeometry( "Cone","MeshSurface","NestedCone")
oNestedConeGeom = oNestedCone.ActivePrimitive.Geometry
# Parent of Scene Root is itself
Application.LogMessage( oSceneRoot.Parent.IsEqualTo( oSceneRoot ) )
# Parent of Null is the Scene Root
Application.LogMessage( oNull.Parent.IsEqualTo( oSceneRoot ) )
# Parent of nested cone is the Null
Application.LogMessage( oNestedCone.Parent.IsEqualTo( oNull ) )
# Parent of a property is the direct owner
Application.LogMessage( oNull.Kinematics.Parent.IsEqualTo( oNull ) )
# Parent of a parameter
Application.LogMessage( oNullLocalKine.Parameters("posx").Parent.FullName
== oNullLocalKine.FullName )
# This same parameter also appears directly under the Null,
# but the Parent property tells the truth about where it comes from
Application.LogMessage( oNull.Parameters("posx").Parent.FullName
== oNullLocalKine.FullName )
# Use Parent to travel all the way from a Point to its X3DObject
Application.LogMessage( oNestedConeGeom.Points(0).Parent.Parent.Parent.IsEqualTo( oNestedCone ) )
# Command object just returns the XSIApplication as its parent
Application.LogMessage( Application.Commands(0).Parent.IsEqualTo( Application ) ) |