## SIObject.Parent

### Description

Returns the parent (any object that derives from SIObject) of the object as follows:
If you call the Parent property on the scene root (Model), it returns itself.
If you call the Parent property on any other X3DObject, it returns the parent of the X3DObject.
If you call the Parent property on a Property, it returns the X3DObject that owns that Property.
If you call the Parent property on a Parameter, it returns the ProjectItem directly containing that Parameter. Note that often the ProjectItem.Parameters collection includes parameters that are actually contained inside children objects. For example an X3DObject may appear to have parameters that actually come from the Kinematics and other nested properties. For this reason the Parent property is very useful for determining where these parameters come from. This concept is demonstrated in one of the examples below.
If you call the Parent property on a geometry component (e.g. Point, Segment, or Facet) it returns the parent Geometry.
If you call the Parent property on a SubComponent, it returns the parent geometry because a SubComponent object contains references to geometry components (to get the actual X3DObject parenting the subcomponent, use SubComponent.Parent3DObject).
If you call the Parent property on a Cluster, it returns the parent Primitive.
If you call the Parent property on an Operator, it returns the target of the operator's first OutputPort.
If you call the Parent property on an ActionSource under a model, it returns that Model. If you call the Parent property on a SimulationEnvironment cache, it returns the SimulationEnvironment. This changed as of v5.0: in previous releases it was returning the Mixer object.
If you call the Parent property on an object that has no parent, like the Application object, it returns the object as parent.
Some simple objects like Command return the XSIApplication as parent.
Tip: Some objects may actually have multiple parents, such as a shared Material, in which case the same object appears at multiple places in the scene explorer and in the graph. In this case all the "parents" can be reached via the ProjectItem.Owners property.
Note: These is currently no equivalent property for finding all nested "children" of an SIObject. Instead these children are available in different collections depending on their type (for example, X3DObject.Children, ProjectItem.Parameters, ParticleCloudPrimitive.Particles, and X3DObject.Primitives). The EnumElements command is one way of finding all children without regard to the type.

### C# Syntax

    // get accessor
    Object rtn = SIObject.Parent;

### Examples

#### 1. VBScript Example

    '
    '       This example displays the name of the object's parent
    '
    set oObj = ActiveProject.ActiveScene.Root.AddGeometry("Sphere", "NurbsSurface")
    Application.LogMessage oObj.Parent.Name

#### 2. VBScript Example

    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"

#### 3. Python Example

    #
    #       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 ) )

### See Also

SubComponent.Parent3DObject EnumElements ProjectItem.Owners X3DObject.Children