当前位置:网站首页>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;
边栏推荐
- . Net automapper use
- What if the win11u disk does not display? Solution to failure of win11 plug-in USB flash disk
- NVR硬盘录像机通过国标GB28181协议接入EasyCVR,设备通道信息不显示是什么原因?
- 客户案例|华律网,通过观测云大幅缩短故障定位时间
- Win11如何解禁键盘?Win11解禁键盘的方法
- Pdf document signature Guide
- L2:ZK-Rollup的现状,前景和痛点
- 用语雀写文章了,功能真心强大!
- 变量与常量
- 强化学习-学习笔记9 | Multi-Step-TD-Target
猜你喜欢
The latest Android interview collection, Android video extraction audio
Solve the problem of uni in uni app Request sent a post request without response.
Matplotlib快速入门
Matplotlib drawing interface settings
[azure microservice service fabric] how to transfer seed nodes in the service fabric cluster
使用 BlocConsumer 同时构建响应式组件和监听状态
如何实现横版游戏中角色的移动控制
Index summary (assault version)
cv2.resize函数报错:error: (-215:Assertion failed) func != 0 in function ‘cv::hal::resize‘
[azure microservice service fabric] start the performance monitor in the SF node and set the method of capturing the process
随机推荐
NVR硬盘录像机通过国标GB28181协议接入EasyCVR,设备通道信息不显示是什么原因?
Main functions of OS, Sys and random Standard Libraries
Pdf document signature Guide
如何选择合适的自动化测试工具?
Jerry's configuration of TWS cross pairing [article]
L'enregistreur de disque dur NVR est connecté à easycvr par le Protocole GB 28181. Quelle est la raison pour laquelle l'information sur le canal de l'appareil n'est pas affichée?
DNS series (I): why does the updated DNS record not take effect?
[open source] Net ORM accessing Firebird database
Application practice | the efficiency of the data warehouse system has been comprehensively improved! Data warehouse construction based on Apache Doris in Tongcheng digital Department
Google SEO external chain backlinks research tool recommendation
Index summary (assault version)
为什么Win11不能显示秒数?Win11时间不显示秒怎么解决?
大数据开源项目,一站式全自动化全生命周期运维管家ChengYing(承影)走向何方?
Remember that a development is encountered in the pit of origin string sorting
23. Merge K ascending linked lists -c language
OpenGL job - texture
如何选择合适的自动化测试工具?
双塔模型的最强出装,谷歌又开始玩起“老古董”了?
OpeGL personal notes - lights
Anti climbing killer