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.
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.
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.