当前位置:网站首页>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;
边栏推荐
- UWA问答精选
- Typescript TS basic knowledge type declaration
- Jerry's test box configuration channel [chapter]
- Google SEO external chain backlinks research tool recommendation
- 双塔模型的最强出装,谷歌又开始玩起“老古董”了?
- What is the difference between the three values of null Nan undefined in JS
- OpenGL configure assimp
- Interview question 01.02 Determine whether it is character rearrangement - auxiliary array algorithm
- How to realize the movement control of characters in horizontal game
- [interview arrangement] 0211 game engine server
猜你喜欢

Index summary (assault version)

. Net automapper use

Kirin Xin'an operating system derivative solution | storage multipath management system, effectively improving the reliability of data transmission

Open source OA development platform: contract management user manual

Debugging and handling the problem of jamming for about 30s during SSH login

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?

Crawler (17) - Interview (2) | crawler interview question bank

嵌入式开发:如何为项目选择合适的RTOS?

Display optimization when the resolution of easycvr configuration center video recording plan page is adjusted

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?
随机推荐
Anti climbing killer
How to turn on win11 game mode? How to turn on game mode in win11
Jerry's configuration of TWS cross pairing [article]
【Azure微服务 Service Fabric 】因证书过期导致Service Fabric集群挂掉(升级无法完成,节点不可用)
Jerry's about TWS pairing mode configuration [chapter]
23. Merge K ascending linked lists -c language
UWA问答精选
强化学习-学习笔记9 | Multi-Step-TD-Target
Jerry's initiation of ear pairing, reconnection, and opening of discoverable and connectable cyclic functions [chapter]
ByteDance Android interview, summary of knowledge points + analysis of interview questions
L2:ZK-Rollup的现状,前景和痛点
Matplotlib drawing interface settings
The free styling service of Dyson's official direct store is now open for appointment. Pioneer Technology interprets the styling concept of hair care and helps consumers unlock diversified and shiny s
Preparing for the interview and sharing experience
2022 how to evaluate and select low code development platforms?
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?
Why can't win11 display seconds? How to solve the problem that win11 time does not display seconds?
Kaggle-Titanic
MIT6.S081-Lab9 FS [2021Fall]
The difference between NPM uninstall and RM direct deletion