Find that labeled dimension

Have you ever gotten lost while searching and searching in a complex family for a labeled dimension? You know there is a dimension somewhere labeled “Jamb Width” or “Head Height” or whatever but you don’t know in what view that dimension lives?

Here is a macro that will find a dimension based on the name of its labeled parameter, open the dimension’s view, select the dimension and zoom to it.


Where is Jamb Width?

dim 2

Found it!

public void findLabelView()
    Document doc = this.ActiveUIDocument.Document;
    UIDocument uidoc = this.ActiveUIDocument;
    foreach (Dimension dim in new FilteredElementCollector(doc)
        FamilyParameter fp = null;
            fp = dim.FamilyLabel;
        if (fp != null && fp.Definition.Name == "Jamb Width")
            uidoc.Selection.SetElementIds(new List<ElementId> { dim.Id});
            View ownerview = doc.GetElement(dim.OwnerViewId) as View;
            uidoc.ActiveView = ownerview;
            UIView uiview = uidoc.GetOpenUIViews().FirstOrDefault(q => q.ViewId == dim.OwnerViewId);
            BoundingBoxXYZ bbox = dim.get_BoundingBox(ownerview);
            uiview.ZoomAndCenterRectangle(bbox.Min, bbox.Max);


4 thoughts on “Find that labeled dimension

  1. Hi boostyourbim!
    Thank you for creating this post. I am trying to use your sample code to create a plugin that finds any label which is input in a TextBox in a Windows Form to then use it in the class that contains findLabelView().
    Do you think this is a good approach? How would you do it?

    • Sounds good Rita! It is good practice to separate the UI and the functions that do the work with the Revit data. So findLabelView() could be rewritten as findLabelView(string ParameterName) and then this is called after the user has closed the Windows Form.

      This topic is covered in Lecture 18 “Creating Windows Forms for User Input” in my Revit API video course –

      • Thank you Harry. I have successfully managed to extend the plugin to pop up a form and write down the label. However, I noticed that when the labels are hosted inside an edit mode (e.g. extrusion), the plugin will throw an exception.
        I have created a thread on this topic here, which better explains the issue.

Leave a Reply

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

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

Google photo

You are commenting using your Google 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 )

Connecting to %s