当前位置:网站首页>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;
边栏推荐
- Node:504 error reporting
- [azure microservice service fabric] the service fabric cluster hangs up because the certificate expires (the upgrade cannot be completed, and the node is unavailable)
- Jerry's test box configuration channel [chapter]
- Restapi version control strategy [eolink translation]
- Talk about relational database and serverless
- Programming mode - table driven programming
- [interview arrangement] 0211 game engine server
- Debugging and handling the problem of jamming for about 30s during SSH login
- Remember aximp once Use of exe tool
- Jerry's initiation of ear pairing, reconnection, and opening of discoverable and connectable cyclic functions [chapter]
猜你喜欢
Vs custom template - take the custom class template as an example
反爬通杀神器
Ad domain group policy management
Remember aximp once Use of exe tool
【Azure微服务 Service Fabric 】在SF节点中开启Performance Monitor及设置抓取进程的方式
Display optimization when the resolution of easycvr configuration center video recording plan page is adjusted
How does win11 time display the day of the week? How does win11 display the day of the week today?
#DAYU200体验官#MPPT光伏发电项目 DAYU200、Hi3861、华为云IotDA
Px4 autonomous flight
Win11时间怎么显示星期几?Win11怎么显示今天周几?
随机推荐
Restapi version control strategy [eolink translation]
Debugging and handling the problem of jamming for about 30s during SSH login
强化学习-学习笔记9 | Multi-Step-TD-Target
OpenGL configuration vs2019
谈谈制造企业如何制定敏捷的数字化转型策略
Remember that a development is encountered in the pit of origin string sorting
Attitude estimation (complementary filtering)
Reinforcement learning - learning notes 9 | multi step TD target
Px4 autonomous flight
cv2.resize函数报错:error: (-215:Assertion failed) func != 0 in function ‘cv::hal::resize‘
Matplotlib快速入门
How does win11 unblock the keyboard? Method of unlocking keyboard in win11
建立自己的网站(18)
Display optimization when the resolution of easycvr configuration center video recording plan page is adjusted
SAR image quality evaluation
The difference between NPM uninstall and RM direct deletion
Crawler (17) - Interview (2) | crawler interview question bank
Relationship between URL and URI
你可曾迷茫?曾经的测试/开发程序员,懵懂的小菜C鸟升级......
Why can't win11 display seconds? How to solve the problem that win11 time does not display seconds?