<?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 Deleting Lines that are not assigned to the &amp;lt;Room Separation&amp;gt; subcategory in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/deleting-lines-that-are-not-assigned-to-the-lt-room-separation/m-p/8765491#M42690</link>
    <description>&lt;P&gt;I have code that deletes all lines in the document. I only want to delete the lines that are not on the &amp;lt;Room Separation&amp;gt; subcategory. I probably need to add something to my FilteredElementCollector but I can't figure out what. Thanks in advance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;                    //Lines
                    var linIds = new FilteredElementCollector(doc, vw.Id)
                        .OfClass(typeof(CurveElement))
                        .ToElementIds();
                    foreach (var lin_id in linIds)
                    {
                        doc.Delete(lin_id);
                        linCount++;
                    }&lt;/PRE&gt;</description>
    <pubDate>Wed, 01 May 2019 20:26:59 GMT</pubDate>
    <dc:creator>62BJW</dc:creator>
    <dc:date>2019-05-01T20:26:59Z</dc:date>
    <item>
      <title>Deleting Lines that are not assigned to the &lt;Room Separation&gt; subcategory</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/deleting-lines-that-are-not-assigned-to-the-lt-room-separation/m-p/8765491#M42690</link>
      <description>&lt;P&gt;I have code that deletes all lines in the document. I only want to delete the lines that are not on the &amp;lt;Room Separation&amp;gt; subcategory. I probably need to add something to my FilteredElementCollector but I can't figure out what. Thanks in advance.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;                    //Lines
                    var linIds = new FilteredElementCollector(doc, vw.Id)
                        .OfClass(typeof(CurveElement))
                        .ToElementIds();
                    foreach (var lin_id in linIds)
                    {
                        doc.Delete(lin_id);
                        linCount++;
                    }&lt;/PRE&gt;</description>
      <pubDate>Wed, 01 May 2019 20:26:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/deleting-lines-that-are-not-assigned-to-the-lt-room-separation/m-p/8765491#M42690</guid>
      <dc:creator>62BJW</dc:creator>
      <dc:date>2019-05-01T20:26:59Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting Lines that are not assigned to the &lt;Room Separation&gt; subcateg</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/deleting-lines-that-are-not-assigned-to-the-lt-room-separation/m-p/8765666#M42691</link>
      <description>&lt;P&gt;You can use LINQ to query the elements. With LINQ, you can check element's category.&lt;/P&gt;
&lt;P&gt;Here is the code snippet.&lt;/P&gt;
&lt;PRE&gt;// This filtered element collector collects all elements in the document except room seperation lines
var lines = new FilteredElementCollector(doc).OfClass(typeof(CurveElement)).Cast&amp;lt;CurveElement&amp;gt;()
        .Where(q =&amp;gt; q.Category.Id != new ElementId(BuiltInCategory.OST_RoomSeparationLines)).ToList();

foreach (var line in lines)
{
     doc.Delete(line.Id);
}&lt;/PRE&gt;
&lt;P&gt;I hope this helps,&lt;/P&gt;
&lt;P&gt;Recep.&lt;/P&gt;</description>
      <pubDate>Wed, 01 May 2019 22:38:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/deleting-lines-that-are-not-assigned-to-the-lt-room-separation/m-p/8765666#M42691</guid>
      <dc:creator>recepagah12</dc:creator>
      <dc:date>2019-05-01T22:38:00Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting Lines that are not assigned to the &lt;Room Separation&gt; subcateg</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/deleting-lines-that-are-not-assigned-to-the-lt-room-separation/m-p/8766082#M42692</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Dear Bernie,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thank you for your query, and many thanks to Recep for his valuable help.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;His suggestion can be improved upon.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Calling ToList at the end is a waste of time and space.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;It requests a (totally unnecessary) copy of all the results from the filtered element collector.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You can iterate over the collector itself directly.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Furthermore, a built-in Revit filter will always be faster than LINQ post-processing.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;In this case, you can use a negated ElementCategoryFilter:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://apidocs.co/apps/revit/2019/6b8f4e3a-1975-7388-3848-462cf305d523.htm" target="_blank"&gt;https://apidocs.co/apps/revit/2019/6b8f4e3a-1975-7388-3848-462cf305d523.htm&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Yet further, you might gain some additional performance by deleting all the elements in one single call rather than by stepping through them one by one.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;For instance, like this:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;PRE&gt;  /// &amp;lt;summary&amp;gt;
  /// Delete all non-room-separating curve elements
  /// &amp;lt;/summary&amp;gt;
  void DeleteNonRoomSeparators( Document doc )
  {
    ElementCategoryFilter non_room_separator 
      = new ElementCategoryFilter( 
        BuiltInCategory.OST_RoomSeparationLines, 
        true );

    FilteredElementCollector a
      = new FilteredElementCollector( doc )
        .OfClass( typeof( CurveElement ) )
        .WherePasses( non_room_separator );

    doc.Delete( a.ToElementIds() );
  }&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I added this method to The Building Coder samples for you:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://github.com/jeremytammik/the_building_coder_samples/compare/2020.0.145.2...2020.0.145.3" target="_blank"&gt;https://github.com/jeremytammik/the_building_coder_samples/compare/2020.0.145.2...2020.0.145.3&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I hope this helps.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Best regards,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Jeremy&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 02 May 2019 06:55:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/deleting-lines-that-are-not-assigned-to-the-lt-room-separation/m-p/8766082#M42692</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2019-05-02T06:55:49Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting Lines that are not assigned to the &lt;Room Separation&gt; subcateg</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/deleting-lines-that-are-not-assigned-to-the-lt-room-separation/m-p/8766267#M42693</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/413917"&gt;@jeremytammik&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you very much for your valuable suggestion.&lt;/P&gt;
&lt;P&gt;Also many thanks to pointing out the wrong side of my code.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your solution is much elegant and faster.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you again,&lt;/P&gt;
&lt;P&gt;Recep.&lt;/P&gt;</description>
      <pubDate>Thu, 02 May 2019 08:43:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/deleting-lines-that-are-not-assigned-to-the-lt-room-separation/m-p/8766267#M42693</guid>
      <dc:creator>recepagah12</dc:creator>
      <dc:date>2019-05-02T08:43:31Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting Lines that are not assigned to the &lt;Room Separation&gt; subcateg</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/deleting-lines-that-are-not-assigned-to-the-lt-room-separation/m-p/8766398#M42694</link>
      <description>&lt;P&gt;Edited and cleaned up here:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://thebuildingcoder.typepad.com/blog/2019/05/location-point-and-filtering-hints.html#4" target="_blank"&gt;https://thebuildingcoder.typepad.com/blog/2019/05/location-point-and-filtering-hints.html#4&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 02 May 2019 10:07:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/deleting-lines-that-are-not-assigned-to-the-lt-room-separation/m-p/8766398#M42694</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2019-05-02T10:07:00Z</dc:date>
    </item>
  </channel>
</rss>

