当前位置:网站首页>Revit secondary development - project file to family file
Revit secondary development - project file to family file
2022-07-07 22:22:00 【Hey, hey, hey, hey, hey】
Project file (.rvt) Convert to family file (.rfa), The system family in the project cannot be transferred in this way
1. Get the instance in the project
2. Traverse instance record properties / coordinate / Centerline, etc , And save the instance as .rfa Format file
3. Load an empty family file , And load all the just exported instances into the empty family file to set their properties / Coordinates, etc
4. Save the family file
// Get instance
FilteredElementCollector fec = new FilteredElementCollector(doc).ofClass(typeof(FamilyInstance));
fec.UnionWith(new FilteredElementCollector(doc).ofClass(typeof(HostObject))).ToElements();
// Property record ...
Dictionary<string,ParamaterSet> dicPara = new Dictionary<string,ParamaterSet>();
// export path
List<string> lstExportPath = new List<string>();
// Save the instance .rfa file
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);
}
// Load an empty family and load the instance establish
Family fa = null;
using(Transaction trans = new Transaction(doc,"load"))
{
trans.start();
try
{
doc.LoadFamily("",familyLoadOption,out fa);
trans.Commit();
}
catch
{
trans.RollBack();
}
}
// Traverse lstExportPath establish
Document fDoc = doc.EditFamily(fa);
foreach(string path in lstExportPath)
{
Family loadFamily;
FamilySymbol fs = null;
fDoc.LoadFamily(path,familyLoadOption,out loadFamily);
ISet<ElementId> symbolIds = loadFamily.GetFamilySymbolIds();
foreach(Elementid symbolId in symbolIds)
{
fs = fDoc.GetElement(symbolId) as FamilySymbol;
if(fs == null) Continue;
if(!fs.IsActive) { fs.Activate(); break; }
}
if(fs == null) Comtinue;
// Here we create point based instances , Line / Noodles Anyway, this method
fDoc.FamilyCreate.NewFamilyInstance( Recorded coordinates ,fs,StructuralType.NoStructural);
// Set properties , Rotation Angle Math.PI / 180 * Recorded angle
...
...
...
}
// Just save it after you create it
fDoc.SaveAs(" route ");
fDoc.Close(false);
It's tiring to beat your heart with your hands , Function is not difficult , I wrote a general .
I hope that helps .
------------------------------------------------------------------------------------------ Update -----------------------------------------------------------------------------------------------------------------------------
Forget to consider the built-in model , Just in Save the instance in the project as rfa When you file Add a judgment
if(!family.IsEditable) continue;
边栏推荐
- Main functions of OS, Sys and random Standard Libraries
- 海外代理推荐
- Restapi version control strategy [eolink translation]
- NVR hard disk video recorder is connected to easycvr through the national standard gb28181 protocol. What is the reason why the device channel information is not displayed?
- 【JDBC Part 1】概述、获取连接、CRUD
- Which financial products will yield high returns in 2022?
- [colmap] sparse reconstruction is converted to mvsnet format input
- ByteDance senior engineer interview, easy to get started, fluent
- Two methods of calling WCF service by C #
- 2022 how to evaluate and select low code development platforms?
猜你喜欢

NVR hard disk video recorder is connected to easycvr through the national standard gb28181 protocol. What is the reason why the device channel information is not displayed?

如何选择合适的自动化测试工具?

Pre sale 179000, hengchi 5 can fire? Product power online depends on how it is sold

双塔模型的最强出装,谷歌又开始玩起“老古董”了?

Vs custom template - take the custom class template as an example

OpenGL configuration vs2019

Win11如何解禁键盘?Win11解禁键盘的方法

Paint basic graphics with custompaint

Two methods of calling WCF service by C #

使用 CustomPaint 绘制基本图形
随机推荐
Preparing for the interview and sharing experience
Application practice | the efficiency of the data warehouse system has been comprehensively improved! Data warehouse construction based on Apache Doris in Tongcheng digital Department
Embedded development: how to choose the right RTOS for the project?
Solve the problem of uni in uni app Request sent a post request without response.
OpenGL configure assimp
The whole network "chases" Zhong Xuegao
PKPM 2020 software installation package download and installation tutorial
MIT6.S081-Lab9 FS [2021Fall]
Anti climbing killer
Remove the default background color of chrome input input box
Ad domain group policy management
npm uninstall和rm直接删除的区别
变量与常量
如何选择合适的自动化测试工具?
Codemail auto collation code of visual studio plug-in
Use json Stringify() to realize deep copy, be careful, there may be a huge hole
Build your own website (18)
The essence of analog Servlet
#DAYU200体验官#MPPT光伏发电项目 DAYU200、Hi3861、华为云IotDA
【Azure微服务 Service Fabric 】在SF节点中开启Performance Monitor及设置抓取进程的方式