[MSCE] Creating Item type Expression with GetRelatedInstance symbol

In this blog, I will show you how you can create an expression with GetRelatedInstance to fetch properties of Parent and child elements through ECRelationships. Before knowing about the GetRelatedInstance expression symbol, it is required to know the basics about EC Classes and their relationships. Also, you should know the internal structure of related elements to fetch instance data. Let us understand how to read relationships with some existing element examples like Parametric solids, item types and cells.

Also, I will explain about on how to use the Dump tool to know instance's internal structure.

Expression Builder:

Let us see how to access the GetRelatedInstance symbol in the Expression builder first. As per the below the image, you will be able to select the GetRelatedInstance symbol in the function group drop down. After selection, you will be able to see the expression string in the Text box. Here, you need to specify RelatedInstanceAccessor as per required instance properties.

     

Expression Syntax:  

 this.GetRelatedIstance("<relationship class name>:<direction: 1=> backward, 0=>forward>:<relatedClassName>").<Property Internal Name>                                                                    

Related Instance Accessor details: 

Related Instance accessor can be defined in 2 ways:   

  1. “<relationship class name>:<direction>:<related class name>”
  2. "<relationship schema name>:<relationship class name>:<direction >:<related schema name>:<related class name>

Where,

Relationship schema and relationship class name is the name through which we can access the target instance.
Direction is defined as Forward (0) or Backward(1) from the source instance to target instance.
Related schema and the class name is a name from which we want to fetch instance properties.

Examples:                                                       

  • Forward Relationship :  

Say, we have an instance of the "Person" class. i.e. in our expression, "this" indicates an instance of the "Person" class. We want to get the value of the "Tag" property of an instance of the "Father" class. Now, the Person is related to the Father class via the "PersonIsFather" relationship where the source is the "Person" class and the target is the "Father" class. Then, our expression will be:

Expression: this.GetRelatedInstance(PersonIsFather:0:Father).Tag

Where,

PersonToFather: Name of ECRelationship between Person and Father.
0: Forward Direction from Person to Father Class. Meaning, we are asking for instance of "Father" class.
Father : Relted target ECClass
Tag: Property of Father class.

  • Backward Relationship:

Say, we have an instance of the "Father" class. i.e. in our expression, "this" indicates an instance of the "Father" class. We want to get the value of the "Tag" property of an instance of the "Person" class.    Now, the Person is related to the Father class via the "PersonIsFather" relationship where the source is the "Person" class and the target is the "Father" class. Then, our expression will be:

Expression: this.GetRelatedInstance(PersonIsFather:1:Person).Tag

Where,

PersonToFather: Name of ECRelationship between Person and Father.
1: Backward Direction from Father to Person Class. Meaning, we are asking for instance of "Person" class.
Person : Relted target ECClass
Tag: Property of Person class.

Use of Instance data Dump tool and Element structures:

Well, writing accurate relationship expression is a tedious task as you need to know the relationships between required elements instances from which you want to fetch property values. To make this task a little bit easy, you can use the utility ECX ITEMS DUMP which will dump all EC of your file into an XML file.

