I was asked how to modify this line in https://boostyourbim.wordpress.com/2012/12/06/sometimes-in-order-to-create-you-have-to-destroy/ so that it will run in Revit 2012.
FamilyInstance famInst = doc.GetElement(id) as FamilyInstance;
In 2012, there was only one way to call the Document.GetElement method and that was with a reference.
In 2013, the input to GetElement can be a string (the element name), the element id, or the element reference. My code used the element id. This is fine for 2013 but not in 2012, where the input needs to be a reference.
Trying to compile the 2013 code in 2012 results in these errors.
Error 1 The best overloaded method match for 'Autodesk.Revit.DB.Document.GetElement(Autodesk.Revit.DB.Reference)' has some invalid arguments Error 2 Argument '1': cannot convert from 'Autodesk.Revit.DB.ElementId' to 'Autodesk.Revit.DB.Reference'
The solution here is to use the element id and the Document class’s Element property instead of the GetElement method.
FamilyInstance famInst = doc.get_Element(id) as FamilyInstance;
(Unlike most properties that can be called like Document.Element, this needs to be done as Document.get_Element)