<?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: Element.LookupParameter Issue in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/element-lookupparameter-issue/m-p/9792077#M31269</link>
    <description>&lt;P&gt;&lt;SPAN&gt;The Building Coder has discussed all the questions you raise many times over, including many other aspects of reading parameters as well.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Richard mentions a few important points; thank you very much for that, Richard!&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Here are some hints that come to mind:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;SPAN&gt;Retrieving parameters by display name is not a good idea; always try to use a language independent method when possible: Avoid Retrieving a Parameter by Name -- &lt;A href="https://thebuildingcoder.typepad.com/blog/2015/02/family-instance-area-and-auto-loading-a-project-file.html#5" target="_blank"&gt;https://thebuildingcoder.typepad.com/blog/2015/02/family-instance-area-and-auto-loading-a-project-file.html#5&lt;/A&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;In general, LookupParameter is almost never the optimal method to use, since it searches through all the element parameters and returns the first one whose display string matches. Better: determine some way to uniquely identify your parameter up front and retrieve it directly. Here is an example that demonstrates the performance enhancement that can thus be achieved by optimising setting shared parameters: &lt;A href="https://thebuildingcoder.typepad.com/blog/2020/09/optimising-parameters-and-full-text-search.html" target="_blank"&gt;https://thebuildingcoder.typepad.com/blog/2020/09/optimising-parameters-and-full-text-search.html&lt;/A&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The results that you list above all make perfect sense.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;They can be easily explained like this:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;SPAN&gt;A family instance always refers to its family symbol; to do so, it uses an element id.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;The family symbol always refers to its parent family; to do so, it again uses an element id.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Therefore, you can easily retrieve the element id of a family from an instance like this:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;BuiltInParameter bip_of_symbol = ???
BuiltInParameter bip_of_family = ???

