<?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: Elegant way to get possible ElementId values for specific Parameter in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/elegant-way-to-get-possible-elementid-values-for-specific/m-p/7164188#M57645</link>
    <description>&lt;P&gt;Hi Jeremy,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I believe this is a "different class of animal". In brief,&amp;nbsp;the post touches on how to mimic contextual content of Element Properties Panel using Revit API. More specifically, how to get a list of available ElementId values for a given Parameter whos Storage Type = ElementId and has an existing value to use as reference. Mostly revolving around use of 'ElementType.GetSimilarTypes' method.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note: I still cant find a way to get available values for a Parameter that does not have existing value for reference.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jon&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 20 Jun 2017 10:49:35 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2017-06-20T10:49:35Z</dc:date>
    <item>
      <title>Elegant way to get possible ElementId values for specific Parameter</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/elegant-way-to-get-possible-elementid-values-for-specific/m-p/7160358#M57642</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm creating a sort of "Property Editor" dialog for user selected elements. In my dialog, the user may pick from a list of non read-only parameters, and specify an alternate value that my application will use later on under particular circumstances (see dialog image below).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The challenge is to provide a list of relevant alternate "Element Id Values" based on the selected parameter. So far, my approach is to explicitly exam the "Current Value (ElementId)" of selected parameter and create alternate value list accordingly. For some "Current Values" I use the "GetSimilarTypes" function, while others I simply filter the document for elements of same category (see code below image).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So far I have two questions...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;Can someone suggest a less explicit, more elegant way of populating the alternate ElementId values?&lt;/LI&gt;
