Question is very simple. Can any ElementId be opened as Element?
Answer is pretty difficult. It depends.
For those visible stuffs on screen such as Walls, Doors and Windows, yes, their ElementId properties can be opened as their Element instances. Even for many invisible stuffs such as Wall types, Door types and Window types, their ElementId properties behave well. Though the opened object would be of ElementType instead of Element, we do not need to worry since ElementType is derived from Element anyway.
Challenge comes. What about ElementId property of Parameter class then?
The answer is more difficult. It really depends. If the Parameter represents a built-in, the Document.GetElement(ElementId id) will return nothing. The ElementId.IntegerValue indicates the BuiltInParameter enum value. If the Parameter represents a shared, the call will return a SharedParameterElement. If normal, maybe just ParameterElement. Good enough!
What about Category then?
Its ElementId property will return nothing. Its IntegerValue indicates the BuiltInCategory enum value.
There are hundreds or even thousands of different objects in terms of Revit .NET API, so please be careful. Please do not take for granted that an ElementId always identifies some Element!
Recent Comments