简体   繁体   English

项目中的Revit Family重命名

[英]Revit Family Rename in a project

Is it possible to rename families in a project through the API. 是否可以通过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#. 我正在使用C#。

I tried the direct way with .Name property and seems to work. 我尝试使用.Name属性的直接方法,并且似乎可以工作。

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";
}

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()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM