pyRevit开发:如何创建墙
作者:互联网
必看部分:
Document获取:
必看文章
基础部分:
创建墙
基本思路:
- 首先添加引用
- 获取当前项目文档
- 开启事务
- 获取墙类型
- 获取标高
- 创建
实现代码:
import Autodesk
from Autodesk.Revit.DB import FilteredElementCollector, BuiltInParameter, BuiltInCategory, Line, Wall, XYZ, Transaction
doc = __revit__.ActiveUIDocument.Document
levels = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Levels).WhereElementIsNotElementType().ToElements()
walls = FilteredElementCollector(doc).OfCategory(BuiltInCategory.OST_Walls).WhereElementIsElementType().ToElements()
for level in levels:
elevation = level.get_Parameter(BuiltInParameter.LEVEL_ELEV).AsDouble()
if elevation == 3000/304.8:
level_0 = level
for wall in walls:
name = wall.get_Parameter(BuiltInParameter.SYMBOL_NAME_PARAM).AsString()
if name == '常规 - 200mm':
wall_type = wall
p_1 = XYZ(0,0,level_0.Elevation)
p_2 = XYZ(50,0,level_0.Elevation)
p_3 = XYZ(50,50,level_0.Elevation)
line_1 = Line.CreateBound(p_1, p_2)
line_2 = Line.CreateBound(p_2, p_3)
lines = [line_1, line_2]
t = Transaction(doc, '创建墙')
t.Start()
for line in lines:
wall_1 = Wall.Create(doc, line, wall_type.Id, level_0.Id, 3000/304.8, 0, False, True)
t.Commit()
总结:
1.创建构件需要开启事务(Transaction)
2.确定标高及指定墙类型存在
欢迎大家添加交流QQ群: 17075104
一起学习
标签:level,wall,创建,XYZ,开发,pyRevit,doc,line,BuiltInCategory 来源: https://www.cnblogs.com/zedmoster/p/15263404.html