简体   繁体   English

如何在 Revit api c# 中将创建的墙类型转换为族文件

[英]How to convert a created wall type to a family file in revit api c#

I am working on a project in Revit API where I need to我正在 Revit API 中的一个项目中工作,我需要

  1. create wall,创建墙,
  2. create a new wall type with materials使用材料创建新的墙类型
  3. Add type parameters to wall and materials将类型参数添加到墙和材料
  4. Generate rfa file for the same生成相同的rfa文件

I did the first 3 parts, but when I filter to extract family我做了前 3 部分,但是当我过滤以提取家庭时

FilteredElementCollector collector = new FilteredElementCollector(doc);
Family famType = collector.OfClass(typeof(Family)).FirstOrDefault(x => x.Name == "Basic Wall") as Family;


This returns null. 这将返回 null。
So I tried with Family Instance since I also created the wall. 所以我尝试了家庭实例,因为我也创建了墙。
 List<FamilyInstance> list = new FilteredElementCollector(RevitData.Document).OfCategory(BuiltInCategory.OST_Walls).OfClass(typeof(FamilyInstance)).Cast<FamilyInstance>().ToList<FamilyInstance>();

But this also returned null 但这也返回了 null

In the attached image, the Project Browser, shows the "Test wall" in Basic Wall Family type. 在附加的图像中,项目浏览器显示了基本墙族类型的“测试墙”。

Can we actually extract wall type as.rfa? 我们真的可以将墙类型提取为.rfa 吗?

If this is possible, can someone guide me through this. 如果这是可能的,有人可以指导我完成这个。

Thank You 谢谢你

在此处输入图像描述

Walls are System Families and you cannot save them as a *.rfa File.墙是系统系列,您不能将它们保存为 *.rfa 文件。

Your collector is not working because you are using the wrong classes in the filter, the class Wall or WallType is the correct one.您的收集器无法正常工作,因为您在过滤器中使用了错误的类,class Wall 或 WallType 是正确的。

To exchange WallTypes between projects, you can transfer Project Standards -> Wall Types, however there is no API for that.要在项目之间交换 WallTypes,您可以传输 Project Standards -> Wall Types,但是没有 API。 As alternative you could use the method ElementTransformUtils.CopyElements() to copy the Wall or WallType, or try to regenerate the WallType in the target Document using an existing WallType and the Duplicate method setting all the Parameters as in the source Document.作为替代方案,您可以使用方法 ElementTransformUtils.CopyElements() 来复制 Wall 或 WallType,或者尝试使用现有的 WallType 和 Duplicate 方法在源文档中设置所有参数来重新生成目标文档中的 WallType。

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

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