# Thinking of directionality as distance along a wall

Getting back to the question of directionality and door numbering, what you might want to do is go from one end of a wall to the other end, incrementing the door numbers as you go. To do this you need to find:

1. The XYZ coordinates of one of the wall’s endpoints
2. The doors in the wall (as described in the previous post)
3. The location point of each door
4. The distance between the door point and the wall end point

This data could then be sorted to use in a door numbering routine.

``````public void FindDoorsInWall()
{
Document doc = this.ActiveUIDocument.Document;
UIDocument uidoc = new UIDocument(doc);
Wall wall = doc.GetElement(uidoc.Selection.PickObject(ObjectType.Element)) as Wall;

// Find the XYZ coordinates of one of the wall's endpoints
LocationCurve locCurve = wall.Location as LocationCurve;
Curve curve = locCurve.Curve;
XYZ wallEnd = curve.get_EndPoint(0);

string doorDistanceInfo = "";

// check each door in the wall
// the logic to find the doors has been moved to its own function
foreach (FamilyInstance door in doorsInWall(wall))
{
// find the XYZ point of the door
LocationPoint doorLocationPoint = door.Location as LocationPoint;
XYZ doorPoint = doorLocationPoint.Point;

// find the distance from the door to the end of the wall
double distance = doorPoint.DistanceTo(wallEnd);
doorDistanceInfo += door.Symbol.Family.Name + " - " + door.Name + " = " + distance + "\n";
}