将项目文件(.rvt)转换成族文件(.rfa), 项目中的系统族用这种方式转不了
1. 获取到项目中实例
2. 遍历实例记录属性/坐标/中心线等,并且将实例保存成.rfa格式文件
3. 加载一个空的族文件,并且把刚刚导出的实例全部加载到空的族文件中设置其属性/坐标等
4. 将族文件保存
//获取实例
FilteredElementCollector fec = new FilteredElementCollector(doc).ofClass(typeof(FamilyInstance));
fec.UnionWith(new FilteredElementCollector(doc).ofClass(typeof(HostObject))).ToElements();
//属性记录...
Dictionary<string,ParamaterSet> dicPara = new Dictionary<string,ParamaterSet>();
//导出路径
List<string> lstExportPath = new List<string>();
//把实例保存.rfa文件
if(elem is FamilyInstance)
{
Familyinstance ins = elem as Familyinstance;
Family family = ins.Symbol.Family;
Document insDoc = ins.EditFamily(family);
string sPath = "d:\\"+ins.Id+".rfa";
lstExportPath.Add(sPath);
insDoc.SaveAs("d:\\ins.rfa");
insDoc.Close(false);
dicPara.Add(sPath,ins.Paramters);
}
//加载一个空族并将实例加载 创建
Family fa = null;
using(Transaction trans = new Transaction(doc,

本文介绍了一种将Revit项目文件(.rvt)转换为族文件(.rfa)的方法,适用于系统族以外的实例。通过获取项目实例、记录属性、导出及重新加载到空白族文件来完成转换。
最低0.47元/天 解锁文章
1624

被折叠的 条评论
为什么被折叠?