In the below image, you can see content of Parametric Cell: HEB in form of xml. So, this is the form in which the above key-in dumps data for element instances and their relationships.

  

 <Element Description="Parametric Cell: HEB" ElementId="3723">
    <ParametricCellElement instanceID=":ECDB00000000:158B0E0000" xmlns="DgnElementSchema.01.00">
        <Is3dElement>True</Is3dElement>
        <IsGraphicalElement>True</IsGraphicalElement>
        <Level>14</Level>
        <ElementID>3723</ElementID>
        <ModifiedTime>637919196587860000</ModifiedTime>
        <ElementSize>80</ElementSize>
        <Linkages>2</Linkages>
        <XAttributes>11</XAttributes>
        <Color xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <Weight xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <Style xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <ElementClass>0</ElementClass>
        <Transparency xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <Priority xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <Template>-1</Template>
        <Modified>True</Modified>
        <New>True</New>
        <Solid xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <ViewDependent xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <Snappable xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <TAG_RPT_Filled>False</TAG_RPT_Filled>
        <TAG_RPT_Complex>False</TAG_RPT_Complex>
        <LineStyleParams>
            <LSScale xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
            <LSWidthMode xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
            <LSStartWidth xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
            <LSEndWidth xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
            <LSGlobalWidth xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
            <LSTrueWidth xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
            <LSShiftMode xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
            <LSDistancePhase xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
            <LSFractionPhase xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
            <LSCornerMode xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
            <LSThroughCorner xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        </LineStyleParams>
        <Thickness xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <GraphicGroup xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <DisplayStyle>-1</DisplayStyle>
        <Locked>False</Locked>
        <MaterialProjectionParameters>
            <Orientation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
            <ProjectionMapping xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
            <Offset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
            <Scale xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
            <ProjectionGroup xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        </MaterialProjectionParameters>
        <RangeLow>228407,-70310,38097</RangeLow>
        <RangeHigh>258408,-70309,128098</RangeHigh>
        <Model3d>False</Model3d>
        <Top>False</Top>
        <Bottom>False</Bottom>
        <Front>False</Front>
        <Back>False</Back>
        <FrontBack>False</FrontBack>
        <Left>False</Left>
        <Right>False</Right>
        <RotationX>1.5707963267948959</RotationX>
        <RotationY>4.2732504141856978E-17</RotationY>
        <RotationZ>-3.7241688681745965E-15</RotationZ>
        <RotationAngle>-3.1415926535897922</RotationAngle>
        <RotationPlane>6</RotationPlane>
        <Origin>228407.20502228849,-70309.400259785791,38097.804762502681</Origin>
        <Scale>1</Scale>
        <IsAnnotation>False</IsAnnotation>
        <AnnotationPurpose>False</AnnotationPurpose>
        <StickyPoint xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <Volume xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <SurfaceArea>371275666.11769205</SurfaceArea>
        <ElementDescription>Parametric Cell: HEB</ElementDescription>
        <Model>3D Metric Design</Model>
        <Links />
        <DwgCustomObjectPropertyList />
        <ElementType>Parametric Cell</ElementType>
        <Groups />
        <AttachedMaterial />
        <AssignedMaterial xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <CellDefinitionName>HEB</CellDefinitionName>
        <ParameterSetName>HE-900B</ParameterSetName>
    </ParametricCellElement>
    <OnSameElement Direction="Forward" InstanceId=":ECDB00000000:158B0E0000::::ECDA00000002:158B0E0000:::DgnContentRelationshipSchema.01.00:::OnSameElement" xmlns="DgnContentRelationshipSchema.01.00">
        <RelatedTo>
            <Steel__x0020__Section_DgnCellParameters instanceID=":ECDA00000002:158B0E0000" ElementId="3723" xmlns="DgnComponent___DgnCustomItemTypes_Structural.01.00" />
        </RelatedTo>
    </OnSameElement>
    <ParametricCellToDefinitionElement Direction="Forward" InstanceId=":ECDB00000000:158B0E0000::::ECDB00000000:15B20F0000:::DgnContentRelationshipSchema.01.00:::ParametricCellToDefinitionElement" xmlns="DgnContentRelationshipSchema.01.00">
        <RelatedTo>
            <ComplexShapeElement instanceID=":ECDB00000000:15B20F0000" ElementId="4018" xmlns="DgnElementSchema.01.00" />
        </RelatedTo>
    </ParametricCellToDefinitionElement>
    <LeafElementToSmartFeatureElementRelationship Direction="Forward" InstanceId=":ECDB00000000:158B0E0000::::ECDB00000000:158F0E0000:::SmartFeaturesSchema.01.00:::LeafElementToSmartFeatureElementRelationship" xmlns="SmartFeaturesSchema.01.00">
        <RelatedTo>
            <SmartFeatureContainer instanceID=":ECDB00000000:158F0E0000" ElementId="3727" />
        </RelatedTo>
    </LeafElementToSmartFeatureElementRelationship>
    <SmartFeatureToCellParametersRelationship Direction="Forward" InstanceId=":ECDB00000000:158B0E0000::::ECDB00000000:158F0E0000:::SmartFeaturesSchema.01.00:::SmartFeatureToCellParametersRelationship" xmlns="SmartFeaturesSchema.01.00">
        <RelatedTo>
            <SmartFeatureContainer instanceID=":ECDB00000000:158F0E0000" ElementId="3727" />
        </RelatedTo>
    </SmartFeatureToCellParametersRelationship>
    <OnSameElement Direction="Backward" InstanceId=":ECDA00000002:158B0E0000::::ECDB00000000:158B0E0000:::DgnContentRelationshipSchema.01.00:::OnSameElement" xmlns="DgnContentRelationshipSchema.01.00">
        <RelatedTo>
            <Steel__x0020__Section_DgnCellParameters instanceID=":ECDA00000002:158B0E0000" ElementId="3723" xmlns="DgnComponent___DgnCustomItemTypes_Structural.01.00" />
        </RelatedTo>
    </OnSameElement>
    <ItemIsAttachedToElement Direction="Backward" InstanceId=":ECDA00000002:158B0E0000::::ECDB00000000:158B0E0000:::DgnContentRelationshipSchema.01.00:::ItemIsAttachedToElement" xmlns="DgnContentRelationshipSchema.01.00">
        <RelatedTo>
            <Steel__x0020__Section_DgnCellParameters instanceID=":ECDA00000002:158B0E0000" ElementId="3723" xmlns="DgnComponent___DgnCustomItemTypes_Structural.01.00" />
        </RelatedTo>
    </ItemIsAttachedToElement>
    <ModelElementRelationship Direction="Backward" InstanceId=":EC01:00000000:C:\Users\Sanjivani.Ichake\Downloads\3463.TestExpression.dgn::::ECDB00000000:158B0E0000:::DgnContentRelationshipSchema.01.00:::ModelElementRelationship" xmlns="DgnContentRelationshipSchema.01.00">
        <RelatedTo>
            <DesignModel instanceID=":EC01:00000000:C:\Users\Sanjivani.Ichake\Downloads\3463.TestExpression.dgn" xmlns="DgnModelSchema.01.00" />
        </RelatedTo>
    </ModelElementRelationship>
    <ModelElementHostedRelationship Direction="Backward" InstanceId=":EC01:00000000:C:\Users\Sanjivani.Ichake\Downloads\3463.TestExpression.dgn::::ECDB00000000:158B0E0000:::DgnContentRelationshipSchema.01.00:::ModelElementHostedRelationship" xmlns="DgnContentRelationshipSchema.01.00">
        <RelatedTo>
            <DesignModel instanceID=":EC01:00000000:C:\Users\Sanjivani.Ichake\Downloads\3463.TestExpression.dgn" xmlns="DgnModelSchema.01.00" />
        </RelatedTo>
    </ModelElementHostedRelationship>
</Element>
                                                 

ECX Dump tool mainly dumps data for each ECInstances, their related instances and relationships among them.

So in the above example, the Parametric cell is a profile element instance(i.e.ParametricCellElement). Now, this Parametric cell element has various relationships. One of them is  SmartFeatureToCellParametersRelationship which shows relationship between Parametric Cell Instance(ParametricCellElement Class) and Parametric Solid instance(SmartFeatureContainer Class).

Below is the definition of SmartFeatureToCellParametersRelationship defined in schema. Where we mention that how the relationship will be used, which types of elements will be defined as source and target, how many instances at source and target can be added.

 

