<?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: FILTER WITH SHARED PARAMETER. GUID ID. in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/filter-with-shared-parameter-guid-id/m-p/7128442#M58094</link>
    <description>&lt;P&gt;&lt;STRONG&gt;PRINCIPAL QUERY (SOLVED):&amp;nbsp;&lt;/STRONG&gt;Thanks Matthew. I'm relative new to coding. Your tips where very useful to stablish a methodology to how detect errors. My problem was that I was detecting all elements in the file, not just in the model.&amp;nbsp;With "ofClass(typeof(FamilyInstance))" everything solved.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will try your code soon Fair59. Thanks aswell.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;SECOND QUERY:&lt;/STRONG&gt; I just need now to see if I can define by the API the GUID of the shared parameter when I create it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have a nice week.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers.&lt;/P&gt;</description>
    <pubDate>Mon, 05 Jun 2017 06:59:34 GMT</pubDate>
    <dc:creator>juancalvoferrandiz</dc:creator>
    <dc:date>2017-06-05T06:59:34Z</dc:date>
    <item>
      <title>FILTER WITH SHARED PARAMETER. GUID ID.</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/filter-with-shared-parameter-guid-id/m-p/7117175#M58089</link>
      <description>&lt;P&gt;Hello everyone!&lt;/P&gt;&lt;P&gt;As matthew.taylor has suggested I'm creating a post with a query which I'm strugguling since a few days ago:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;OBJECTIVE:&lt;/STRONG&gt; Filter the elements in my model of a category I choose with a shared parameter yes/no.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;ACTUAL SITUATION:&lt;/STRONG&gt; At this moment, I know how get my objective but using the GUID number directly, looking at it in the .txt or the fantastic "Lookup" addin.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;int ruleValInt = 1;&lt;BR /&gt;
Element firstdoorElement = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Doors).FirstElement();
Parameter SharedParamGUIDID = firstdoorElement.get_Parameter(new Guid("6b79a46d-8d2a-4071-8069-86dc9c0f2c68"));

ParameterValueProvider pvp = new ParameterValueProvider(SharedParamGUIDID.Id);
FilterNumericEquals fnrv = new FilterNumericEquals();
FilterIntegerRule paramFr = new FilterIntegerRule(pvp, fnrv, ruleValInt);
ElementParameterFilter epf = new ElementParameterFilter( paramFr );

FilteredElementCollector doors = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Doors).WherePasses(epf);
doors.OfClass(typeof(FamilyInstance));&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;MAIN QUERY:&lt;/STRONG&gt; I want to know how to get and use the GUID from the .txt or the category(or element). I have this code that dosen't give any error in Visual, but dosent work when I do the debugging:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Element firstdoorElement = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Doors).FirstElement();
var sharedParamGuid = firstdoorElement.LookupParameter(LabConstants.SharedParamsGroupAPI).GUID;
Parameter SharedParamGUIDID = firstdoorElement.get_Parameter(sharedParamGuid);


ParameterValueProvider pvp = new ParameterValueProvider(SharedParamGUIDID.Id);
FilterNumericEquals fnrv = new FilterNumericEquals();
FilterIntegerRule paramFr = new FilterIntegerRule(pvp, fnrv, ruleValInt);
ElementParameterFilter epf = new ElementParameterFilter( paramFr );

