8 01 2013

caddguru:

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.

levelTypes

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 + ", ";
            else
                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)
{
    foreach

View original 16 more words

About these ads

Actions

Information

Leave a Reply

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

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




Follow

Get every new post delivered to your Inbox.

Join 30 other followers

%d bloggers like this: