<?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: How to Pick a View using ISelectionFilter in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-pick-a-view-using-iselectionfilter/m-p/3065658#M81650</link>
    <description>&lt;P&gt;What kind of help? Does your code generate an error?&lt;/P&gt;</description>
    <pubDate>Tue, 21 Jun 2011 00:36:05 GMT</pubDate>
    <dc:creator>phildebrandt</dc:creator>
    <dc:date>2011-06-21T00:36:05Z</dc:date>
    <item>
      <title>How to Pick a View using ISelectionFilter</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-pick-a-view-using-iselectionfilter/m-p/3063174#M81649</link>
      <description>&lt;P&gt;Need help creating filter for View&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Jim&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;//Comments removed for brevity 

namespace TESTING.View.Select
{
    public class MySelectView : IExternalCommand
    {

       UIDocument m_document;
       public Autodesk.Revit.UI.Result Execute(Autodesk.Revit.UI.ExternalCommandData commandData,
            ref string message, Autodesk.Revit.DB.ElementSet elements)
        {
            try
            {
                m_document = commandData.Application.ActiveUIDocument;

                Reference viewRef = m_document.Selection.PickObject(ObjectType.Element, new ViewFilter(m_document.Document), "Please pick a View. ESC for cancel.");

                return Result.Succeeded;
            }
            catch (Exceptions.OperationCanceledException)
            {
                // Selection Cancelled. For picking face and picking point.
                return Result.Cancelled;
            }
            catch (System.Exception ex)
            {
                // If any error, give error information and return failed
                message = ex.Message;
                return Result.Failed;
            }
        }
    }

    public class ViewFilter : ISelectionFilter
    {

        Document m_doc = null;

        public ViewFilter(Document doc)
        {
            m_doc = doc;
        }

        public bool AllowElement(Element element)
        {
            return element is Autodesk.Revit.DB.View;
        }

        public bool AllowReference(Reference refer, XYZ point)
        {
            return false;
        }
    }
}&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 17 Jun 2011 14:39:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-pick-a-view-using-iselectionfilter/m-p/3063174#M81649</guid>
      <dc:creator>Todd_Jacobs</dc:creator>
      <dc:date>2011-06-17T14:39:40Z</dc:date>
    </item>
    <item>
      <title>Re: How to Pick a View using ISelectionFilter</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-pick-a-view-using-iselectionfilter/m-p/3065658#M81650</link>
      <description>&lt;P&gt;What kind of help? Does your code generate an error?&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2011 00:36:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-pick-a-view-using-iselectionfilter/m-p/3065658#M81650</guid>
      <dc:creator>phildebrandt</dc:creator>
      <dc:date>2011-06-21T00:36:05Z</dc:date>
    </item>
    <item>
      <title>Re: How to Pick a View using ISelectionFilter</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-pick-a-view-using-iselectionfilter/m-p/3066070#M81651</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;No runtime error is&amp;nbsp;generated, but when the cursor hovers over a view object it is not allowing it to be selected, the cursor remains as a circle with a slash, I need help with the&amp;nbsp;selection filter code to accept a View object&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2011 11:34:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-pick-a-view-using-iselectionfilter/m-p/3066070#M81651</guid>
      <dc:creator>Todd_Jacobs</dc:creator>
      <dc:date>2011-06-21T11:34:52Z</dc:date>
    </item>
    <item>
      <title>Re: How to Pick a View using ISelectionFilter</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-pick-a-view-using-iselectionfilter/m-p/3066300#M81652</link>
      <description>&lt;P&gt;[Edit]&lt;/P&gt;&lt;P&gt;I am not sure if I should be filtering for a&amp;nbsp;View , I did not see a ViewPort class, it's the ViewPort on the sheet which is to be selected&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Jim&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jun 2011 13:37:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-pick-a-view-using-iselectionfilter/m-p/3066300#M81652</guid>
      <dc:creator>Todd_Jacobs</dc:creator>
      <dc:date>2011-06-21T13:37:49Z</dc:date>
    </item>
    <item>
      <title>Re: How to Pick a View using ISelectionFilter</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/how-to-pick-a-view-using-iselectionfilter/m-p/3068226#M81653</link>
      <description>&lt;P&gt;I modified the ViewFilter class to this and it seems to work, but is it the correct way of doing it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Jim&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;    public class ViewFilter : ISelectionFilter
    {
        // Revit document.
        Document m_doc = null;

        /// &amp;lt;summary&amp;gt;
        /// Constructor the filter and initialize the document.
        /// &amp;lt;/summary&amp;gt;
        /// &amp;lt;param name="doc"&amp;gt;The document.&amp;lt;/param&amp;gt;
        public ViewFilter(Document doc)
        {
            m_doc = doc;
        }

        /// &amp;lt;summary&amp;gt;
        /// Allow View - ViewPort? to be selected
        /// &amp;lt;/summary&amp;gt;
        /// &amp;lt;param name="element"&amp;gt;A candidate element in selection operation.&amp;lt;/param&amp;gt;
        /// &amp;lt;returns&amp;gt;Return true for View - ViewPort?. Return false for non View - ViewPort? element.&amp;lt;/returns&amp;gt;
        public bool AllowElement(Element element)
        {

            Reference myView = new Reference(element);

            if (null != myView)
            {
                if ("324" == m_doc.GetElement(myView).GetTypeId().ToString())
                    return true;
                else
                    return false;
            }
            else
            {
                return false;
            }
        }

        /// &amp;lt;summary&amp;gt;
        /// No reference to be selected
        /// &amp;lt;/summary&amp;gt;
        /// &amp;lt;param name="refer"&amp;gt;A candidate reference in selection operation.&amp;lt;/param&amp;gt;
        /// &amp;lt;param name="point"&amp;gt;The 3D position of the mouse on the candidate reference.&amp;lt;/param&amp;gt;
        /// &amp;lt;returns&amp;gt;Return true for reference. Return false non reference.&amp;lt;/returns&amp;gt;
        public bool AllowReference(Reference refer, XYZ point)
        {
            return true;
        }
    }&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Jun 2011 18:03:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/how-to-pick-a-view-using-iselectionfilter/m-p/3068226#M81653</guid>
      <dc:creator>Todd_Jacobs</dc:creator>
      <dc:date>2011-06-22T18:03:44Z</dc:date>
    </item>
  </channel>
</rss>