FilteredElementCollector doors = new FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Doors).WherePasses(epf); ;
doors.OfClass(typeof(FamilyInstance));&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;SECOND QUERY:&lt;/STRONG&gt; It's possible to write the GUID I want to use? Example: "7b7b77b-7b7b-7777-7777-77bb7b77bb77" I want to do this in case I use families created before with the same shared parameter name and group, but different GUID. My intention is to create always this parameter with the same GUID so I can filter independently from when it was created.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;REFERENCES &lt;/STRONG&gt;&lt;STRONG&gt;:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;A href="https://forums.autodesk.com/t5/revit-api-forum/get-all-elements-in-a-project-that-have-a-parameter-with-a-value/m-p/7116245" target="_blank"&gt;https://forums.autodesk.com/t5/revit-api-forum/get-all-elements-in-a-project-that-have-a-parameter-with-a-value/m-p/7116245&lt;/A&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;A href="http://thebuildingcoder.typepad.com/blog/2015/12/shared-project-parameter-guid-reporter.html" target="_blank"&gt;http://thebuildingcoder.typepad.com/blog/2015/12/shared-project-parameter-guid-reporter.html&lt;/A&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;A href="http://spiderinnet.typepad.com/blog/2011/07/elementparameterfilter-using-sharedparameterapplicablerule-to-filter-element-parameters-in-c.html" target="_blank"&gt;http://spiderinnet.typepad.com/blog/2011/07/elementparameterfilter-using-sharedparameterapplicablerule-to-filter-element-parameters-in-c.html&lt;/A&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;A href="https://forums.autodesk.com/t5/revit-api-forum/get-parameter-guid-directly-from-shared-parameter-file/m-p/6372000/highlight/true#M16650" target="_blank"&gt;https://forums.autodesk.com/t5/revit-api-forum/get-parameter-guid-directly-from-shared-parameter-file/m-p/6372000/highlight/true#M16650&lt;/A&gt;&lt;/EM&gt;&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;Any comment is wellcome. Thanks for your time. Have a nice day.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 May 2017 15:11:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/filter-with-shared-parameter-guid-id/m-p/7117175#M58089</guid>
      <dc:creator>juancalvoferrandiz</dc:creator>
      <dc:date>2017-05-30T15:11:04Z</dc:date>
    </item>
    <item>
      <title>Re: FILTER WITH SHARED PARAMETER. GUID ID.</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/filter-with-shared-parameter-guid-id/m-p/7119107#M58090</link>
      <description>&lt;P&gt;Hello &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/2738191"&gt;@juancalvoferrandiz&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;Thanks for making the new post.&lt;/P&gt;
&lt;P&gt;Without looking at your code too much, have you seen the ParameterFilterRuleFactory class? &lt;A href="http://www.revitapidocs.com/2017.1/e6646480-b0ce-b299-3996-e965c913f9c4.htm" target="_self"&gt;http://www.revitapidocs.com/2017.1/e6646480-b0ce-b299-3996-e965c913f9c4.htm&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;When testing filters, add a layer at a time and check that your results are as expected along the way. Not all filters act as I expect them to, perhaps the same applies to you?&lt;/P&gt;
&lt;P&gt;As for your GUID question. If the GUID varies, then just using the shared parameter name could be the best tactic. Or search for a selection of GUIDs.&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 10:16:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/filter-with-shared-parameter-guid-id/m-p/7119107#M58090</guid>
      <dc:creator>matthew_taylor</dc:creator>
      <dc:date>2017-05-31T10:16:59Z</dc:date>
    </item>
    <item>
      <title>Re: FILTER WITH SHARED PARAMETER. GUID ID.</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/filter-with-shared-parameter-guid-id/m-p/7119242#M58091</link>
      <description>&lt;P&gt;Thanks Matthew for your quick answer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;PRINCIPAL QUERY:&lt;/STRONG&gt; I didn,t know about ParameterFilterRuleFactory class. I will take a look at it as soon as possible.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have detect that my problem is with this line. When debugging the message I get is this one:&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="Screenshot (29).png" style="width: 705px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/361925i318729B0C22A0264/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot (29).png" alt="Screenshot (29).png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;RIght now, I dont know what it refers to.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;STRONG&gt;SECOND QUERY:&lt;/STRONG&gt; The problem I think I have if I use the name parameter, is that I can end with more than 1 parameter if they have different GUID. Thats why I think a good option to be sure, that the shared parameter I have has the same GUID and name, all the ocassions I create it or/and use it.&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;Have a nice day.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 11:48:51 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/filter-with-shared-parameter-guid-id/m-p/7119242#M58091</guid>
      <dc:creator>juancalvoferrandiz</dc:creator>
      <dc:date>2017-05-31T11:48:51Z</dc:date>
    </item>
    <item>
      <title>Re: FILTER WITH SHARED PARAMETER. GUID ID.</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/filter-with-shared-parameter-guid-id/m-p/7119259#M58092</link>
      <description>&lt;P&gt;Hi &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/2738191"&gt;@juancalvoferrandiz&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;No problem.&lt;/P&gt;
