Element.CanBeLocked Method

Element.CanBeLocked Method

Anonymous
Not applicable
786 Views
3 Replies
Message 1 of 4

Element.CanBeLocked Method

Anonymous
Not applicable

Does the Element.CanBeLocked Method also check if the element can be pinned?

0 Likes
787 Views
3 Replies
Replies (3)
Message 2 of 4

naveen.kumar.t
Autodesk Support
Autodesk Support

HI @Anonymous ,

To answer your question, NO. There is a difference between lock and pin.

 

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.

 

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.

 

So Element.CanBeLocked() doesn't check element's pinned property.

 

Since all elements in Revit can be pinned there is no method to check this property.

 


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 4

Anonymous
Not applicable

There must be some that can't. I have the following code in one of my apps:

 

IList<ElementId> regionList = new List<ElementId>();
FilteredElementCollector collector = new FilteredElementCollector(TheDoc);
IList<Element> fr_list = collector.WherePasses(new ElementClassFilter(typeof(FilledRegion))).ToElements();

foreach (Element fr in fr_list )
{
  if (fr.Pinned)
  {
    fr.Pinned = false;
  }
}

But I keep getting the following exception when trying to set pinned = false.

Autodesk.Revit.Exceptions.InvalidOperationException: Element cannot be pinned or unpinned.

 

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.

0 Likes
Message 4 of 4

naveen.kumar.t
Autodesk Support
Autodesk Support

Hi @Anonymous ,

I tried using your code and Filled region can be pinned. But I don't know what is causing you the error.

It is very difficult for us to help you without you providing us the sample file which is causing the error.

 

I hope it clarifies.


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

0 Likes