Wednesday, January 29, 2014

BIM Consortium Revit Add-in First Release

I have been working with the Los Angeles Revit Users Group leadership group (known as the BIM Consortium) to start creating a set of Revit add-ins based on meeting discussions. I'm happy to announce the first release of the add-in.

Download: https://drive.google.com/file/d/0B16E2YBKmeUtbmZsNDFIUmJHMm8/edit

Instructions for installation are inside the zip file.


This initial release comes with 3 tools...




3D Grid Generator
This tool is based on the 3D Grid family created by Jay Zallan. Jay demoed the family during a meeting that I happened to also be discussing macros. I challenged myself to take Jay's family and create a macro that would automatically place a 3D Grid family on every grid line in the model. After several iterations, I converted the macro to an add-in and here it is.

The tool is very simple. First load the 3D Grids family included with the add-in into your Revit model. Then start the tool and choose the levels that you would like to have 3D grids on. Then you can use Jay's original guide on how to use the 3D grids. Quick video demo can be found here: https://www.youtube.com/watch?v=-wSnc9-j2O8



** The first release does have a limitation that I am working on fixing and will release in a future update. It currently won't recognize that a 3D grid already exists when creating them. So if you run the tool twice on the same level you will end up with two families in the same place and Revit will let you know. If you want to place new copies if your grid changes, for now you will need to delete the existing 3D grids before you create new ones.


Create Dependent Views
This tool is very simple and came as a request. It will simply duplicate as dependent the active view 5 times. Saves you 5 right-clicks.

** I have already received a request to add a dialog that allows you to pick your own number. It will be in a future update.


Delete Views
This tool was the original reason I wanted to learn how to create macros in Revit. As an MEP firm I work with a lot of models from other companies. In order to keep the numerous linked models manageable, I clean the models by deleting views, legends, schedules, and sheets. I used to do this by hand by deleting them from the project browser. Now I can run this tool and get it done quickly.

Word of caution, this will DELETE views and sheets from your currently active model. Be careful using the tool (I take no responsibility for your usage :-) ).

To use the tool, start from a view you want to keep (Revit requires at least 1 view in a model). Run the tool and choose the option that best suits your model usage.


  • Delete All Non-Plan Views – this option will delete all views except floor and ceiling plans. This is best for consultant models that you will be using linked views.
  • Delete All Views – this option will delete all views in a model except the currently active one.
  • Delete All Except Containing – this option will delete all views except ones containing the word you type in. This is best for prearranged view names for linked models. IE: another company has created views with consultant in the name. Type consultant into the box to delete all but the consultant views.
  • Delete Sheets Too – this option will also delete all the sheets in addition to the options chosen above.

Macro to change all families to the same LEADER ARROWHEAD style

I had a request to write a macro that would change all families' Leader Arrowhead style to the same type in a project.



This is the code I came up with:


public void UpdateLeaders()
        {
            UIDocument uidoc = this.ActiveUIDocument;
            Document doc = uidoc.Document;
            
            // create a collection of all the Arrowhead types
            ElementId id = new ElementId(BuiltInParameter.ALL_MODEL_FAMILY_NAME);
            ParameterValueProvider provider = new ParameterValueProvider(id);
            FilterStringRuleEvaluator evaluator = new FilterStringEquals();
            FilterRule rule = new FilterStringRule(provider, evaluator, "Arrowhead", false);
            ElementParameterFilter filter = new ElementParameterFilter(rule); 
            FilteredElementCollector collector2 = new FilteredElementCollector(doc).OfClass(typeof(ElementType)).WherePasses(filter);
            
            ElementId arrowheadId = null;
              
            // loop through the collection of Arrowhead types and get the Id of a specific one
            foreach(ElementId eid in collector2.ToElementIds())
            {
                if(doc.GetElement(eid).Name == "Arrow Filled 30 Degree") //change the name to the arrowhead type you want to use
                {
                    arrowheadId = eid;
                }
            }
            
            // create a collection of all families
            List<Family> families = new List<Family>(new FilteredElementCollector(doc).OfClass(typeof(Family)).Cast<Family>());
            using(Transaction t = new Transaction(doc, "Update Leaders"))
            {
                t.Start();        
                // loop through all families and get their types       
                foreach(Family f in families)
                {
                    FamilySymbolSet symbols = f.Symbols;
                    List<FamilySymbol> symbols2 = new List<FamilySymbol>(symbols.Cast<FamilySymbol>());
                 
                     // loop through the family types and try switching the parameter Leader Arrowhead to the one chosen above
                     // if the type doesn't have this parameter it will skip to the next family type
                    foreach(FamilySymbol fs in symbols2)
                    {
                        try
                         {
                             fs.get_Parameter(BuiltInParameter.LEADER_ARROWHEAD).Set(arrowheadId);
                         }
                         catch
                         {
                             
                         }
                     }
                }
                t.Commit();
            }
        }