&lt;P&gt;You are calling for the GUID in the same line as the LookupParameter.&lt;/P&gt;
&lt;P&gt;If you put the lookupParameter on the first line, then get the guid on the second line, you'll (probably) find that the same exception happens on the second line - the parameter hasn't been found. So provide a test for Parameter=nothing, and an alert so you know that this has happened.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You don't note what your constant is. If it's not the parameter name, then that's the issue. If it is, then it (the parameter) doesn't exist.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could filter for door elements that definitely have the relevant parameter, so that you know that the parameter exists.&lt;/P&gt;</description>
      <pubDate>Wed, 31 May 2017 11:54:29 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/filter-with-shared-parameter-guid-id/m-p/7119259#M58092</guid>
      <dc:creator>matthew_taylor</dc:creator>
      <dc:date>2017-05-31T11:54:29Z</dc:date>
    </item>
    <item>
      <title>Re: FILTER WITH SHARED PARAMETER. GUID ID.</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/filter-with-shared-parameter-guid-id/m-p/7127726#M58093</link>
      <description>&lt;P&gt;For shared parameters you don't need to have an element with that parameter. The SharedParameterElement exists independent in the document.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;if you know the GUID :&lt;/P&gt;
&lt;P&gt;SharedParameterElement shParamElement = SharedParameterElement.Lookup(doc, new Guid("088dc720-c070-40bb-b838-b1e34b47b46f"));&lt;/P&gt;
&lt;P&gt;ParameterValueProvider pvp = new ParameterValueProvider(shParamElement.Id);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or you can search for a&amp;nbsp;parameter by&amp;nbsp;name in this List;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;List&amp;lt;SharedParameterElement&amp;gt; shParamElements = new FilteredElementCollector(doc)&lt;/P&gt;
&lt;P&gt;.OfClass(typeof(SharedParameterElement))&lt;/P&gt;
&lt;P&gt;.Cast&amp;lt;SharedParameterElement&amp;gt;()&lt;/P&gt;
&lt;P&gt;.ToList();&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 04 Jun 2017 12:02:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/filter-with-shared-parameter-guid-id/m-p/7127726#M58093</guid>
      <dc:creator>FAIR59</dc:creator>
      <dc:date>2017-06-04T12:02:30Z</dc:date>
    </item>
    <item>
      <title>Re: FILTER WITH SHARED PARAMETER. GUID ID.</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/filter-with-shared-parameter-guid-id/m-p/7128442#M58094</link>
      <description>&lt;P&gt;&lt;STRONG&gt;PRINCIPAL QUERY (SOLVED):&amp;nbsp;&lt;/STRONG&gt;Thanks Matthew. I'm relative new to coding. Your tips where very useful to stablish a methodology to how detect errors. My problem was that I was detecting all elements in the file, not just in the model.&amp;nbsp;With "ofClass(typeof(FamilyInstance))" everything solved.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will try your code soon Fair59. Thanks aswell.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;SECOND QUERY:&lt;/STRONG&gt; I just need now to see if I can define by the API the GUID of the shared parameter when I create it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have a nice week.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers.&lt;/P&gt;</description>
      <pubDate>Mon, 05 Jun 2017 06:59:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/filter-with-shared-parameter-guid-id/m-p/7128442#M58094</guid>
      <dc:creator>juancalvoferrandiz</dc:creator>
      <dc:date>2017-06-05T06:59:34Z</dc:date>
    </item>
    <item>
      <title>Re: FILTER WITH SHARED PARAMETER. GUID ID.</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/filter-with-shared-parameter-guid-id/m-p/7128518#M58095</link>
      <description>&lt;P&gt;Hi &lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/2738191"&gt;@juancalvoferrandiz&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;One way is to load the shared parameter definition from file. There is an example &lt;A href="http://www.revitapidocs.com/2017.1/a3e84415-b88e-a8e0-4e11-64795d92da0e.htm" target="_self"&gt;here&lt;/A&gt;.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 05 Jun 2017 07:58:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/filter-with-shared-parameter-guid-id/m-p/7128518#M58095</guid>
      <dc:creator>matthew_taylor</dc:creator>
      <dc:date>2017-06-05T07:58:05Z</dc:date>
    </item>
  </channel>
</rss>

