当前位置:网站首页>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;
边栏推荐
- Px4 autonomous flight
- OpenGL job - texture
- Open source OA development platform: contract management user manual
- #DAYU200体验官#MPPT光伏发电项目 DAYU200、Hi3861、华为云IotDA
- 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
- Dbsync adds support for mongodb and ES
- 反爬通杀神器
- Two methods of calling WCF service by C #
- Talk about relational database and serverless
- PKPM 2020 software installation package download and installation tutorial
猜你喜欢

Matplotlib快速入门

NVR硬盘录像机通过国标GB28181协议接入EasyCVR,设备通道信息不显示是什么原因?

cv2.resize函数报错:error: (-215:Assertion failed) func != 0 in function ‘cv::hal::resize‘

EasyCVR配置中心录像计划页面调整分辨率时的显示优化

Reinforcement learning - learning notes 9 | multi step TD target

建立自己的网站(18)

Blender exchange group, welcome to the water group ~
![[azure microservice service fabric] start the performance monitor in the SF node and set the method of capturing the process](/img/80/11c2b539c217ecd6ba55668d3e71e9.png)
[azure microservice service fabric] start the performance monitor in the SF node and set the method of capturing the process
![Jerry's about TWS channel configuration [chapter]](/img/94/fde5054fc412b786cd9864215e912c.png)
Jerry's about TWS channel configuration [chapter]

. Net automapper use
随机推荐
Relationship between URL and URI
Win11时间怎么显示星期几?Win11怎么显示今天周几?
Build your own website (18)
为什么Win11不能显示秒数?Win11时间不显示秒怎么解决?
如何选择合适的自动化测试工具?
Remember an experience of using selectmany
Tcp/ip protocol stack
使用 BlocConsumer 同时构建响应式组件和监听状态
Where is the big data open source project, one-stop fully automated full life cycle operation and maintenance steward Chengying (background)?
PKPM 2020软件安装包下载及安装教程
ByteDance Android interview, summary of knowledge points + analysis of interview questions
戴森官方直营店免费造型服务现已开放预约 先锋科技诠释护发造型理念,助力消费者解锁多元闪耀造型
三元表达式、各生成式、匿名函数
#DAYU200体验官#MPPT光伏发电项目 DAYU200、Hi3861、华为云IotDA
null == undefined
vite Unrestricted file system access to
Why can't win11 display seconds? How to solve the problem that win11 time does not display seconds?
Embedded development: how to choose the right RTOS for the project?
operator
MIT6.S081-Lab9 FS [2021Fall]