<?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.CanBeLocked Method in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/element-canbelocked-method/m-p/8958961#M40590</link>
    <description>&lt;P&gt;There must be some that can't. I have the following code in one of my apps:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;IList&amp;lt;ElementId&amp;gt; regionList = new List&amp;lt;ElementId&amp;gt;();
FilteredElementCollector collector = new FilteredElementCollector(TheDoc);
IList&amp;lt;Element&amp;gt; fr_list = collector.WherePasses(new ElementClassFilter(typeof(FilledRegion))).ToElements();

foreach (Element fr in fr_list )
{
  if (fr.Pinned)
  {
    fr.Pinned = false;
  }
}&lt;/PRE&gt;&lt;P&gt;But I keep getting the following exception when trying to set pinned = false.&lt;/P&gt;&lt;P&gt;Autodesk.Revit.Exceptions.InvalidOperationException: Element cannot be pinned or unpinned.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't have access to the Revit project file so I can't tell what it is about the Filled Region that is doing this.&lt;/P&gt;</description>
    <pubDate>Sat, 10 Aug 2019 10:37:16 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2019-08-10T10:37:16Z</dc:date>
    <item>
      <title>Element.CanBeLocked Method</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/element-canbelocked-method/m-p/8955077#M40588</link>
      <description>&lt;P&gt;Does the Element.CanBeLocked Method also check if the element can be pinned?&lt;/P&gt;</description>
      <pubDate>Thu, 08 Aug 2019 09:45:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/element-canbelocked-method/m-p/8955077#M40588</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-08-08T09:45:00Z</dc:date>
    </item>
    <item>
      <title>Re: Element.CanBeLocked Method</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/element-canbelocked-method/m-p/8956939#M40589</link>
      <description>&lt;P&gt;HI&amp;nbsp;@Anonymous&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;To answer your question, NO. There is a difference between lock and pin.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think all elements placed in the project can be pinned. So that you can't move those elements in the Revit project(i.e)the position(x,y,z) of the element is fixed until you unpin it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Locking the element is like fixing the element's position based on the position of some other element. (i.e)when you lock 2 levels at a particular distance you can move levels to any position(x,y,z) but the distance between the levels remains the same.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So Element.CanBeLocked() doesn't check element's pinned property.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Since all elements in Revit can be pinned there is no method to check this property.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 09 Aug 2019 05:54:01 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/element-canbelocked-method/m-p/8956939#M40589</guid>
      <dc:creator>naveen.kumar.t</dc:creator>
      <dc:date>2019-08-09T05:54:01Z</dc:date>
    </item>
    <item>
      <title>Re: Element.CanBeLocked Method</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/element-canbelocked-method/m-p/8958961#M40590</link>
      <description>&lt;P&gt;There must be some that can't. I have the following code in one of my apps:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;IList&amp;lt;ElementId&amp;gt; regionList = new List&amp;lt;ElementId&amp;gt;();
FilteredElementCollector collector = new FilteredElementCollector(TheDoc);
IList&amp;lt;Element&amp;gt; fr_list = collector.WherePasses(new ElementClassFilter(typeof(FilledRegion))).ToElements();

foreach (Element fr in fr_list )
{
  if (fr.Pinned)
  {
    fr.Pinned = false;
  }
}&lt;/PRE&gt;&lt;P&gt;But I keep getting the following exception when trying to set pinned = false.&lt;/P&gt;&lt;P&gt;Autodesk.Revit.Exceptions.InvalidOperationException: Element cannot be pinned or unpinned.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I don't have access to the Revit project file so I can't tell what it is about the Filled Region that is doing this.&lt;/P&gt;</description>
      <pubDate>Sat, 10 Aug 2019 10:37:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/element-canbelocked-method/m-p/8958961#M40590</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-08-10T10:37:16Z</dc:date>
    </item>
    <item>
      <title>Re: Element.CanBeLocked Method</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/element-canbelocked-method/m-p/8963018#M40591</link>
      <description>&lt;P&gt;Hi&amp;nbsp;@Anonymous&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;I tried using your code and Filled region can be pinned. But I don't know what is causing you the error.&lt;/P&gt;
&lt;P&gt;It is very difficult for us to help you without you providing us the sample file which is causing the error.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I hope it clarifies.&lt;/P&gt;</description>
      <pubDate>Tue, 13 Aug 2019 11:16:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/element-canbelocked-method/m-p/8963018#M40591</guid>
      <dc:creator>naveen.kumar.t</dc:creator>
      <dc:date>2019-08-13T11:16:19Z</dc:date>
    </item>
  </channel>
</rss>