ElementId id_symbol = instance.Get( bip_of_symbol )
Element symbol = doc.GetElement( id_symbol )
ElementId id_family = symbol.Get( bip_of_family )
Element family = doc.GetElement( id_family )&lt;/LI-CODE&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;To determine the suitable built-in parameter enumeration values to use, please explore your family instance using RevitLookup.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 08 Oct 2020 17:18:42 GMT</pubDate>
    <dc:creator>jeremytammik</dc:creator>
    <dc:date>2020-10-08T17:18:42Z</dc:date>
    <item>
      <title>Element.LookupParameter Issue</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/element-lookupparameter-issue/m-p/9791584#M31266</link>
      <description>&lt;P&gt;I am having difficulties getting the Family Element of a FamilyInstance using the "Lookup" method.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;TRY 1 - The "AsValueString methods returns the Family Name and not the family&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;string getFamily(FamilyInstance FI)
{
 return FI.LookupParameter("Family").AsValueString()
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;TRY 2 - The "AsElementId" method of the "Family" Parameter returns the FamilySymbol Id and not the Family Id&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;string getFamily(FamilyInstance FI)
{
  ElementId EI = FI.LookupParameter("Family").AsElementId()
  return FI.Document.GetElement(EI).Name
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;TRY 3 -&amp;nbsp;&lt;SPAN style="display: inline !important; float: none; background-color: #ffffff; color: #666666; cursor: text; font-family: inherit; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 1.7142; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;The "AsElementId" method of the "Family and Type" Parameter returns again the FamilySymbol Id and not the Family Id&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;string getFamily(FamilyInstance FI)
{
  ElementId EI = FI.LookupParameter("Family and Type").AsElementId()
  return FI.Document.GetElement(EI).Name
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;TRY 4 -&amp;nbsp;&lt;SPAN style="background-color: #ffffff; box-sizing: border-box; color: #666666; cursor: text; display: inline; float: none; font-family: inherit; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: 1.7142; orphans: 2; text-align: left; text-decoration: none; text-indent: 0px; text-transform: none; -webkit-text-stroke-width: 0px; white-space: normal; word-spacing: 0px;"&gt;The "&lt;FONT&gt;AsValueString&lt;/FONT&gt;" method of the "Family Name" Parameter returns null. That is very confusing.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;string getFamily(FamilyInstance FI)
{
  ElementId EI = FI.LookupParameter("Family Name").AsElementId()
  return FI.Document.GetElement(EI).Name
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Does the above mean that parameters may store string but not elements correctly?&lt;/P&gt;</description>
      <pubDate>Thu, 08 Oct 2020 14:26:17 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/element-lookupparameter-issue/m-p/9791584#M31266</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-10-08T14:26:17Z</dc:date>
    </item>
    <item>
      <title>Re: Element.LookupParameter Issue</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/element-lookupparameter-issue/m-p/9791835#M31267</link>
      <description>&lt;P&gt;FamilyInstance Lookup method is not reliable.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I checked the statement below. This unfortunately results true!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;bool CompareFamilyVsTypeIdUsingLookupParameter(FamilyInstance FI)
{
  return FI.LookupParameter("Type").AsElementId() == FI.LookupParameter("Family").AsElementId()
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Oct 2020 15:48:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/element-lookupparameter-issue/m-p/9791835#M31267</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-10-08T15:48:56Z</dc:date>
    </item>
    <item>
      <title>Re: Element.LookupParameter Issue</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/element-lookupparameter-issue/m-p/9792022#M31268</link>
      <description>&lt;P&gt;If those are built in Parameters (which they seem to be) then you should be getting the parameter by no other way than with it's built in parameter enum value. With LookupParameter you get the first match with a given name.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;AsValueString is a convenience method you should avoid using this and instead review the storage type of the parameter and use the specific Parmeter.As... method; i.e. .AsString not .AsValueString should be used when the storage type is string.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;AsValueString is most useful when the value is of storage type double and has Units since it converts from internal units and adds the unit symbol according to UI units set. However you can use the unit conversion utilities for that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;'Family Name', 'FamilySymbol', 'Family' are all things you can get from the methods within the various API class objects. You should not need to go anywhere near parameters for these items.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Element.GetTypeID -&amp;gt; ElmentID (ID of ElementType such as FamilySymbol)&lt;/P&gt;&lt;P&gt;Name is overridden as writeonly at ElementType therefore don't cast an Element (which is an ElementType) to ElementType to get Name. Leave as Element and get from Element.Name.&lt;/P&gt;&lt;P&gt;&lt;STRIKE&gt;FamilySymbol.Name&amp;nbsp;&lt;/STRIKE&gt; use FamilySymbol -&amp;gt; Element.Name&lt;/P&gt;&lt;P&gt;FamilySymbol.Family.Name&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Oct 2020 17:12:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/element-lookupparameter-issue/m-p/9792022#M31268</guid>
      <dc:creator>RPTHOMAS108</dc:creator>
      <dc:date>2020-10-08T17:12:18Z</dc:date>
    </item>
    <item>
      <title>Re: Element.LookupParameter Issue</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/element-lookupparameter-issue/m-p/9792077#M31269</link>
      <description>&lt;P&gt;&lt;SPAN&gt;The Building Coder has discussed all the questions you raise many times over, including many other aspects of reading parameters as well.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Richard mentions a few important points; thank you very much for that, Richard!&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Here are some hints that come to mind:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;SPAN&gt;Retrieving parameters by display name is not a good idea; always try to use a language independent method when possible: Avoid Retrieving a Parameter by Name -- &lt;A href="https://thebuildingcoder.typepad.com/blog/2015/02/family-instance-area-and-auto-loading-a-project-file.html#5" target="_blank"&gt;https://thebuildingcoder.typepad.com/blog/2015/02/family-instance-area-and-auto-loading-a-project-file.html#5&lt;/A&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;In general, LookupParameter is almost never the optimal method to use, since it searches through all the element parameters and returns the first one whose display string matches. Better: determine some way to uniquely identify your parameter up front and retrieve it directly. Here is an example that demonstrates the performance enhancement that can thus be achieved by optimising setting shared parameters: &lt;A href="https://thebuildingcoder.typepad.com/blog/2020/09/optimising-parameters-and-full-text-search.html" target="_blank"&gt;https://thebuildingcoder.typepad.com/blog/2020/09/optimising-parameters-and-full-text-search.html&lt;/A&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;The results that you list above all make perfect sense.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;They can be easily explained like this:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;SPAN&gt;A family instance always refers to its family symbol; to do so, it uses an element id.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN&gt;The family symbol always refers to its parent family; to do so, it again uses an element id.&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Therefore, you can easily retrieve the element id of a family from an instance like this:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;BuiltInParameter bip_of_symbol = ???
BuiltInParameter bip_of_family = ???

ElementId id_symbol = instance.Get( bip_of_symbol )
Element symbol = doc.GetElement( id_symbol )
ElementId id_family = symbol.Get( bip_of_family )
Element family = doc.GetElement( id_family )&lt;/LI-CODE&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;To determine the suitable built-in parameter enumeration values to use, please explore your family instance using RevitLookup.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 08 Oct 2020 17:18:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/element-lookupparameter-issue/m-p/9792077#M31269</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2020-10-08T17:18:42Z</dc:date>
    </item>
  </channel>
</rss>

