<VB.NET>
'' add a
door to the center of the given wall.
Sub AddDoor(ByVal hostWall As Wall)
'' get the
door type to use.
Dim doorType As FamilySymbol = _
ElementFiltering.FindFamilyType(m_rvtDoc, GetType(FamilySymbol), _
"片開", "w900h2000",
BuiltInCategory.OST_Doors)
'' get the
start and end points of the wall.
Dim locCurve As LocationCurve = hostWall.Location
Dim pt1 As XYZ = locCurve.Curve.EndPoint(0)
Dim pt2 As XYZ = locCurve.Curve.EndPoint(1)
'' calculate
the mid point.
Dim pt As XYZ = (pt1 + pt2) / 2.0
'' we want
to set the reference as a bottom of the wall or level1.
Dim idLevel1 As ElementId = _
hostWall.Parameter(BuiltInParameter.WALL_BASE_CONSTRAINT).AsElementId
Dim level1 As Level = m_rvtDoc.Element(idLevel1)
'' finally,
create a door.
Dim aDoor As FamilyInstance = m_rvtDoc.Create.NewFamilyInstance( _
pt, doorType, hostWall, level1,
StructuralType.NonStructural)
End Sub
</VB.NET>