当前位置:网站首页>Creating host elements of Revit secondary development (doors and windows, etc.) (issue 14)
Creating host elements of Revit secondary development (doors and windows, etc.) (issue 14)
2022-04-21 12:51:00 【A seat in Wolong City, Tsing Yi】
All right, all right , Return theme : Today we'll learn about creating a host element :
Document.NewFamilyInstance Method (XYZ, FamilySymbol, Element, Level, StructuralType)
What is a host element ? That's a good question , The so-called bacteria parasitize your large intestine every day , Eating your Xiang with relish every day .
No problem , It's like this .
You're dead , They die , The same can be : Windows and doors are hosts , And the wall is the matrix on which they live .
Think about it. It tastes , Dinner echoed in my mouth .
It's disgusting , Let's change to the example of cooking : Every program is a delicacy , Now let's prepare the raw materials for this delicious dish !
- XYZ: Where are we going to put it ? Then put it at the origin !new XYZ(0, 0, 0)
- FamilySymbol: The family type we want to create Here we create a door M1221
FilteredElementCollector faaa = new FilteredElementCollector(doc);
faaa.OfClass(typeof(FamilySymbol));// Get all types
ElementId id = null;// Record type ID
foreach (FamilySymbol faa in faaa)// find M1221 This door type
{
if (faa.GetParameters(" Type the name ")[0].AsString().Contains("M1221"))
{
id = faa.Id;// Record the of the door ID
}
}
FamilySymbol fs = doc.GetElement(id) as FamilySymbol;// From him ID To get the door family type
These are as like as two peas. , The main thing is thinking and understanding API Oh .
Element: Let's create a wall here :
XYZ start = new XYZ(-10, 0, 0);// The starting point
XYZ end = new XYZ(10, 10, 0);// End
Line wallLine = Line.CreateBound(start, end);// Draw a straight line
Wall newWall = Wall.Create(doc, wallLine, wid, true);// Draw the wall (wid Is the elevation , Look at number 4 strip )
Level: This is the most trained , I won't repeat it !
foreach (Level ll in fil)// Find elevation
{
if (ll.Name.Contains(" First floor "))// Find the elevation of the first floor
{
le = ll;// Record the elevation
wid = new ElementId(ll.Id.IntegerValue);// Record the elevation ID
}
}
StructuralType: I talked about this last issue , Say it again ! This is the structure type , Remember to reference the structure type !using Autodesk.Revit.DB.Structure; Here we choose StructuralType.NonStructural, Because we are not structures .
Be on it , Start cooking ! Throw them all into the pot in order and stew , After all, Xiaobian is a great cook .
FilteredElementCollector fil = new FilteredElementCollector(doc);
fil.OfClass(typeof(Level));// Get elevation
FilteredElementCollector faaa = new FilteredElementCollector(doc);
faaa.OfClass(typeof(FamilySymbol));// Get all types
Level le = null;// Record the elevation
ElementId id = null;// Record type ID
ElementId wid = null;// Record the elevation ID
foreach (FamilySymbol faa in faaa)// find M1221 This door type
{
if (faa.GetParameters(" Type the name ")[0].AsString().Contains("M1221"))
{
id = faa.Id;// Record the of the door ID
}
}
FamilySymbol fs = doc.GetElement(id) as FamilySymbol;// From him ID To get the door family type
XYZ start = new XYZ(-10, 0, 0);// The starting point
XYZ end = new XYZ(10, 10, 0);// End
Line wallLine = Line.CreateBound(start, end);// Draw a straight line
foreach (Level ll in fil)// Find elevation
{
if (ll.Name.Contains(" First floor "))// Find the elevation of the first floor
{
le = ll;// Record the elevation
wid = new ElementId(ll.Id.IntegerValue);// Record the elevation ID
}
}
Wall newWall = Wall.Create(doc, wallLine, wid, true);// Draw the wall
FamilyInstance fa = doc.Create.NewFamilyInstance(new XYZ(0, 0, 0), fs, newWall, le, StructuralType.NonStructural);
All right. , Look at the cooked food !
版权声明
本文为[A seat in Wolong City, Tsing Yi]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204211247475591.html
边栏推荐
- Discussion on content and cost of elastic Architecture - Digital Architecture Design (3)
- 字段行相同则合并在另外一个字段sql 语句?
- The soul of the frame - Reflection
- 深入剖析Focal loss损失函数
- [SQL] sql19 finds the last of all employees_ Name and first_ Name and corresponding Dept_ name
- Controlling the release and introduction of rip routing based on Routing
- The second time Revit development elements are obtained
- C语言嵌套练习
- Revit二次开发——创建标高(第八期)
- 2022年监理工程师考试质量、投资、进度控制练习题及答案
猜你喜欢
随机推荐
[linked list] 148 Sort linked list
Go语言 反射
2020batjz Android Senior Engineer Interview Questions - multiple choice questions collection (with answer analysis)
Validation数据校验注解
Revit二次开发之创建宿主元素(门窗等)(第十四期)
2022年初级会计职称考试会计实务练习题及答案
A comprehensive understanding of static code analysis
2022年一级注册建筑师考试建筑物理与设备复习题及答案
利用Cisco配置VRRP(虚拟路由器冗余协议)
实例:用C#.NET手把手教你做微信公众号开发(7)--普通消息处理之位置消息
初始响应工具包
Repairing tables with SQL statements
2022年监理工程师合同管理练习题及答案
三、标签准备
选择排序法
AGP Transform API 被废弃意味着什么?
Revit二次开发之创建族实例(第十三期)
Pytroch 深度学习 跑CIFAR10数据集
Flowable activiti7 countersign
[SQL] sql19 finds the last of all employees_ Name and first_ Name and corresponding Dept_ name









