<?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: Why is PickObjects with Selection filter slows down my selection in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/why-is-pickobjects-with-selection-filter-slows-down-my-selection/m-p/8581790#M44368</link>
    <description>&lt;P&gt;I didn't see any problematic code in your selection filter implementation, the only thing I can anticipate is the PickObjects needs more calculation time after element selection filtering, for example, it needs to check if the passed element is in valid mouse selection region, the geometry calculation may need more time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 08 Feb 2019 03:44:49 GMT</pubDate>
    <dc:creator>JimJia</dc:creator>
    <dc:date>2019-02-08T03:44:49Z</dc:date>
    <item>
      <title>Why is PickObjects with Selection filter slows down my selection</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/why-is-pickobjects-with-selection-filter-slows-down-my-selection/m-p/8580938#M44367</link>
      <description>&lt;P&gt;Why is PickOjects with Selection Filter slower than the PickObjects with out Selection Filter in IExternalCommand(Add-in). I try inputting code inside Revit Macro and see no difference in both methods.&lt;/P&gt;
&lt;P&gt;My code is working fine(Please see below) The Only difference is the performance. PickObjects with Selection Filter feels a little slower and laggy.&lt;/P&gt;
&lt;P&gt;Should i write my code differently? maybe my IselectionFilter is not a good write?&lt;/P&gt;
&lt;P&gt;any help, comments, suggestion will greatly appreciated.&lt;/P&gt;
&lt;PRE&gt;#region Namespaces
using System;
using System.Collections.Generic;
using System.Diagnostics;
using Autodesk.Revit.ApplicationServices;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;
#endregion

namespace ConduitSizeShowInfo
{
    [Transaction(TransactionMode.Manual)]
    public class Command : IExternalCommand
    {
        public Result Execute(
          ExternalCommandData commandData,
          ref string message,
          ElementSet elements)
        {
            UIApplication uiapp = commandData.Application;
            UIDocument uidoc = uiapp.ActiveUIDocument;
            Application app = uiapp.Application;
            Document doc = uidoc.Document;

            try
            {
                //Filter Selection
                SelectElementsFilter conduitFilter = new SelectElementsFilter("Conduits");

                //Pick Multiple Conduits
                IList&amp;lt;Reference&amp;gt; selectedConduits = uidoc.Selection.PickObjects(ObjectType.Element, conduitFilter, "Please select conduits");

                //Show Conduit Size Information
                string showConduitSize = "";
                foreach (Reference conduit in selectedConduits)
                {
                    Element e = doc.GetElement(conduit);
                    Parameter conduitSize = e.LookupParameter("Size");
                    showConduitSize += e.Name + ": " + conduitSize.AsString() + Environment.NewLine;
                }
                TaskDialog.Show("Conduit Sizes", showConduitSize);
            }
            catch(Autodesk.Revit.Exceptions.OperationCanceledException)
            {
                return Result.Cancelled;
            }
            catch(Exception ex)
            {
                message = ex.Message;
                return Result.Failed;
            }
           
            return Result.Succeeded;
        }

        public class SelectElementsFilter : ISelectionFilter
        {
            static string CategoryName = "";

            public SelectElementsFilter(string name)
            {
                CategoryName = name;
            }

            public bool AllowElement(Element e)
            {
                if (e.Category.Name == CategoryName)
                    return true;
                return false;
            }

            public bool AllowReference(Reference r, XYZ p)
            {
                return false;
            }
        }
    }
}
&lt;/PRE&gt;</description>
      <pubDate>Thu, 07 Feb 2019 19:27:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/why-is-pickobjects-with-selection-filter-slows-down-my-selection/m-p/8580938#M44367</guid>
      <dc:creator>johna</dc:creator>
      <dc:date>2019-02-07T19:27:33Z</dc:date>
    </item>
    <item>
      <title>Re: Why is PickObjects with Selection filter slows down my selection</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/why-is-pickobjects-with-selection-filter-slows-down-my-selection/m-p/8581790#M44368</link>
      <description>&lt;P&gt;I didn't see any problematic code in your selection filter implementation, the only thing I can anticipate is the PickObjects needs more calculation time after element selection filtering, for example, it needs to check if the passed element is in valid mouse selection region, the geometry calculation may need more time.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Feb 2019 03:44:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/why-is-pickobjects-with-selection-filter-slows-down-my-selection/m-p/8581790#M44368</guid>
      <dc:creator>JimJia</dc:creator>
      <dc:date>2019-02-08T03:44:49Z</dc:date>
    </item>
  </channel>
</rss>

