<?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: Selection Limitation by Category in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/selection-limitation-by-category/m-p/5797226#M70764</link>
    <description>&lt;P&gt;Dear Mr.&amp;nbsp;&lt;SPAN&gt;Jeremy,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thank you for spending time on providing me such useful information and detail instruction.&lt;/P&gt;&lt;P&gt;Your site (The Building Coder) covers plenty of such information which is out of my knowledge frame since I am not from programing discipline. I believe I will&amp;nbsp;find much information for my coming questions from there.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Regarding&amp;nbsp;my question, I finally found a suitable answer (of course from your information) for the second step. Although I am not sure this is the best and&amp;nbsp;the only answer but anyway now the command works smoothly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheer!&lt;/P&gt;&lt;P&gt;Sincerely&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;The answer found:&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;// Set the selected element set as current select element set
                ICollection&amp;lt;ElementId&amp;gt; wallIds = sel.GetElementIds();
                foreach (Reference r in refWalls)
                {
                    Element e = doc.GetElement(r);
                    wallIds.Add(e.Id);
                }
                UIDoc.Selection.SetElementIds(wallIds);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 01 Sep 2015 09:56:43 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2015-09-01T09:56:43Z</dc:date>
    <item>
      <title>Selection Limitation by Category</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/selection-limitation-by-category/m-p/5794722#M70762</link>
      <description>&lt;P&gt;Hi Revit API community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am a newbie in Revit API and on my way to create a simple command which can “limit user selection by category” with the code snippet shown below.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My purpose:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;While the command is active: only wall category is selectable&lt;/LI&gt;&lt;LI&gt;After command is ended: the selected elements become current select element set&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Step 1 is now working fine since only wall category is selectable while the command is active (refer to&amp;nbsp;the attached screenshot for detail)&lt;/P&gt;&lt;P&gt;Please show me how to continue with step 2 to set selected reference as current select element set after ending the command.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be appreciated&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Code snippet:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;namespace CategorySelector
{
    [Autodesk.Revit.Attributes.Transaction(Autodesk.Revit.Attributes.TransactionMode.Manual)]
    public class Command : IExternalCommand
    {
        public Autodesk.Revit.UI.Result Execute(ExternalCommandData commandData, ref string message, ElementSet element)
        {
            UIApplication uiApp = commandData.Application;
            Document doc = uiApp.ActiveUIDocument.Document;
            Selection sel = uiApp.ActiveUIDocument.Selection;

            // Limit element selection =&amp;gt; works fine
            ISelectionFilter selFilter = new wallSelectionFilter(doc);
            IList&amp;lt;Reference&amp;gt; refWalls = sel.PickObjects(ObjectType.Element, selFilter, "Please select wall");

            &lt;FONT color="#FF0000"&gt;// How to convert selected reference list to elements?
            // How to set converted elements as current select element set?&lt;/FONT&gt;
            
            return Autodesk.Revit.UI.Result.Succeeded;
        }
      
        public class wallSelectionFilter : ISelectionFilter
        {
            Document doc = null;
            public wallSelectionFilter(Document document)
            {
                doc = document;
            }
                        
            public bool AllowElement(Element element)
            {
                return (element.Category.Id.IntegerValue.Equals((int)BuiltInCategory.OST_Walls));
            }
            public bool AllowReference(Reference refer, XYZ point)
            {
                return false;
            }
        }
    }
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 30 Aug 2015 06:27:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/selection-limitation-by-category/m-p/5794722#M70762</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-08-30T06:27:06Z</dc:date>
    </item>
    <item>
      <title>Re: Selection Limitation by Category</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/selection-limitation-by-category/m-p/5795584#M70763</link>
      <description>&lt;P&gt;Dear Mr. Hoa,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Congratulations on solving the first part of your task.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you are new to the Revit API, make sure you have worked through and understood the basics before going any further, e.g. by studying the hand-on DevTV and My first Revit plugin tutorials provided with the getting started material:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://thebuildingcoder.typepad.com/blog/about-the-author.html#2" target="_blank"&gt;http://thebuildingcoder.typepad.com/blog/about-the-author.html#2&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The more you understand Revit from an end user point of view, the better you will be equipped to find optimal solutions for you programming and automation tasks.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Also make sure you have installed the help file and Revit SDK programming samples.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Your question is fully answered by one of the latter, in steps 3, 5, 7 and 9 of the &lt;U&gt;DirectionCalculation&lt;/U&gt; SDK sample, cf. its readme file&amp;nbsp;&lt;SPAN class="s1"&gt;SDK/Samples/DirectionCalculation/CS/ReadMe_DirectionCalculation.rtf&lt;/SPAN&gt;:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p1"&gt;&lt;STRONG&gt;Instructions:&lt;/STRONG&gt;&lt;/P&gt;
&lt;P class="p1"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p2"&gt;1. Open FindSouthFacing.rvt&lt;/P&gt;
&lt;P class="p2"&gt;2. Run external command “South Facing Walls Without ProjectLocation”&lt;/P&gt;
&lt;P class="p2"&gt;3. The walls that face south (without regard to the project’s location) are selected&lt;/P&gt;
&lt;P class="p2"&gt;4. Run external command “South Facing Walls With ProjectLocation”&lt;/P&gt;
&lt;P class="p2"&gt;5. The walls that face south (with regard to the project’s location) are selected&lt;/P&gt;
&lt;P class="p2"&gt;6. Run external command “South Facing Windows Without ProjectLocation”&lt;/P&gt;
&lt;P class="p2"&gt;7. The windows that face south (without regard to the project’s location) are selected&lt;/P&gt;
&lt;P class="p2"&gt;8. Run external command “South Facing Windows With ProjectLocation”&lt;/P&gt;
&lt;P class="p2"&gt;9. The windows that face south (with regard to the project’s location) are selected&lt;/P&gt;
&lt;P class="p2"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p2"&gt;More details on this sample are discussed by The Building Coder:&lt;/P&gt;
&lt;P class="p2"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p2"&gt;&lt;A href="http://thebuildingcoder.typepad.com/blog/2010/06/highlight-elements.html" target="_blank"&gt;http://thebuildingcoder.typepad.com/blog/2010/06/highlight-elements.html&lt;/A&gt;&lt;/P&gt;
&lt;P class="p2"&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class="entry-content"&gt;
&lt;DIV class="entry-body"&gt;
&lt;P&gt;This kind of selection is also demonstrated by the Lab1_2_CommandArguments of the ADN Xtra labs:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://github.com/jeremytammik/AdnRevitApiLabsXtra/blob/master/XtraCs/Labs1.cs" target="_blank"&gt;https://github.com/jeremytammik/AdnRevitApiLabsXtra/blob/master/XtraCs/Labs1.cs&lt;/A&gt;&lt;/P&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV class="entry-footer"&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;P class="p2"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p2"&gt;I hope this helps.&lt;/P&gt;
&lt;P class="p2"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p2"&gt;Best regards,&lt;/P&gt;
&lt;P class="p2"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class="p2"&gt;Jeremy&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 31 Aug 2015 11:56:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/selection-limitation-by-category/m-p/5795584#M70763</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2015-08-31T11:56:13Z</dc:date>
    </item>
    <item>
      <title>Re: Selection Limitation by Category</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/selection-limitation-by-category/m-p/5797226#M70764</link>
      <description>&lt;P&gt;Dear Mr.&amp;nbsp;&lt;SPAN&gt;Jeremy,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thank you for spending time on providing me such useful information and detail instruction.&lt;/P&gt;&lt;P&gt;Your site (The Building Coder) covers plenty of such information which is out of my knowledge frame since I am not from programing discipline. I believe I will&amp;nbsp;find much information for my coming questions from there.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Regarding&amp;nbsp;my question, I finally found a suitable answer (of course from your information) for the second step. Although I am not sure this is the best and&amp;nbsp;the only answer but anyway now the command works smoothly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheer!&lt;/P&gt;&lt;P&gt;Sincerely&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;The answer found:&amp;nbsp;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;// Set the selected element set as current select element set
                ICollection&amp;lt;ElementId&amp;gt; wallIds = sel.GetElementIds();
                foreach (Reference r in refWalls)
                {
                    Element e = doc.GetElement(r);
                    wallIds.Add(e.Id);
                }
                UIDoc.Selection.SetElementIds(wallIds);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 01 Sep 2015 09:56:43 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/selection-limitation-by-category/m-p/5797226#M70764</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-09-01T09:56:43Z</dc:date>
    </item>
  </channel>
</rss>