&lt;LI&gt;Based on my current approach, if the "Current Value" is NULL, I have no way of getting alternate values.&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jon&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;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2017-06-18_18-07-28.jpg" style="width: 705px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/368576iB6EF6DC839BAA186/image-size/large?v=v2&amp;amp;px=999" role="button" title="2017-06-18_18-07-28.jpg" alt="2017-06-18_18-07-28.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;if (request == EditPropertyOptRequest.GetAvailableValues) {
&lt;BR /&gt;	cond.SelElemValue = null;
	cond.PropertyOpt.ElementValues = new ObservableCollection&amp;lt;Element&amp;gt;();

	try {
		dynamic CurrentElem = doc.GetElement(cond.SelProperty.AsElementId);


		if ((CurrentElem) is WallType) {
			WallType obj = CurrentElem;

			foreach (void ElemId_loopVariable in obj.GetSimilarTypes) {
				ElemId = ElemId_loopVariable;
				cond.PropertyOpt.ElementValues.Add(doc.GetElement(ElemId));
			}


		} else if ((CurrentElem) is FloorType) {
			FloorType obj = CurrentElem;

			foreach (void ElemId_loopVariable in obj.GetSimilarTypes) {
				ElemId = ElemId_loopVariable;
				cond.PropertyOpt.ElementValues.Add(doc.GetElement(ElemId));
			}


		} else if ((CurrentElem) is FamilySymbol) {
			FamilySymbol obj = CurrentElem;

			foreach (void ElemId_loopVariable in obj.GetSimilarTypes) {
				ElemId = ElemId_loopVariable;
				cond.PropertyOpt.ElementValues.Add(doc.GetElement(ElemId));
			}


		} else if ((CurrentElem) is Level) {
			FilteredElementCollector collector = new FilteredElementCollector(doc);
			collector.OfCategory(BuiltInCategory.OST_Levels).WhereElementIsNotElementType();

			foreach (void elem_loopVariable in collector) {
				elem = elem_loopVariable;
				cond.PropertyOpt.ElementValues.Add(elem);
			}


		} else if ((CurrentElem) is Phase) {
			FilteredElementCollector collector = new FilteredElementCollector(doc);
			collector.OfCategory(BuiltInCategory.OST_Phases).WhereElementIsNotElementType();

			foreach (void elem_loopVariable in collector) {
				elem = elem_loopVariable;
				cond.PropertyOpt.ElementValues.Add(elem);
			}

		}

		cond.SelElemValue = cond.PropertyOpt.ElementValues(0);

	} catch (Exception ex) {
	}

}&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 18 Jun 2017 22:36:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/elegant-way-to-get-possible-elementid-values-for-specific/m-p/7160358#M57642</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-06-18T22:36:36Z</dc:date>
    </item>
    <item>
      <title>Re: Elegant way to get possible ElementId values for specific Parameter</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/elegant-way-to-get-possible-elementid-values-for-specific/m-p/7161286#M57643</link>
      <description>&lt;P&gt;Quick update...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;After realizing "GetSimilarTypes" method is inherited from "ElementType" base class, I now attempt to cast Element to ElementType, then use "GetSimilarTypes" method if "ElemType" is Not NULL. Otherwise I filter document for NonElementTypes of same Category. I still need to handle elements with No Category, which so far I've identified Line Styles as being this way.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am quite happy with this approach!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jon&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;if (request == EditPropertyOptRequest.GetAvailableValues) {
	cond.SelElemValue = null;
	cond.PropertyOpt.ElementValues = new ObservableCollection&amp;lt;Element&amp;gt;();

	if (cond.SelProperty.StorageType == StorageType.ElementId) {
		ElementId ElemId = cond.SelProperty.AsElementId;
		if (ElemId == null)
			return;

		Element Elem = doc.GetElement(ElemId);
		ElementType ElemType = Elem as ElementType;

		if (ElemType != null) {
			foreach ( ElemId in ElemType.GetSimilarTypes) {
				cond.PropertyOpt.ElementValues.Add(doc.GetElement(ElemId));
			}

		} else if (Elem.Category != null) {
			FilteredElementCollector collector = new FilteredElementCollector(doc);
			collector.OfCategory(Elem.Category.Id.IntegerValue).WhereElementIsNotElementType();

			foreach ( Elem in collector) {
				cond.PropertyOpt.ElementValues.Add(Elem);
			}
		} else {
			//
			//Handle non-category elements. Namely Line Styles(aka GraphicStlyes)
			//
		}

		cond.SelElemValue = cond.PropertyOpt.ElementValues(0);

	}

}&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 19 Jun 2017 12:09:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/elegant-way-to-get-possible-elementid-values-for-specific/m-p/7161286#M57643</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-06-19T12:09:04Z</dc:date>
    </item>
    <item>
      <title>Re: Elegant way to get possible ElementId values for specific Parameter</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/elegant-way-to-get-possible-elementid-values-for-specific/m-p/7163869#M57644</link>
      <description>&lt;P&gt;Dear Jon,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for sharing this.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How does this fit in with the combo box dropdown workarounds suggested here?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://thebuildingcoder.typepad.com/blog/2015/11/drop-down-enumerated-parameter-values.html" target="_blank"&gt;http://thebuildingcoder.typepad.com/blog/2015/11/drop-down-enumerated-parameter-values.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Should I add your solution as a new workaround, or is it a different class of animal?&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, 20 Jun 2017 07:59:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/elegant-way-to-get-possible-elementid-values-for-specific/m-p/7163869#M57644</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2017-06-20T07:59:11Z</dc:date>
    </item>
    <item>
      <title>Re: Elegant way to get possible ElementId values for specific Parameter</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/elegant-way-to-get-possible-elementid-values-for-specific/m-p/7164188#M57645</link>
      <description>&lt;P&gt;Hi Jeremy,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I believe this is a "different class of animal". In brief,&amp;nbsp;the post touches on how to mimic contextual content of Element Properties Panel using Revit API. More specifically, how to get a list of available ElementId values for a given Parameter whos Storage Type = ElementId and has an existing value to use as reference. Mostly revolving around use of 'ElementType.GetSimilarTypes' method.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Note: I still cant find a way to get available values for a Parameter that does not have existing value for reference.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jon&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jun 2017 10:49:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/elegant-way-to-get-possible-elementid-values-for-specific/m-p/7164188#M57645</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-06-20T10:49:35Z</dc:date>
    </item>
    <item>
      <title>Re: Elegant way to get possible ElementId values for specific Parameter</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/elegant-way-to-get-possible-elementid-values-for-specific/m-p/7164314#M57646</link>
      <description>&lt;P&gt;Dear Jon,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you, all clear now.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;To get available values for a Parameter that does not have an existing value for reference, you&amp;nbsp;might be able to create a suitable template element in a temporary transaction, grab the data you require from it, and roll back the transaction without committing, also know as the 'temporary transaction trick' TTT:&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#5.53" target="_blank"&gt;http://thebuildingcoder.typepad.com/blog/about-the-author.html#5.53&lt;/A&gt;&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, 20 Jun 2017 11:48:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/elegant-way-to-get-possible-elementid-values-for-specific/m-p/7164314#M57646</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2017-06-20T11:48:11Z</dc:date>
    </item>
    <item>
      <title>Re: Elegant way to get possible ElementId values for specific Parameter</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/elegant-way-to-get-possible-elementid-values-for-specific/m-p/7164438#M57647</link>
      <description>&lt;P&gt;Thanks for suggestion Jeremy,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;TTT may work, but I don't see a way to determine what a "suitable template element" might be. Given a parameter with &amp;lt;null&amp;gt; ElementID value, the only helpful information looks like BuiltInParameter Id, but that doesn't get me very far. Worst case, I make exceptions for my favorite BuiltInParameter Id's to assist in determining "suitable template element".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Almost as if the Parameter class would benefit from something like a "GetSampleValueType" method.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jon&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jun 2017 12:33:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/elegant-way-to-get-possible-elementid-values-for-specific/m-p/7164438#M57647</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-06-20T12:33:00Z</dc:date>
    </item>
    <item>
      <title>Re: Elegant way to get possible ElementId values for specific Parameter</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/elegant-way-to-get-possible-elementid-values-for-specific/m-p/7166024#M57648</link>
      <description>&lt;P&gt;you can use a ElementParameterFilter, to get all the elements that have a value&amp;nbsp;other then ElementId.InvalidElementId &amp;nbsp;for a specific parameter.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;this code filters for elements in the active view, that are demolished in some&amp;nbsp;phase.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;            ParameterValueProvider pvp_Demolished = new ParameterValueProvider(new ElementId((int)BuiltInParameter.PHASE_DEMOLISHED));
            FilterNumericGreater fgreater = new FilterNumericGreater();
            FilterElementIdRule IdFilter = new FilterElementIdRule(pvp_Demolished, fgreater, ElementId.InvalidElementId);
            ElementParameterFilter efilter = new ElementParameterFilter(IdFilter);

            FilteredElementCollector elems = new FilteredElementCollector(doc, doc.ActiveView.Id)
                .WherePasses(efilter);
