当前位置:网站首页>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;
边栏推荐
- TCP/IP 协议栈
- DBSync新增对MongoDB、ES的支持
- [开源] .Net ORM 访问 Firebird 数据库
- Jerry's about TWS channel configuration [chapter]
- SAR image quality evaluation
- [open source] Net ORM accessing Firebird database
- 648. Word replacement
- 100million single men and women "online dating", supporting 13billion IPOs
- QT compile IOT management platform 39 alarm linkage
- Jerry's about TWS pairing mode configuration [chapter]
猜你喜欢
[JDBC Part 1] overview, get connection, CRUD
Remember aximp once Use of exe tool
Reinforcement learning - learning notes 9 | multi step TD target
The latest Android interview collection, Android video extraction audio
How to quickly check whether the opening area ratio of steel mesh conforms to ipc7525
[azure microservice service fabric] start the performance monitor in the SF node and set the method of capturing the process
Kirin Xin'an operating system derivative solution | storage multipath management system, effectively improving the reliability of data transmission
Pdf document signature Guide
Add get disabled for RC form
NVR硬盤錄像機通過國標GB28181協議接入EasyCVR,設備通道信息不顯示是什麼原因?
随机推荐
Jerry's about TWS pairing mode configuration [chapter]
Typescript TS basic knowledge type declaration
vite Unrestricted file system access to
Solve the problem of uni in uni app Request sent a post request without response.
[开源] .Net ORM 访问 Firebird 数据库
Jerry's fast pairing does not support canceling pairing [article]
Preparing for the interview and sharing experience
Dayu200 experience officer MPPT photovoltaic power generation project dayu200, hi3861, Huawei cloud iotda
Crawler (17) - Interview (2) | crawler interview question bank
Codemail auto collation code of visual studio plug-in
Use json Stringify() to realize deep copy, be careful, there may be a huge hole
23. Merge K ascending linked lists -c language
Pre sale 179000, hengchi 5 can fire? Product power online depends on how it is sold
Jerry's key to initiate pairing [chapter]
Implementation method of data platform landing
Debugging and handling the problem of jamming for about 30s during SSH login
Node:504 error reporting
Ternary expressions, generative expressions, anonymous functions
What is the difference between the three values of null Nan undefined in JS
The function is really powerful!