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.

door distances in wall

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";
    }
    TaskDialog.Show("door distances in wall", doorDistanceInfo);
}
Advertisements

2 thoughts on “Thinking of directionality as distance along a wall

  1. How about windows? If I know the wall end (XYZ) and window’s locationPoint (XYZ), how can I work out the in-plane offset between these two point? namely, delta X and delta Y if it is a 2D problem?

    • How about finding the distance between the wall’s location curve and an XYZ point created with the X & Y of the window’s location point and the Z of the wall’s location curve?

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s