<ECRelationshipClass typeName="SmartFeatureToCellParametersRelationship" displayLabel="SmartFeatureContainer to Cell parameters" strength="referencing">
    <ECCustomAttributes>
        <IsSymmetricalRelationship xmlns="Bentley_Standard_CustomAttributes.01.10" />
        <DisplayOptions xmlns="Bentley_Standard_CustomAttributes.01.10">
            <Hidden>True</Hidden>
        </DisplayOptions>
        <SearchOptions xmlns="Bentley_Standard_CustomAttributes.01.10">
            <Hidden>True</Hidden>
        </SearchOptions>
        <RelationshipIsNotStored xmlns="DgnCustomAttributes.01.00" />
        <DgnECRelationshipAttributes xmlns="DgnCustomAttributes.01.00">
            <SourceHostType>1</SourceHostType>
            <TargetHostType>1</TargetHostType>
        </DgnECRelationshipAttributes>
    </ECCustomAttributes>
    <Source cardinality="(0,N)" polymorphic="True">
        <Class class="SmartFeatureContainer" />
    </Source>
    <Target cardinality="(1,1)" polymorphic="True">
        <Class class="DgnCellParameters" />
    </Target>
</ECRelationshipClass>
               

We will use the above information in further examples to form expressions and fetch required properties.

Different ways to use GetRelatedInstance Symbol expression:

1. Fetch immediate parent properties.

Use case:

Here, we want to fetch parent shape's element class or it’s properties in attached item type Door. To write this expression, we first need to know target instance class name (e.g. MstnGraphHeader), it's relationship with item type instance(e.g. OnSameElement) and direction of relationship(e.g. 0 - forward)

Below is the OnSameElement relationship definition in schema. So, here ECRelationshipClass describes strength is referencing,  source and target host should be of Element type 1, it's cardinality is (0,N) & can create relationship between Anyclass to Anyclass.

 

<ECRelationshipClass typeName="OnSameElement" displayLabel="On same Element" strength="referencing">
    <ECCustomAttributes>
        <IsSymmetricalRelationship xmlns="Bentley_Standard_CustomAttributes.01.10" />
        <DisplayOptions xmlns="Bentley_Standard_CustomAttributes.01.10">
            <Hidden>True</Hidden>
        </DisplayOptions>
        <SearchOptions xmlns="Bentley_Standard_CustomAttributes.01.10">
            <Hidden>True</Hidden>
        </SearchOptions>
        <RelationshipIsNotStored xmlns="DgnCustomAttributes.01.00" />
        <DgnECRelationshipAttributes xmlns="DgnCustomAttributes.01.00">
            <SourceHostType>1</SourceHostType>
            <TargetHostType>1</TargetHostType>
        </DgnECRelationshipAttributes>
    </ECCustomAttributes>
    <Source cardinality="(0,N)" roleLabel="On same Element" polymorphic="True">
        <Class class="bsc:AnyClass" />
    </Source>
    <Target cardinality="(0,N)" roleLabel="On same Element" polymorphic="True">
        <Class class="bsc:AnyClass" />
    </Target>
</ECRelationshipClass>
              

