<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Having trouble filtering to OST_TitleBlocks in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/having-trouble-filtering-to-ost-titleblocks/m-p/6827531#M60781</link>
    <description>&lt;P&gt;Dear Charlie,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You say "they have only been loaded in".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does that mean that they live in linked project files?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In that case, you have to run your filtered element collectors in the&amp;nbsp;&lt;SPAN&gt;linked documents, one for each one, not the main project document.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Jeremy&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 24 Jan 2017 15:54:29 GMT</pubDate>
    <dc:creator>jeremytammik</dc:creator>
    <dc:date>2017-01-24T15:54:29Z</dc:date>
    <item>
      <title>Having trouble filtering to OST_TitleBlocks</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/having-trouble-filtering-to-ost-titleblocks/m-p/6826884#M60780</link>
      <description>&lt;P&gt;I'm trying to build a FilteredElementCollector that will filter down to a number of TitleBlocks we have preloaded into a project. To be clear there are no instances of these elements within the project, they have only been loaded in.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;[Transaction(TransactionMode.Manual)]
    [Regeneration(RegenerationOption.Manual)]
    public class Snoop : IExternalCommand
    {
        public Result Execute(ExternalCommandData commandData,
            ref string message, ElementSet elements)
        {
            Document doc = commandData.Application.ActiveUIDocument.Document;
            UIDocument uidoc = commandData.Application.ActiveUIDocument;

            FilteredElementCollector collector = new FilteredElementCollector(doc);
            ICollection&amp;lt;Element&amp;gt; titleFrames = collector
                .OfCategory(BuiltInCategory.OST_TitleBlocks)
                .OfClass(typeof(Family))
                .ToElements();

            StringBuilder textMessage = new StringBuilder("Available titleframes: ");

            if (titleFrames.Count == 0)
                textMessage.AppendLine("Contains no titleframes.");
            else
            {
                foreach (Family titleFrame in titleFrames)
                {
                    textMessage.AppendLine("\nName: " + titleFrame.Name);
                }
            }

            File.WriteAllText(@"C:\Users\user\Documents\Test.txt", textMessage.ToString());
            TaskDialog.Show("Revit","Complete");
            return Result.Succeeded;
        }
    }&lt;/PRE&gt;&lt;P&gt;From this code block I recieve the following:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Available titleframes: Contains no titleframes.&lt;/PRE&gt;&lt;P&gt;I am 100% sure the TitleBlocks are loaded&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Am I missing a call?&lt;/P&gt;&lt;P&gt;Or do I need to use a different method to find these elements?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is appreciated.&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Charlie&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2017 12:35:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/having-trouble-filtering-to-ost-titleblocks/m-p/6826884#M60780</guid>
      <dc:creator>Charles.Stokes</dc:creator>
      <dc:date>2017-01-24T12:35:57Z</dc:date>
    </item>
    <item>
      <title>Re: Having trouble filtering to OST_TitleBlocks</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/having-trouble-filtering-to-ost-titleblocks/m-p/6827531#M60781</link>
      <description>&lt;P&gt;Dear Charlie,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You say "they have only been loaded in".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does that mean that they live in linked project files?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In that case, you have to run your filtered element collectors in the&amp;nbsp;&lt;SPAN&gt;linked documents, one for each one, not the main project document.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Jeremy&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2017 15:54:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/having-trouble-filtering-to-ost-titleblocks/m-p/6827531#M60781</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2017-01-24T15:54:29Z</dc:date>
    </item>
    <item>
      <title>Re: Having trouble filtering to OST_TitleBlocks</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/having-trouble-filtering-to-ost-titleblocks/m-p/6827555#M60782</link>
      <description>&lt;P&gt;Sorry thats not it.&lt;/P&gt;&lt;P&gt;What I meant was they have been loaded into the project file from a library but no instances of those families have been created in the project itself.&lt;/P&gt;&lt;P&gt;If that makes sense.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2017 15:59:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/having-trouble-filtering-to-ost-titleblocks/m-p/6827555#M60782</guid>
      <dc:creator>Charles.Stokes</dc:creator>
      <dc:date>2017-01-24T15:59:31Z</dc:date>
    </item>
    <item>
      <title>Re: Having trouble filtering to OST_TitleBlocks</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/having-trouble-filtering-to-ost-titleblocks/m-p/6827759#M60783</link>
      <description>&lt;P&gt;Hi &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/3765758"&gt;@Charles.Stokes&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;This one stumped me once upon a time, and I've just re-learnt the answer (with the help of RevitLookup).&lt;/P&gt;
