当前位置:网站首页>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;
边栏推荐
- 100million single men and women "online dating", supporting 13billion IPOs
- Leetcode SQL first day
- Get the exact offset of the element
- operator
- ByteDance Android interview, summary of knowledge points + analysis of interview questions
- JS number is insufficient, and 0 is added
- Matplotlib快速入门
- 建立自己的网站(18)
- Reptile combat (VII): pictures of the king of reptiles' heroes
- How does win11 unblock the keyboard? Method of unlocking keyboard in win11
猜你喜欢
Use json Stringify() to realize deep copy, be careful, there may be a huge hole
双塔模型的最强出装,谷歌又开始玩起“老古董”了?
Embedded development: how to choose the right RTOS for the project?
2022 how to evaluate and select low code development platforms?
Two methods of calling WCF service by C #
Node:504 error reporting
An in-depth understanding of fp/fn/precision/recall
Jerry's initiation of ear pairing, reconnection, and opening of discoverable and connectable cyclic functions [chapter]
Two kinds of updates lost and Solutions
【Azure微服务 Service Fabric 】因证书过期导致Service Fabric集群挂掉(升级无法完成,节点不可用)
随机推荐
It's worth seeing. Interview sites and interview skills
OpenGL configure assimp
Dayu200 experience officer MPPT photovoltaic power generation project dayu200, hi3861, Huawei cloud iotda
Tsconfig of typescript TS basics JSON configuration options
PKPM 2020 software installation package download and installation tutorial
[azure microservice service fabric] start the performance monitor in the SF node and set the method of capturing the process
vite Unrestricted file system access to
The whole network "chases" Zhong Xuegao
Matplotlib drawing interface settings
cv2.resize函数报错:error: (-215:Assertion failed) func != 0 in function ‘cv::hal::resize‘
Remove the default background color of chrome input input box
Use json Stringify() to realize deep copy, be careful, there may be a huge hole
23. Merge K ascending linked lists -c language
[JDBC Part 1] overview, get connection, CRUD
[开源] .Net ORM 访问 Firebird 数据库
JS number is insufficient, and 0 is added
An in-depth understanding of fp/fn/precision/recall
Preparing for the interview and sharing experience
如何选择合适的自动化测试工具?
Win11U盘不显示怎么办?Win11插U盘没反应的解决方法