2027 Method
Changes 0
M

Document.EditFamily

Description:
Gets the document of a loaded family to edit.
Remarks:
This creates an independent copy of the family for editing. To apply the changes back to the family stored in the document, use the LoadFamily overload accepting IFamilyLoadOptions.

This method may not be called if the document is currently modifiable (has an open transaction) or is in a read-only state. The method may not be called during dynamic updates. To test the document's current status, check the values of IsModifiable and IsReadOnly properties.

public Document EditFamily(
	Family loadedFamily
)
  • loadedFamily
    The loaded family in current document.
Return Value Document Reference of the document of the family.
public void GetLoadedSymbols(Autodesk.Revit.DB.Document document, FamilyInstance familyInstance)
{
    if (null != familyInstance.Symbol)
    {
        // Get family associated with this
        Family family = familyInstance.Symbol.Family;

        // Get Family document for family
        Document familyDoc = document.EditFamily(family);
        if (null != familyDoc && familyDoc.IsFamilyDocument == true)
        {
            String loadedFamilies = "FamilySymbols in " + family.Name + ":\n";
            FilteredElementCollector collector = new FilteredElementCollector(document);
            ICollection<Element> collection = 
                collector.OfClass(typeof(FamilySymbol)).ToElements();
            foreach (Element e in collection)
            {
                FamilySymbol fs = e as FamilySymbol;
                loadedFamilies += "\t" + fs.Name + "\n";
            }

            TaskDialog.Show("Revit",loadedFamilies);
        }
    }
}