So, with all the above information we can form the expression as below:

  

 <Element Description="Shape" ElementId="1265">
    <ShapeElement instanceID=":ECDB00000000:15F1040000" xmlns="DgnElementSchema.01.00">
        <Is3dElement>False</Is3dElement>
        <IsGraphicalElement>True</IsGraphicalElement>
        <Level>64</Level>
        <ElementID>1265</ElementID>
        <ModifiedTime>637919230385310000</ModifiedTime>
        <ElementSize>96</ElementSize>
        <Linkages>0</Linkages>
        <XAttributes>2</XAttributes>
        <Color>-1</Color>
        <Weight>-1</Weight>
        <Style>2147483647</Style>
        <ElementClass>0</ElementClass>
        <Transparency>0</Transparency>
        <Priority>0</Priority>
        <Template>-1</Template>
        <Modified>True</Modified>
        <New>True</New>
        <Solid>True</Solid>
        <ViewDependent xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <Snappable>True</Snappable>
        <TAG_RPT_Filled>False</TAG_RPT_Filled>
        <TAG_RPT_Complex>False</TAG_RPT_Complex>
        <LineStyleParams>
            <LSScale>1</LSScale>
            <LSWidthMode>0</LSWidthMode>
            <LSStartWidth xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
            <LSEndWidth xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
            <LSGlobalWidth xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
            <LSTrueWidth xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
            <LSShiftMode>0</LSShiftMode>
            <LSDistancePhase xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
            <LSFractionPhase xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
            <LSCornerMode>0</LSCornerMode>
            <LSThroughCorner>False</LSThroughCorner>
        </LineStyleParams>
        <Thickness xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <GraphicGroup xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <DisplayStyle>-1</DisplayStyle>
        <Locked>False</Locked>
        <MaterialProjectionParameters>
            <Orientation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
            <ProjectionMapping xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
            <Offset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
            <Scale xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
            <ProjectionGroup xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        </MaterialProjectionParameters>
        <RangeLow>994670143,801230855,0</RangeLow>
        <RangeHigh>998776017,803921365,0</RangeHigh>
        <Model3d>False</Model3d>
        <Top>False</Top>
        <Bottom>False</Bottom>
        <Front>False</Front>
        <Back>False</Back>
        <FrontBack>False</FrontBack>
        <Left>False</Left>
        <Right>False</Right>
        <Count>4</Count>
        <TotalLength>13592766.00177002</TotalLength>
        <Area>11046891205371.705</Area>
        <ZDepth>0</ZDepth>
        <EnclosedArea>11046891205371.705</EnclosedArea>
        <Perimeter>13592766.00177002</Perimeter>
        <FrontClipDepth>0</FrontClipDepth>
        <BackClipDepth>0</BackClipDepth>
        <FrontClip>False</FrontClip>
        <BackClip>False</BackClip>
        <HatchSource>2</HatchSource>
        <HatchScale xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <HatchIsAnnotation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <HatchSpace xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <HatchSpace2 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <HatchCross xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <HatchAngle xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <HatchAngle2 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <HatchAssoc xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <HatchOrigin xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <HatchStyle xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <HatchEcsOrigin xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <HatchIsUserDefined xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <HatchColor xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <HatchWeight xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <HatchLineStyle xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <ElementDescription>Shape</ElementDescription>
        <Model>2D Metric Design Model</Model>
        <Links />
        <DwgCustomObjectPropertyList />
        <ElementType>Shape</ElementType>
        <Groups />
        <AttachedMaterial />
        <AssignedMaterial xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <Segments>
            <Segment>
                <Start>994670143.0576812,803921364.23319829,0</Start>
                <End>998776016.87972569,803921364.23319829,0</End>
                <Length>4105873.8220444918</Length>
                <Direction>0</Direction>
                <ElevationAngle>0</ElevationAngle>
                <DeltaX>4105873.8220444918</DeltaX>
                <DeltaY>0</DeltaY>
                <DeltaZ>0</DeltaZ>
                <Delta>-4105873.8220444918,0,0</Delta>
            </Segment>
            <Segment>
                <Start>998776016.87972569,803921364.23319829,0</Start>
                <End>998776016.87972569,801230855.05435777,0</End>
                <Length>2690509.178840518</Length>
                <Direction>-1.5707963267948966</Direction>
                <ElevationAngle>0</ElevationAngle>
                <DeltaX>0</DeltaX>
                <DeltaY>-2690509.178840518</DeltaY>
                <DeltaZ>0</DeltaZ>
                <Delta>0,2690509.178840518,0</Delta>
            </Segment>
            <Segment>
                <Start>998776016.87972569,801230855.05435777,0</Start>
                <End>994670143.0576812,801230855.05435777,0</End>
                <Length>4105873.8220444918</Length>
                <Direction>3.1415926535897931</Direction>
                <ElevationAngle>0</ElevationAngle>
                <DeltaX>-4105873.8220444918</DeltaX>
                <DeltaY>0</DeltaY>
                <DeltaZ>0</DeltaZ>
                <Delta>4105873.8220444918,0,0</Delta>
            </Segment>
            <Segment>
                <Start>994670143.0576812,801230855.05435777,0</Start>
                <End>994670143.0576812,803921364.23319829,0</End>
                <Length>2690509.178840518</Length>
                <Direction>1.5707963267948966</Direction>
                <ElevationAngle>0</ElevationAngle>
                <DeltaX>0</DeltaX>
                <DeltaY>2690509.178840518</DeltaY>
                <DeltaZ>0</DeltaZ>
                <Delta>0,-2690509.178840518,0</Delta>
            </Segment>
        </Segments>
        <Fill>AAD///8=</Fill>
        <HatchName xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <HatchCell xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
    </ShapeElement>
    <OnSameElement Direction="Forward" InstanceId=":ECDB00000000:15F1040000::::56FF00000001:15F1040000:::DgnContentRelationshipSchema.01.00:::OnSameElement" xmlns="DgnContentRelationshipSchema.01.00">
        <RelatedTo>
            <Doors instanceID=":56FF00000001:15F1040000" ElementId="1265" xmlns="DgnCustomItemTypes_Architectural.01.00" />
        </RelatedTo>
    </OnSameElement>
    <OnSameElement Direction="Forward" InstanceId=":ECDB00000000:15F1040000::::56FF00000002:15F1040000:::DgnContentRelationshipSchema.01.00:::OnSameElement" xmlns="DgnContentRelationshipSchema.01.00">
        <RelatedTo>
            <FloorArea instanceID=":56FF00000002:15F1040000" ElementId="1265" xmlns="DgnCustomItemTypes_Architectural.01.00" />
        </RelatedTo>
    </OnSameElement>
    <OnSameElement Direction="Backward" InstanceId=":56FF00000001:15F1040000::::ECDB00000000:15F1040000:::DgnContentRelationshipSchema.01.00:::OnSameElement" xmlns="DgnContentRelationshipSchema.01.00">
        <RelatedTo>
            <Doors instanceID=":56FF00000001:15F1040000" ElementId="1265" xmlns="DgnCustomItemTypes_Architectural.01.00" />
        </RelatedTo>
    </OnSameElement>
    <OnSameElement Direction="Backward" InstanceId=":56FF00000002:15F1040000::::ECDB00000000:15F1040000:::DgnContentRelationshipSchema.01.00:::OnSameElement" xmlns="DgnContentRelationshipSchema.01.00">
        <RelatedTo>
            <FloorArea instanceID=":56FF00000002:15F1040000" ElementId="1265" xmlns="DgnCustomItemTypes_Architectural.01.00" />
        </RelatedTo>
    </OnSameElement>
    <ItemIsAttachedToElement Direction="Backward" InstanceId=":56FF00000001:15F1040000::::ECDB00000000:15F1040000:::DgnContentRelationshipSchema.01.00:::ItemIsAttachedToElement" xmlns="DgnContentRelationshipSchema.01.00">
        <RelatedTo>
            <Doors instanceID=":56FF00000001:15F1040000" ElementId="1265" xmlns="DgnCustomItemTypes_Architectural.01.00" />
        </RelatedTo>
    </ItemIsAttachedToElement>
    <ItemIsAttachedToElement Direction="Backward" InstanceId=":56FF00000002:15F1040000::::ECDB00000000:15F1040000:::DgnContentRelationshipSchema.01.00:::ItemIsAttachedToElement" xmlns="DgnContentRelationshipSchema.01.00">
        <RelatedTo>
            <FloorArea instanceID=":56FF00000002:15F1040000" ElementId="1265" xmlns="DgnCustomItemTypes_Architectural.01.00" />
        </RelatedTo>
    </ItemIsAttachedToElement>
    <ModelElementRelationship Direction="Backward" InstanceId=":EC01:00000000:C:\Users\Sanjivani.Ichake\Downloads\uuu.dgn::::ECDB00000000:15F1040000:::DgnContentRelationshipSchema.01.00:::ModelElementRelationship" xmlns="DgnContentRelationshipSchema.01.00">
        <RelatedTo>
            <DesignModel instanceID=":EC01:00000000:C:\Users\Sanjivani.Ichake\Downloads\uuu.dgn" xmlns="DgnModelSchema.01.00" />
        </RelatedTo>
    </ModelElementRelationship>
    <ModelElementHostedRelationship Direction="Backward" InstanceId=":EC01:00000000:C:\Users\Sanjivani.Ichake\Downloads\uuu.dgn::::ECDB00000000:15F1040000:::DgnContentRelationshipSchema.01.00:::ModelElementHostedRelationship" xmlns="DgnContentRelationshipSchema.01.00">
        <RelatedTo>
            <DesignModel instanceID=":EC01:00000000:C:\Users\Sanjivani.Ichake\Downloads\uuu.dgn" xmlns="DgnModelSchema.01.00" />
        </RelatedTo>
    </ModelElementHostedRelationship>
