<?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: Get Parameter Values from Room in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/get-parameter-values-from-room/m-p/6669040#M63496</link>
    <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;How do you check of a parameter exists?&lt;BR /&gt;&lt;BR /&gt;The below code does not work on : OST_Views, OST_Room &amp;amp; OST_DetailComponents&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt; if (null !=  doc2.GetElement(doc2.GetElement(id).GetTypeId()).GetParameters("Family Name"))&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It keeps coming up with an error message, and I have tried.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt; if (0 !=  doc2.GetElement(doc2.GetElement(id).GetTypeId()).GetParameters("Family Name").Count)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 05 Nov 2016 03:41:29 GMT</pubDate>
    <dc:creator>joshua.lumley</dc:creator>
    <dc:date>2016-11-05T03:41:29Z</dc:date>
    <item>
      <title>Get Parameter Values from Room</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/get-parameter-values-from-room/m-p/6502386#M63494</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm moving from Python to C# and am trying to convert my plugin which obtains data from Room objects.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In Python I can obtain a rooms Number with the following&amp;nbsp;method:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Create a FilteredElementCollector of all rooms and then convert to Eleemnts, then loop through the elements list with the variable f:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;paramsnum = f.GetParameters('Number')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This returns the Number parameter value in the variable&amp;nbsp;&lt;SPAN&gt;paramsnum.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This works fine, but I'm struggling to do this in c#:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;            //Get all rooms
            FilteredElementCollector allrooms = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Rooms);

            //Convert room list to elements
            ICollection&amp;lt;Element&amp;gt; allroomelements = allrooms.ToElements();

            // Create list of room numbers (from Number parameter)
            List&amp;lt;string&amp;gt; numslist = new List&amp;lt;string&amp;gt;();

            foreach (Element f in allroomelements)
            {
                Debug.Print(f.Name);
                IList&amp;lt;Parameter&amp;gt; paramsnum = f.GetParameters("Number");
            }&lt;/PRE&gt;&lt;P&gt;&lt;SPAN&gt;This executes, but paramsnum is not a string I can use, I cannot obtain the value from an IList.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Where am I going wrong?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Thanks.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2016 08:09:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/get-parameter-values-from-room/m-p/6502386#M63494</guid>
      <dc:creator>Kevin.Bell</dc:creator>
      <dc:date>2016-08-16T08:09:10Z</dc:date>
    </item>
    <item>
      <title>Re: Get Parameter Values from Room</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/get-parameter-values-from-room/m-p/6503046#M63495</link>
      <description>&lt;P&gt;Dear Archie.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I would strongly recommend you start off working through the .NET C# Revit API getting started material before doing anything else at all, especially the&amp;nbsp;&lt;I&gt;DevTV&lt;/I&gt;&lt;SPAN&gt; and &lt;/SPAN&gt;&lt;I&gt;My First Revit Plugin&lt;/I&gt;&lt;SPAN&gt; tutorials:&lt;/SPAN&gt;&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;That will immediately answer your question and many more, saving both you and the rest of the world lots of time and effort.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeremy&lt;/P&gt;</description>
      <pubDate>Tue, 16 Aug 2016 14:07:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/get-parameter-values-from-room/m-p/6503046#M63495</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2016-08-16T14:07:32Z</dc:date>
    </item>
    <item>
      <title>Re: Get Parameter Values from Room</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/get-parameter-values-from-room/m-p/6669040#M63496</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;How do you check of a parameter exists?&lt;BR /&gt;&lt;BR /&gt;The below code does not work on : OST_Views, OST_Room &amp;amp; OST_DetailComponents&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt; if (null !=  doc2.GetElement(doc2.GetElement(id).GetTypeId()).GetParameters("Family Name"))&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It keeps coming up with an error message, and I have tried.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt; if (0 !=  doc2.GetElement(doc2.GetElement(id).GetTypeId()).GetParameters("Family Name").Count)&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 05 Nov 2016 03:41:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/get-parameter-values-from-room/m-p/6669040#M63496</guid>
      <dc:creator>joshua.lumley</dc:creator>
      <dc:date>2016-11-05T03:41:29Z</dc:date>
    </item>
    <item>
      <title>Re: Get Parameter Values from Room</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/get-parameter-values-from-room/m-p/6669886#M63497</link>
      <description>&lt;P&gt;You should be able to do it like this:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;            ICollection&amp;lt;Element&amp;gt; allRooms = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Rooms).ToElements();
            List&amp;lt;string&amp;gt; roomNumbers = allRooms.Select(x =&amp;gt; ((Room)x).Number).ToList();&lt;/PRE&gt;&lt;P&gt;Few key things to keep in mind here are the differences between Python and C#. C# is strong typed and doesn't fare well with unknown types. Python doesn't have that "issue" since it just tries all possible overloads. C# was meant to be a little more efficient and wants you to define a type that you are working with. What I am getting at here, is that where's you can just do FilteredElementCollector query in Python and then ask returned elements for a Number, you can't do that with C# before you cast Element to Room.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Give it a try.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 06 Nov 2016 03:01:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/get-parameter-values-from-room/m-p/6669886#M63497</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-11-06T03:01:51Z</dc:date>
    </item>
  </channel>
</rss>