&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jun 2017 20:43:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/elegant-way-to-get-possible-elementid-values-for-specific/m-p/7166024#M57648</guid>
      <dc:creator>FAIR59</dc:creator>
      <dc:date>2017-06-20T20:43:37Z</dc:date>
    </item>
    <item>
      <title>Re: Elegant way to get possible ElementId values for specific Parameter</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/elegant-way-to-get-possible-elementid-values-for-specific/m-p/7166122#M57649</link>
      <description>&lt;P&gt;Thanks for the suggestion FAIR59,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Unfortunately that's not what I'm looking to accomplish. Please see video below for better explanation of what I'm trying to do. Maybe you might have another idea.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jon&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;div class="video-embed-center video-embed"&gt;&lt;iframe class="embedly-embed" src="https://cdn.embedly.com/widgets/media.html?url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3Db_1k3uXaQrY&amp;amp;type=text%2Fhtml&amp;amp;schema=google&amp;amp;display_name=YouTube&amp;amp;src=https%3A%2F%2Fwww.youtube.com%2Fembed%2Fb_1k3uXaQrY" width="400" height="225" scrolling="no" title="YouTube embed" frameborder="0" allow="autoplay; fullscreen; encrypted-media; picture-in-picture" allowfullscreen="true"&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jun 2017 21:19:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/elegant-way-to-get-possible-elementid-values-for-specific/m-p/7166122#M57649</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-06-20T21:19:18Z</dc:date>
    </item>
    <item>
      <title>Re: Elegant way to get possible ElementId values for specific Parameter</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/elegant-way-to-get-possible-elementid-values-for-specific/m-p/7166166#M57650</link>
      <description>&lt;P&gt;Actually, it is part of what you are trying to accomplish. With&amp;nbsp;an ElementParameterFilter you get a list of Elements (if there are any) that have a value for the parameter in question, and then you&amp;nbsp;may find all the relevant values, or display all the found values.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 20 Jun 2017 21:44:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/elegant-way-to-get-possible-elementid-values-for-specific/m-p/7166166#M57650</guid>
      <dc:creator>FAIR59</dc:creator>
      <dc:date>2017-06-20T21:44:38Z</dc:date>
    </item>
    <item>
      <title>Re: Elegant way to get possible ElementId values for specific Parameter</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/elegant-way-to-get-possible-elementid-values-for-specific/m-p/7166198#M57651</link>
      <description>&lt;P&gt;Oh I see now, VERY CLEVER!!!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Just implemented and works like a charm. Only caveat like you say is "if there are any", but I can live with that.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks for the great tip!!!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jon&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>Tue, 20 Jun 2017 22:02:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/elegant-way-to-get-possible-elementid-values-for-specific/m-p/7166198#M57651</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2017-06-20T22:02:46Z</dc:date>
    </item>
    <item>
      <title>Re: Elegant way to get possible ElementId values for specific Parameter</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/elegant-way-to-get-possible-elementid-values-for-specific/m-p/7167137#M57652</link>
      <description>&lt;P&gt;Rescued for posterity here:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://thebuildingcoder.typepad.com/blog/2017/06/finding-an-exit-path-and-elementid-parameter-values.html#3" target="_blank"&gt;http://thebuildingcoder.typepad.com/blog/2017/06/finding-an-exit-path-and-elementid-parameter-values.html#3&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks guys, especially Fair59!&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>Wed, 21 Jun 2017 09:28:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/elegant-way-to-get-possible-elementid-values-for-specific/m-p/7167137#M57652</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2017-06-21T09:28:56Z</dc:date>
    </item>
    <item>
      <title>Re: Elegant way to get possible ElementId values for specific Parameter</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/elegant-way-to-get-possible-elementid-values-for-specific/m-p/13400005#M57653</link>
      <description>&lt;P&gt;Old thread, but was just working through this problem myself.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The accepted solution will only find ElementId values which have been used somewhere in the model. So if for example you have 10 phases, but only 2 of them are used somewhere, your dropdown will only display those 2 phases.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But you can get all available options though &lt;U&gt;if any element in the model has &lt;STRONG&gt;a&lt;/STRONG&gt; value set for that parameter&lt;/U&gt;. As long as there is one element that has chosen an option besides the None option for a parameter, you can find all options for that parameter using the below. The below code will capture all these options for ElementId parameters like Phase, Level, End Connection, etc. Note if you want to retrieve possible values for the Family, Family and Type, and Type parameters, you would have to supply an element or category of interest and just collect all the ElementTypes pertinent to that category. Note it is important to use the below approach rather than ElementType.GetSimilarTypes(), because some ElementId parameters do not represent ElementTypes - for example base level, phase created, etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;Parameter param = //Whatever parameter you supply
