Thursday, June 05, 2014

View Schedule with Detail Numbers Macro for Revit

A question was posted on about showing a view's detail number in a view list schedule. Revit has a parameter for the Detail Number (see first image) but it isn't accessible to add in a view list schedule.

Original post:


Step 1
Create a View List schedule (or edit an existing one) and add a new text Parameter named "Detail_Number" (notice the _ in the name)

Step 2
Create a new macro with the following routine and run it

public void DetailNumber()
    UIDocument uidoc = this.ActiveUIDocument;
    Document doc = uidoc.Document;
    string strDetailNumber = "Detail_Number";         
    FilteredElementCollector collector = new FilteredElementCollector(doc);
    ICollection<Element> collection = collector.OfClass(typeof(View)).ToElements();
    using (Transaction t = new Transaction(doc, "Detail Number"))
        foreach(Element e in collection)
            View v = e as View;
                Parameter bpDetailNumber = v.get_Parameter(BuiltInParameter.VIEWPORT_DETAIL_NUMBER);

All the views that are on sheets now have the Detail Number copied into the Detail_Number parameter.

Run the macro whenever you want to update the values in the new parameter to reflect the current state of the project (aka is doesn't auto update and needs to be run manually).


  1. Could this also work to link door schedules to door details that have been placed on sheets?

    Adding a parameter to the door families that will allow a detail drawings to fill in a head, jamb, sill detail section of the door schedule with the drawings (detail) number and sheet when that detail view is placed on a sheet?

  2. Hi. I am interested in your Macro that does this automatically

  3. Thank for sharing :D

  4. Thank you for making this, I am new to macros, so this may be a stupid question:
    I am getting an error
    'DetailNumber.ThisDocument' does not contain a definition for 'ActiveUIDocument' and no extens:ion method 'ActiveUIDocument' accepting a first argument of type 'DetailNumber.ThisDocument' could be found (are you missing a using directive or an assembly referen

  5. Taylor, yes definitely. You can get the detail number as shown and fill it into a parameter in the door schedule. You would need some type of verification to ensure you are putting the correct detail in the matching door.

  6. Hi Troy, thanks for sharing this macro! Would you be able to edit the post for a step-by-step process on making a macro? I am not sure what to add/delete/amend in the macro/C# interface.

  7. Getting these two errors:

    Argument 1: cannot convert from 'string' to "Autodesk.Revit.DB.BuiltInParameter' (CS1503)
    The best overloaded method match for 'Autodesk.Revit.DB.Element.get_Parameter' has some invalid argument (CS1502)

    Any idea why?