&lt;P&gt;If you snoop a titleblock family, you will see that the category is &amp;lt;null&amp;gt;.&lt;/P&gt;
&lt;P&gt;The *FamilyCategory* is OST_Titleblocks.&lt;/P&gt;
&lt;P&gt;Crudely (using VB.NET), this can be achieved by:&lt;/P&gt;
&lt;PRE&gt;       Dim titleFrames As List(Of DB.Family) = _&lt;BR /&gt;		collector.OfClass(GetType(DB.Family)) _&lt;BR /&gt;		.Cast(Of DB.Family) _&lt;BR /&gt;		.Where(Function(fam) fam.FamilyCategoryId.IntegerValue = CInt(DB.BuiltInCategory.OST_TitleBlocks)).ToList
&lt;/PRE&gt;
&lt;P&gt;I am sure more efficient ways exist, but I'll leave that investigation to you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;-Matt&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;[edit]&lt;/P&gt;
&lt;P&gt;Make sure you import and reference System.LINQ.&lt;/P&gt;
&lt;P&gt;[/edit]&lt;/P&gt;</description>
      <pubDate>Tue, 24 Jan 2017 16:50:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/having-trouble-filtering-to-ost-titleblocks/m-p/6827759#M60783</guid>
      <dc:creator>matthew_taylor</dc:creator>
      <dc:date>2017-01-24T16:50:33Z</dc:date>
    </item>
    <item>
      <title>Re: Having trouble filtering to OST_TitleBlocks</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/having-trouble-filtering-to-ost-titleblocks/m-p/6829574#M60784</link>
      <description>&lt;P&gt;Thanks alot&lt;/P&gt;&lt;P&gt;yeah I saw that in snoop but thought it was some kind of glitch or I was doing something wrong&lt;/P&gt;&lt;P&gt;nice to know it isn't just me.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;&lt;P&gt;Charlie&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jan 2017 10:00:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/having-trouble-filtering-to-ost-titleblocks/m-p/6829574#M60784</guid>
      <dc:creator>Charles.Stokes</dc:creator>
      <dc:date>2017-01-25T10:00:44Z</dc:date>
    </item>
    <item>
      <title>Re: Having trouble filtering to OST_TitleBlocks</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/having-trouble-filtering-to-ost-titleblocks/m-p/6829581#M60785</link>
      <description>&lt;P&gt;Thank you for spotting that, Matt.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Another example of this age-old 'feature':&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://thebuildingcoder.typepad.com/blog/2015/09/change-type-iterate-elements-create-family.html#2" target="_blank"&gt;http://thebuildingcoder.typepad.com/blog/2015/09/change-type-iterate-elements-create-family.html#2&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note that the &lt;CODE&gt;Category&lt;/CODE&gt; property is not always implemented on families, so you may have to use &lt;CODE&gt;FamilyCategory&lt;/CODE&gt; instead, or the category of the family's first symbol.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeremy&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jan 2017 10:04:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/having-trouble-filtering-to-ost-titleblocks/m-p/6829581#M60785</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2017-01-25T10:04:40Z</dc:date>
    </item>
    <item>
      <title>Re: Having trouble filtering to OST_TitleBlocks</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/having-trouble-filtering-to-ost-titleblocks/m-p/6832589#M60786</link>
      <description>&lt;P&gt;I summarised this rather fundamental 'feature' of families on The Building Coder for future reference:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://thebuildingcoder.typepad.com/blog/2017/01/family-category-and-two-energy-model-types.html#2" target="_blank"&gt;http://thebuildingcoder.typepad.com/blog/2017/01/family-category-and-two-energy-model-types.html#2&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeremy&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2017 11:10:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/having-trouble-filtering-to-ost-titleblocks/m-p/6832589#M60786</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2017-01-26T11:10:32Z</dc:date>
    </item>
  </channel>
</rss>

