问题
Is it possible to rename families in a project through the API. We are recently updating and standardizing our family naming convention. I'd like to build an add-in that would rename the families in existing project to the new standard names. I haven't had any success finding an example of this online.
I’ve successfully been able to find all the family names, however, I can’t rename the family.
I’m using the C#.
回答1:
I tried the direct way with .Name property and seems to work.
UIApplication uiapp = commandData.Application;
UIDocument uidoc = uiapp.ActiveUIDocument;
Application app = uiapp.Application;
Document doc = uidoc.Document;
foreach(ElementId id in uidoc.Selection.GetElementIds())
{
FamilyInstance famInstance = doc.GetElement(id) as FamilyInstance;
if (famInstance == null) continue; //skip element
famInstance.Symbol.Name = famInstance.Symbol.Name + " - Changed";
}
回答2:
This is what I used
Element ff = doc2.GetElement({insert family id here});
var bar = (from x in familycollection where x.Name == ff.LookupParameter("Family Name").AsString() select x).FirstOrDefault();
exEvent.Raise()
来源:https://stackoverflow.com/questions/31414625/revit-family-rename-in-a-project