var paramDef = param.Definition as InternalDefinition;
ElementId id = param.Id;
// Need to filter for elements that have a value of the parameter, and for value not equal to InvalidElementId
var filter = new ElementParameterFilter(new HasValueFilterRule(id));
var filter2 = new ElementParameterFilter(new FilterInverseRule(new FilterElementIdRule(new ParameterValueProvider(id), new FilterNumericEquals(), ElementId.InvalidElementId)));

var elem = new FilteredElementCollector(doc).WherePasses(filter).WherePasses(filter2).FirstOrDefault();

if (elem is not null)
{
    var valueId = elem.get_Parameter(paramDef).AsElementId();
    var valueElem = doc.GetElement(valueId); 
    var allOfType = new FilteredElementCollector(doc).OfClass(valueElem.GetType()).ToElements().GroupBy(e =&amp;gt; e.Name).Select(g =&amp;gt; g.First());
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If all elements in the model have the "None" option (if available) set for the parameter, or if there are no elements modeled with the parameter available, elem will be null and you can't retrieve the available options.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It's another can of worms to get available options for some of the built-in parameters that are an enumeration, like Workset, "Export to IFC", and View Scale. These are just stored as an Integer internally, and the names of the options don't seem to generally be exposed. For Workset you can just use a FilteredWorksetCollector, but for the other enumerations, the best way I have found to get them is to run a dummy transaction where you try to set the parameter to each integer in a reasonable range of values (most of the enumerations are in the range 0-3, but some like View Scale go much higher). If the parameter.Set(integer) succeeds, you can collect the enumeration name of the result using parameter.ToValueString() and collect that name and corresponding integer value into a dictionary and make them unique by the name. Then cancel the transaction.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 31 May 2025 12:53:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/elegant-way-to-get-possible-elementid-values-for-specific/m-p/13400005#M57653</guid>
      <dc:creator>schipmanU5A9G</dc:creator>
      <dc:date>2025-05-31T12:53:18Z</dc:date>
    </item>
  </channel>
</rss>

