<?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 Can't get References for PickObjects method pre-selection in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/can-t-get-references-for-pickobjects-method-pre-selection/m-p/7406445#M55876</link>
    <description>&lt;P&gt;I have a collection of areas, and want to prompt the user to select additional areas by using PickObjects method. Unfortunately, PickObjects only accepts a list of references, and I cannot find a way to get references to my areas. Thought this might work, but it throws an "object reference not set to an instance of an object" error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;        internal IList&amp;lt;Reference&amp;gt; getRefs(List&amp;lt;Area&amp;gt; areas)
        {
            IList&amp;lt;Reference&amp;gt; selected = new List&amp;lt;Reference&amp;gt;();
            try
            {                
                foreach (Area area in areas)
                {
                    selected.Add((area as Object)as Reference);
                }
                return selected;
            }
            catch(Exception e)
            {
                MessageBox.Show(e.ToString());
            }
            return null;           
        }&lt;/PRE&gt;&lt;P&gt;This thread seemed like it might contain helpful info on a similar problem, but the answer in there did not work for me: &lt;A href="https://forums.autodesk.com/t5/revit-api-forum/using-elements-selected-before-a-command-is-started/td-p/6059524" target="_blank"&gt;https://forums.autodesk.com/t5/revit-api-forum/using-elements-selected-before-a-command-is-started/td-p/6059524&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Help would be greatly appreciated!&lt;/P&gt;</description>
    <pubDate>Mon, 25 Sep 2017 13:47:32 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2017-09-25T13:47:32Z</dc:date>
    <item>
      <title>Can't get References for PickObjects method pre-selection</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/can-t-get-references-for-pickobjects-method-pre-selection/m-p/7406445#M55876</link>
      <description>&lt;P&gt;I have a collection of areas, and want to prompt the user to select additional areas by using PickObjects method. Unfortunately, PickObjects only accepts a list of references, and I cannot find a way to get references to my areas. Thought this might work, but it throws an "object reference not set to an instance of an object" error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;        internal IList&amp;lt;Reference&amp;gt; getRefs(List&amp;lt;Area&amp;gt; areas)
        {
            IList&amp;lt;Reference&amp;gt; selected = new List&amp;lt;Reference&amp;gt;();
            try
            {                
                foreach (Area area in areas)
                {
                    selected.Add((area as Object)as Reference);
                }
                return selected;
            }
            catch(Exception e)
            {
                MessageBox.Show(e.ToString());
            }
            return null;           
        }&lt;/PRE&gt;&lt;P&gt;This thread seemed like it might contain helpful info on a similar problem, but the answer in there did not work for me: &lt;A href="https://forums.autodesk.com/t5/revit-api-forum/using-elements-selected-before-a-command-is-started/td-p/6059524" target="_blank"&gt;https://forums.autodesk.com/t5/revit-api-forum/using-elements-selected-before-a-command-is-started/td-p/6059524&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Help would be greatly appreciated!&lt;/P&gt;</description>
      <pubDate>Mon, 25 Sep 2017 13:47:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/can-t-get-references-for-pickobjects-method-pre-selection/m-p/7406445#M55876</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-09-25T13:47:32Z</dc:date>
    </item>
    <item>
      <title>Re: Can't get References for PickObjects method pre-selection</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/can-t-get-references-for-pickobjects-method-pre-selection/m-p/7406623#M55877</link>
      <description>&lt;P&gt;try this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&amp;nbsp;foreach (Area area in areas)
 {
&amp;nbsp;	selected.Add(Reference.ParseFromStableRepresentation(doc,area.UniqueId));
                }
&lt;/PRE&gt;</description>
      <pubDate>Mon, 25 Sep 2017 14:34:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/can-t-get-references-for-pickobjects-method-pre-selection/m-p/7406623#M55877</guid>
      <dc:creator>FAIR59</dc:creator>
      <dc:date>2017-09-25T14:34:05Z</dc:date>
    </item>
    <item>
      <title>Re: Can't get References for PickObjects method pre-selection</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/can-t-get-references-for-pickobjects-method-pre-selection/m-p/7407249#M55878</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Maybe a little simpler, just new Reference(area) instead of Reference.ParseFromStableRepresentation&lt;/P&gt;</description>
      <pubDate>Mon, 25 Sep 2017 17:58:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/can-t-get-references-for-pickobjects-method-pre-selection/m-p/7407249#M55878</guid>
      <dc:creator>aignatovich</dc:creator>
      <dc:date>2017-09-25T17:58:36Z</dc:date>
    </item>
  </channel>
</rss>

