Is there Directionality in Revit?

David asked an interesting question in a comment to an earlier post. He wrote:

“The other option I’m curious about is if Revit has the ability to understand direction. Am I able to create a rule that doors are to be numbered from east to west (from north to south let’s say)? There’s obviously a certain amount of coordination that would have to take place in a true project situation. But in terms of concept, I’ve always wondered if we’re able to use directionality…”

There are at least a few different ways to think about what “directionality” means. The simplest is probably to make use of the X / Y / Z coordinate system in Revit.

Here is an example that sorts doors based on their coordinate along the horizontal X axis.

doorSort

public void xDirectionDoorSort()
{
    Document document = this.ActiveUIDocument.Document;
    FilteredElementCollector collector = new FilteredElementCollector(document);
    SortedList<double, ElementId> sortedList = new SortedList<double, ElementId>();
    foreach (FamilyInstance famInst in collector.OfCategory(BuiltInCategory.OST_Doors).OfClass(typeof(FamilyInstance)).Cast<FamilyInstance>().ToList())
    {
        LocationPoint lpoint = famInst.Location as LocationPoint;
        sortedList.Add(lpoint.Point.X, famInst.Id);
    }
    string doorInfo = "";
    foreach (var pair in sortedList)
    {              
        Parameter markParameter = document.GetElement(pair.Value).get_Parameter("Mark");
        doorInfo += markParameter.AsString() + " " + pair.Key + "\n";
    }
    TaskDialog.Show("Doors sorted by X",doorInfo);
}

Here are some highlights of the code:

  1. Since the goal is to sort the doors by their X position, I create a SortedList. The elements in the list will be pairs of information – the X value (which is a double value) and the ElementId of the door.
    The first item in the pair (the X value) is known as the “key”. The second item (the ElementId) is known as the “value”.
    The pairs in the list will be automatically sorted by their keys (the X value).

  2. When the collector is used to get the list of doors, I added a ” Cast<FamilyInstance>()” so to make it a list of FamilyInstances. Without this the cast would have to be done on a separate line inside that foreach loop.

  3. In a previous post, I mentioned that wall.Location was a LocationCurve. For the doors the Location is a LocationPoint and it has a Point property that is an XYZ point.
  4. In the 2nd foreach loop, we get the parameter of the door’s Mark, and then build a string with the Mark Value and X coordinate for each door.
Advertisements

One thought on “Is there Directionality in Revit?

  1. my question on weither revit could do it was probably not the best way to ask it. rather, it should have been how. revit can probably do just about anything I can think of. the complexity to achieve the task is probably the bigger thing.

    the approach, using coordinates seems so obvious to me now. ha! how to achieve it i wouldn’t have known. don’t have a computer in front of me so will have to wait to run the code. looks good! thanks!

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