</Element>

Expression:

this.GetRelatedInstance("OnSameElement:0:MstnGraphHeader).GetClass().Name

Where,

 Source Class: Door

 Target Class: MstnGraphHeader

 Relationship Name : OnSameElement

 Direction : 0 - Forward

                                                                                                  

2. Fetch parent element properties through item type relationship

Use case:

Here, we want to fetch Parent element ElementDescription property in attached item type Door. So, here we will find item type instance (e.g. FloorArea) attached on Parent element first through GetItem and then will try to find Parent element instance (e.g. MstnGraphHeader) through relationship (e.g.OnSameElement) and direction of relationship (e.g. 0 - forward).

So, with all above information we can form expression as below:

  

<Element Description="Shape" ElementId="1265">
    <ShapeElement instanceID=":ECDB00000000:15F1040000" xmlns="DgnElementSchema.01.00">
        <Is3dElement>False</Is3dElement>
        <IsGraphicalElement>True</IsGraphicalElement>
        <Level>64</Level>
        <ElementID>1265</ElementID>
        <ModifiedTime>637919230385310000</ModifiedTime>
        <ElementSize>96</ElementSize>
        <Linkages>0</Linkages>
        <XAttributes>2</XAttributes>
        <Color>-1</Color>
        <Weight>-1</Weight>
        <Style>2147483647</Style>
        <ElementClass>0</ElementClass>
        <Transparency>0</Transparency>
        <Priority>0</Priority>
        <Template>-1</Template>
        <Modified>True</Modified>
        <New>True</New>
        <Solid>True</Solid>
        <ViewDependent xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <Snappable>True</Snappable>
        <TAG_RPT_Filled>False</TAG_RPT_Filled>
        <TAG_RPT_Complex>False</TAG_RPT_Complex>
        <LineStyleParams>
            <LSScale>1</LSScale>
            <LSWidthMode>0</LSWidthMode>
            <LSStartWidth xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
            <LSEndWidth xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
            <LSGlobalWidth xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
            <LSTrueWidth xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
            <LSShiftMode>0</LSShiftMode>
            <LSDistancePhase xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
            <LSFractionPhase xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
            <LSCornerMode>0</LSCornerMode>
            <LSThroughCorner>False</LSThroughCorner>
        </LineStyleParams>
        <Thickness xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <GraphicGroup xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <DisplayStyle>-1</DisplayStyle>
        <Locked>False</Locked>
        <MaterialProjectionParameters>
            <Orientation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
            <ProjectionMapping xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
            <Offset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
            <Scale xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
            <ProjectionGroup xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        </MaterialProjectionParameters>
        <RangeLow>994670143,801230855,0</RangeLow>
        <RangeHigh>998776017,803921365,0</RangeHigh>
        <Model3d>False</Model3d>
        <Top>False</Top>
        <Bottom>False</Bottom>
        <Front>False</Front>
        <Back>False</Back>
        <FrontBack>False</FrontBack>
        <Left>False</Left>
        <Right>False</Right>
        <Count>4</Count>
        <TotalLength>13592766.00177002</TotalLength>
        <Area>11046891205371.705</Area>
        <ZDepth>0</ZDepth>
        <EnclosedArea>11046891205371.705</EnclosedArea>
        <Perimeter>13592766.00177002</Perimeter>
        <FrontClipDepth>0</FrontClipDepth>
        <BackClipDepth>0</BackClipDepth>
        <FrontClip>False</FrontClip>
        <BackClip>False</BackClip>
        <HatchSource>2</HatchSource>
        <HatchScale xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <HatchIsAnnotation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <HatchSpace xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <HatchSpace2 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <HatchCross xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <HatchAngle xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <HatchAngle2 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <HatchAssoc xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <HatchOrigin xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <HatchStyle xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <HatchEcsOrigin xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <HatchIsUserDefined xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <HatchColor xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <HatchWeight xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <HatchLineStyle xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <ElementDescription>Shape</ElementDescription>
        <Model>2D Metric Design Model</Model>
        <Links />
        <DwgCustomObjectPropertyList />
        <ElementType>Shape</ElementType>
        <Groups />
        <AttachedMaterial />
        <AssignedMaterial xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <Segments>
            <Segment>
                <Start>994670143.0576812,803921364.23319829,0</Start>
                <End>998776016.87972569,803921364.23319829,0</End>
                <Length>4105873.8220444918</Length>
                <Direction>0</Direction>
                <ElevationAngle>0</ElevationAngle>
                <DeltaX>4105873.8220444918</DeltaX>
                <DeltaY>0</DeltaY>
                <DeltaZ>0</DeltaZ>
                <Delta>-4105873.8220444918,0,0</Delta>
            </Segment>
            <Segment>
                <Start>998776016.87972569,803921364.23319829,0</Start>
                <End>998776016.87972569,801230855.05435777,0</End>
                <Length>2690509.178840518</Length>
                <Direction>-1.5707963267948966</Direction>
                <ElevationAngle>0</ElevationAngle>
                <DeltaX>0</DeltaX>
                <DeltaY>-2690509.178840518</DeltaY>
                <DeltaZ>0</DeltaZ>
                <Delta>0,2690509.178840518,0</Delta>
            </Segment>
            <Segment>
                <Start>998776016.87972569,801230855.05435777,0</Start>
                <End>994670143.0576812,801230855.05435777,0</End>
                <Length>4105873.8220444918</Length>
                <Direction>3.1415926535897931</Direction>
                <ElevationAngle>0</ElevationAngle>
                <DeltaX>-4105873.8220444918</DeltaX>
                <DeltaY>0</DeltaY>
                <DeltaZ>0</DeltaZ>
                <Delta>4105873.8220444918,0,0</Delta>
            </Segment>
            <Segment>
                <Start>994670143.0576812,801230855.05435777,0</Start>
                <End>994670143.0576812,803921364.23319829,0</End>
                <Length>2690509.178840518</Length>
                <Direction>1.5707963267948966</Direction>
                <ElevationAngle>0</ElevationAngle>
                <DeltaX>0</DeltaX>
                <DeltaY>2690509.178840518</DeltaY>
                <DeltaZ>0</DeltaZ>
                <Delta>0,-2690509.178840518,0</Delta>
            </Segment>
        </Segments>
        <Fill>AAD///8=</Fill>
        <HatchName xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <HatchCell xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
    </ShapeElement>
    <OnSameElement Direction="Forward" InstanceId=":ECDB00000000:15F1040000::::56FF00000001:15F1040000:::DgnContentRelationshipSchema.01.00:::OnSameElement" xmlns="DgnContentRelationshipSchema.01.00">
        <RelatedTo>
            <Doors instanceID=":56FF00000001:15F1040000" ElementId="1265" xmlns="DgnCustomItemTypes_Architectural.01.00" />
        </RelatedTo>
    </OnSameElement>
    <OnSameElement Direction="Forward" InstanceId=":ECDB00000000:15F1040000::::56FF00000002:15F1040000:::DgnContentRelationshipSchema.01.00:::OnSameElement" xmlns="DgnContentRelationshipSchema.01.00">
        <RelatedTo>
            <FloorArea instanceID=":56FF00000002:15F1040000" ElementId="1265" xmlns="DgnCustomItemTypes_Architectural.01.00" />
        </RelatedTo>
    </OnSameElement>
    <OnSameElement Direction="Backward" InstanceId=":56FF00000001:15F1040000::::ECDB00000000:15F1040000:::DgnContentRelationshipSchema.01.00:::OnSameElement" xmlns="DgnContentRelationshipSchema.01.00">
        <RelatedTo>
            <Doors instanceID=":56FF00000001:15F1040000" ElementId="1265" xmlns="DgnCustomItemTypes_Architectural.01.00" />
        </RelatedTo>
    </OnSameElement>
    <OnSameElement Direction="Backward" InstanceId=":56FF00000002:15F1040000::::ECDB00000000:15F1040000:::DgnContentRelationshipSchema.01.00:::OnSameElement" xmlns="DgnContentRelationshipSchema.01.00">
        <RelatedTo>
            <FloorArea instanceID=":56FF00000002:15F1040000" ElementId="1265" xmlns="DgnCustomItemTypes_Architectural.01.00" />
        </RelatedTo>
    </OnSameElement>
    <ItemIsAttachedToElement Direction="Backward" InstanceId=":56FF00000001:15F1040000::::ECDB00000000:15F1040000:::DgnContentRelationshipSchema.01.00:::ItemIsAttachedToElement" xmlns="DgnContentRelationshipSchema.01.00">
        <RelatedTo>
            <Doors instanceID=":56FF00000001:15F1040000" ElementId="1265" xmlns="DgnCustomItemTypes_Architectural.01.00" />
        </RelatedTo>
    </ItemIsAttachedToElement>
    <ItemIsAttachedToElement Direction="Backward" InstanceId=":56FF00000002:15F1040000::::ECDB00000000:15F1040000:::DgnContentRelationshipSchema.01.00:::ItemIsAttachedToElement" xmlns="DgnContentRelationshipSchema.01.00">
        <RelatedTo>
            <FloorArea instanceID=":56FF00000002:15F1040000" ElementId="1265" xmlns="DgnCustomItemTypes_Architectural.01.00" />
        </RelatedTo>
    </ItemIsAttachedToElement>
    <ModelElementRelationship Direction="Backward" InstanceId=":EC01:00000000:C:\Users\Sanjivani.Ichake\Downloads\uuu.dgn::::ECDB00000000:15F1040000:::DgnContentRelationshipSchema.01.00:::ModelElementRelationship" xmlns="DgnContentRelationshipSchema.01.00">
        <RelatedTo>
            <DesignModel instanceID=":EC01:00000000:C:\Users\Sanjivani.Ichake\Downloads\uuu.dgn" xmlns="DgnModelSchema.01.00" />
        </RelatedTo>
    </ModelElementRelationship>
    <ModelElementHostedRelationship Direction="Backward" InstanceId=":EC01:00000000:C:\Users\Sanjivani.Ichake\Downloads\uuu.dgn::::ECDB00000000:15F1040000:::DgnContentRelationshipSchema.01.00:::ModelElementHostedRelationship" xmlns="DgnContentRelationshipSchema.01.00">
        <RelatedTo>
            <DesignModel instanceID=":EC01:00000000:C:\Users\Sanjivani.Ichake\Downloads\uuu.dgn" xmlns="DgnModelSchema.01.00" />
        </RelatedTo>
    </ModelElementHostedRelationship>
</Element>
                        

 

Expression:

this.GetItem("DgnCustomItemTypes_Architectural:FloorArea").GetRelatedInstance("OnSameElement:0:MstnGraphHeader").ElementDescription

Where,

 Source Class: FloorArea

 Target Class: MstnGraphHeader

 Relationship Name : OnSameElement

 Direction : 0 - Forward

               

                                   

3. Fetch Parametric Solid Profile properties through relationships.

Use case:

Here, we want to fetch the Profile element's Variation property in attached item type Steel Section. So, here we will find Parametric Solid instance (e.g. SmartFeatureContainer) through GetItem and then will try to find child element instance (e.g. ParametricCellElement) through relationship (e.g.  SmartFeatureToCellParametersRelationship) and direction of relationship (e.g. 1 - backward)

So, with all above information we can form expression as below:

 

<Element Description="Parametric Solid/Surface" ElementId="3727">
    <SmartFeatureContainer instanceID=":ECDB00000000:158F0E0000" xmlns="SmartFeaturesSchema.01.00">
        <NodeId>0</NodeId>
        <Deletable>False</Deletable>
        <DepthId>0</DepthId>
        <MoveToTopValid>False</MoveToTopValid>
        <MoveAboveValid>False</MoveAboveValid>
        <ReorderValid>True</ReorderValid>
        <IsTop>True</IsTop>
        <Enabled xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <Is3dElement>True</Is3dElement>
        <IsGraphicalElement>True</IsGraphicalElement>
        <Level>14</Level>
        <ElementID>3727</ElementID>
        <ModifiedTime>637919196599890000</ModifiedTime>
        <ElementSize>76</ElementSize>
        <Linkages>2</Linkages>
        <XAttributes>7</XAttributes>
        <Color>6</Color>
        <Weight>2</Weight>
        <Style>0</Style>
        <ElementClass>0</ElementClass>
        <Transparency>0</Transparency>
        <Priority xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <Template>-1</Template>
        <Modified>True</Modified>
        <New>True</New>
        <Solid xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <ViewDependent xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <Snappable>True</Snappable>
        <TAG_RPT_Filled>False</TAG_RPT_Filled>
        <TAG_RPT_Complex>False</TAG_RPT_Complex>
        <LineStyleParams>
            <LSScale xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
            <LSWidthMode xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
            <LSStartWidth xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
            <LSEndWidth xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
            <LSGlobalWidth xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
            <LSTrueWidth xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
            <LSShiftMode xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
            <LSDistancePhase xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
            <LSFractionPhase xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
            <LSCornerMode xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
            <LSThroughCorner xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        </LineStyleParams>
        <Thickness xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <GraphicGroup xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <DisplayStyle>-1</DisplayStyle>
        <Locked>False</Locked>
        <MaterialProjectionParameters>
            <Orientation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
            <ProjectionMapping xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
            <Offset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
            <Scale xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
            <ProjectionGroup xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        </MaterialProjectionParameters>
        <RangeLow>228407,-70310,38097</RangeLow>
        <RangeHigh>258408,19691,128098</RangeHigh>
        <Model3d>False</Model3d>
        <Top>False</Top>
        <Bottom>False</Bottom>
        <Front>False</Front>
        <Back>False</Back>
        <FrontBack>False</FrontBack>
        <Left>False</Left>
        <Right>False</Right>
        <Volume>33414809950592.145</Volume>
        <SurfaceArea>26946011365.173874</SurfaceArea>
        <RotationX>0</RotationX>
        <RotationY>0</RotationY>
        <RotationZ>0</RotationZ>
        <RotationAngle>0</RotationAngle>
        <RotationPlane>1</RotationPlane>
        <Status xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
        <IconName>ParametricSolid</IconName>
        <Name>Solid of Extrusion #2</Name>
        <Label>Solid of Extrusion #2</Label>
        <DynamicLabel>Parametric Solid</DynamicLabel>
        <ElementDescription>Parametric Solid/Surface</ElementDescription>
        <Model>3D Metric Design</Model>
        <Links />
        <DwgCustomObjectPropertyList />
        <ElementType>Parametric Solid/Surface</ElementType>
        <Groups />
        <AttachedMaterial />
        <AssignedMaterial xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true" />
    </SmartFeatureContainer>
    <OnSameElement Direction="Forward" InstanceId=":ECDB00000000:158F0E0000::::ECDB00000002:158F0E0000:::DgnContentRelationshipSchema.01.00:::OnSameElement" xmlns="DgnContentRelationshipSchema.01.00">
        <RelatedTo>
            <Extrude instanceID=":ECDB00000002:158F0E0000" ElementId="3727" xmlns="SmartFeaturesSchema.01.00" />
        </RelatedTo>
    </OnSameElement>
    <OnSameElement Direction="Forward" InstanceId=":ECDB00000000:158F0E0000::::ECDB00000001:158F0E0000:::DgnContentRelationshipSchema.01.00:::OnSameElement" xmlns="DgnContentRelationshipSchema.01.00">
        <RelatedTo>
            <SmartFeatureProfile instanceID=":ECDB00000001:158F0E0000" ElementId="3727" xmlns="SmartFeaturesSchema.01.00" />
        </RelatedTo>
    </OnSameElement>
    <OnSameElement Direction="Forward" InstanceId=":ECDB00000000:158F0E0000::::56FF00000001:158F0E0000:::DgnContentRelationshipSchema.01.00:::OnSameElement" xmlns="DgnContentRelationshipSchema.01.00">
        <RelatedTo>
            <Steel__x0020__Section instanceID=":56FF00000001:158F0E0000" ElementId="3727" xmlns="DgnCustomItemTypes_Structural.01.00" />
        </RelatedTo>
    </OnSameElement>
    <OnSameElement Direction="Backward" InstanceId=":ECDB00000002:158F0E0000::::ECDB00000000:158F0E0000:::DgnContentRelationshipSchema.01.00:::OnSameElement" xmlns="DgnContentRelationshipSchema.01.00">
        <RelatedTo>
            <Extrude instanceID=":ECDB00000002:158F0E0000" ElementId="3727" xmlns="SmartFeaturesSchema.01.00" />
        </RelatedTo>
    </OnSameElement>
    <OnSameElement Direction="Backward" InstanceId=":ECDB00000001:158F0E0000::::ECDB00000000:158F0E0000:::DgnContentRelationshipSchema.01.00:::OnSameElement" xmlns="DgnContentRelationshipSchema.01.00">
        <RelatedTo>
            <SmartFeatureProfile instanceID=":ECDB00000001:158F0E0000" ElementId="3727" xmlns="SmartFeaturesSchema.01.00" />
        </RelatedTo>
    </OnSameElement>
    <OnSameElement Direction="Backward" InstanceId=":56FF00000001:158F0E0000::::ECDB00000000:158F0E0000:::DgnContentRelationshipSchema.01.00:::OnSameElement" xmlns="DgnContentRelationshipSchema.01.00">
        <RelatedTo>
            <Steel__x0020__Section instanceID=":56FF00000001:158F0E0000" ElementId="3727" xmlns="DgnCustomItemTypes_Structural.01.00" />
        </RelatedTo>
    </OnSameElement>
    <ItemIsAttachedToElement Direction="Backward" InstanceId=":ECDB00000002:158F0E0000::::ECDB00000000:158F0E0000:::DgnContentRelationshipSchema.01.00:::ItemIsAttachedToElement" xmlns="DgnContentRelationshipSchema.01.00">
        <RelatedTo>
            <Extrude instanceID=":ECDB00000002:158F0E0000" ElementId="3727" xmlns="SmartFeaturesSchema.01.00" />
        </RelatedTo>
    </ItemIsAttachedToElement>
    <ItemIsAttachedToElement Direction="Backward" InstanceId=":ECDB00000001:158F0E0000::::ECDB00000000:158F0E0000:::DgnContentRelationshipSchema.01.00:::ItemIsAttachedToElement" xmlns="DgnContentRelationshipSchema.01.00">
        <RelatedTo>
            <SmartFeatureProfile instanceID=":ECDB00000001:158F0E0000" ElementId="3727" xmlns="SmartFeaturesSchema.01.00" />
        </RelatedTo>
    </ItemIsAttachedToElement>
    <ItemIsAttachedToElement Direction="Backward" InstanceId=":56FF00000001:158F0E0000::::ECDB00000000:158F0E0000:::DgnContentRelationshipSchema.01.00:::ItemIsAttachedToElement" xmlns="DgnContentRelationshipSchema.01.00">
        <RelatedTo>
            <Steel__x0020__Section instanceID=":56FF00000001:158F0E0000" ElementId="3727" xmlns="DgnCustomItemTypes_Structural.01.00" />
        </RelatedTo>
    </ItemIsAttachedToElement>
    <ModelElementRelationship Direction="Backward" InstanceId=":EC01:00000000:C:\Users\Sanjivani.Ichake\Downloads\3463.TestExpression.dgn::::ECDB00000000:158F0E0000:::DgnContentRelationshipSchema.01.00:::ModelElementRelationship" xmlns="DgnContentRelationshipSchema.01.00">
        <RelatedTo>
            <DesignModel instanceID=":EC01:00000000:C:\Users\Sanjivani.Ichake\Downloads\3463.TestExpression.dgn" xmlns="DgnModelSchema.01.00" />
        </RelatedTo>
    </ModelElementRelationship>
    <ModelElementHostedRelationship Direction="Backward" InstanceId=":EC01:00000000:C:\Users\Sanjivani.Ichake\Downloads\3463.TestExpression.dgn::::ECDB00000000:158F0E0000:::DgnContentRelationshipSchema.01.00:::ModelElementHostedRelationship" xmlns="DgnContentRelationshipSchema.01.00">
        <RelatedTo>
            <DesignModel instanceID=":EC01:00000000:C:\Users\Sanjivani.Ichake\Downloads\3463.TestExpression.dgn" xmlns="DgnModelSchema.01.00" />
        </RelatedTo>
    </ModelElementHostedRelationship>
    <LeafElementToSmartFeatureElementRelationship Direction="Backward" InstanceId=":ECDB00000000:158B0E0000::::ECDB00000000:158F0E0000:::SmartFeaturesSchema.01.00:::LeafElementToSmartFeatureElementRelationship" xmlns="SmartFeaturesSchema.01.00">
        <RelatedTo>
            <ParametricCellElement instanceID=":ECDB00000000:158B0E0000" ElementId="3723" xmlns="DgnElementSchema.01.00" />
        </RelatedTo>
    </LeafElementToSmartFeatureElementRelationship>
    <SmartFeatureToCellParametersRelationship Direction="Backward" InstanceId=":ECDB00000000:158B0E0000::::ECDB00000000:158F0E0000:::SmartFeaturesSchema.01.00:::SmartFeatureToCellParametersRelationship" xmlns="SmartFeaturesSchema.01.00">
        <RelatedTo>
            <ParametricCellElement instanceID=":ECDB00000000:158B0E0000" ElementId="3723" xmlns="DgnElementSchema.01.00" />
        </RelatedTo>
    </SmartFeatureToCellParametersRelationship>
</Element>
                                      

Expression:

this.GetItem("SmartFeaturesSchema:SmartFeatureContainer").GetRelatedInstance("SmartFeatureToCellParametersRelationship:1:ParametricCellElement").ParameterSetName 

Where,
 Source Class: SmartFeatureContainer (Parametric Solid)

 Target Class: ParametricCellElement 

 Relationship Name : SmartFeatureToCellParametersRelationship

 Direction : 1 - Backward

Property to fetch:

 

      

Expression and result:                                                                                                                                                                                                                                                                                               

References:

Please refer attached DGN files for above samples.

ItemType example:

Sample.dgn

Parametric Solid example:

ParametricExpression.dgn