Application: FindColumns
Revit Platform: All
Revit Version: 2011.0
First Released For: 2011.0
Programming Language: C#
Skill Level: Advanced
Category: Geometry
Type: ExternalCommand

Subject: Columns Embedded in Walls
Summary: 
This sample shows how to find columns that are embedded in walls with the Revit API method FindReferencesWithContextByDirection.

Classes: 
Autodesk.Revit.DB.FilteredElementCollector
Autodesk.Revit.DB.FilteredElementIterator
Autodesk.Revit.DB.Transform
Autodesk.Revit.DB.XYZ
Autodesk.Revit.DB.Document
Autodesk.Revit.UI.Selection.Selection

Project Files: 
FindColumns.cs

Description: 
1.	Determine which walls to process (either the selected walls, or all walls if none are selected)
2.	Find columns embedded in each wall
a.	For linear walls
i.	Set the height for the ray at 1’ above the wall’s level
ii.	Find the direction tangent to the wall’s location curve
iii.	Because the wall’s LocationCurve is always the wall centerline, use the wall’s width to determine the offset needed for FindReferencesWithContextByDirection to shoot its “ray” just outside of the wall
iv.	Find references of objects returned by FindReferencesWithContextByDirection when running from one end of the wall to the other end of the wall
v.	Check each reference to validate that it is a column within the allowable distance from the origin used with FindReferencesWithContextByDirection (don’t want columns past the end of the wall)
b.	For non-linear walls
i.	Unlike linear walls, where a single ray can be to check for intersections along the entire length of the wall, a non-linear wall must be divided into series of smaller pieces to approximate the wall as a set of shorter straight segments.
ii.	Calculate an increment that will be used for the length of these short segments
iii.	Check for columns along every incremental piece of the wall using the methodology described above for linear walls.
c.	Select the resulting columns

Instructions:
1.	Open the file FindColumns-Basic.rvt or FindColumns-TestCases.rvt
2.	Run the external command “Find Columns Embedded in Walls”
3.	If one or more walls are selected before running the command, Revit will select the columns embedded in the selected walls.
4.	If no walls are selected before running the command, Revit will select all columns that are embedded in a wall.