Great inspiration to use Revit’s API…

Originally posted on Boost Your BIM:

Writing about the Copy/Monitor UI, Steve mentions that “It would be cool if Revit identified the elements and types that are actually in use in the linked file”

The Revit API can’t modify the Copy/Monitor UI, but the API can be used to identify the elements and types that are actually in use in the linked file.


publicvoid levelTypesInLink()
    Document doc = this.ActiveUIDocument.Document;
    foreach (RevitLinkType linkType innew FilteredElementCollector(doc).OfClass(typeof(RevitLinkType)).Cast<RevitLinkType>())
        string usedLevelTypes = "";
        string notUsedLevelTypes = "";
        Document linkDoc = getLinkDoc(doc, linkType);
        foreach (LevelType levelType innew FilteredElementCollector(linkDoc).OfClass(typeof(LevelType)).Cast<LevelType>())
            if (new FilteredElementCollector(linkDoc).OfClass(typeof(Level)).Cast<Level>().Where(level => level.LevelType.Id == levelType.Id).Count() > 0)
                usedLevelTypes += levelType.Name + ", ";
                notUsedLevelTypes += levelType.Name + ", ";
        TaskDialog.Show("Level Types in " + linkDoc.Title,
                        "Used\n------\n" + usedLevelTypes + 
                        "\n\nNot Used\n---------\n" + notUsedLevelTypes);

private Document getLinkDoc(Document doc, RevitLinkType linkType)

View original 16 more words

About these ads

Leave a Reply

Please log in using one of these methods to post your comment: Logo

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