Revit Family Rename in a project

大城市里の小女人 提交于 2021-02-08 08:33:25

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!