如何使用 Revit 创建倾斜墙 API?

How to create a Slanted wall with Revit API?

我正在尝试在 dynamo(Revit 2021) 中为自己开发脚本,但我不明白如何创建倾斜墙? 根据此blog of changes in revit 2021,,创建倾斜墙的参数有BuiltInParameter.WALL_CROSS_SECTION。但是,没有将它们用于现有参数或 类 的示例。所以在造线或造墙的阶段,我不明白具体用在什么地方,诉求是什么?

创建墙本身的代码部分,最后我尝试转向墙并将其方向参数更改为倾斜的,因为没有其他诉求。

import sys
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument

clr.AddReference('RevitAPI')
import Autodesk
from Autodesk.Revit.DB import *

clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion) 
# points for line
p_tp_1_1 =  XYZ(x_tp_1_1, y_tp1, levels.get_Parameter(BuiltInParameter.LEVEL_ELEV).AsDouble() + size_of_batten_1v_width)
p_tp_1_2 =  XYZ(x_tp_1_2, y_tp1, levels.get_Parameter(BuiltInParameter.LEVEL_ELEV).AsDouble() + size_of_batten_1v_width)
# Draw a line
wall_line_tp1 = Line.CreateBound(p_tp_1_1, p_tp_1_2)
# Create a Wall
wall_tp1 = Wall.Create(doc, wall_line_tp1, type.Id, levels.Id, h_tp_1, z_tp1, 0, 1)
wall_tp1.Orientation(BuiltInParameter.WALL_CROSS_SECTION(1))

如果有人遇到过这个,示例可以是C++或c#,我会尝试在python中进行适配。 并感谢您的帮助。

正如我在对 your question in The Revit API discussion forum 的回答中提到的,这里有一些 API 来自 The Building Coder 的示例和更新可能有用:

所以我自己想出来了。如果有人有同样的问题,有鳕鱼:

# Points
p_tp_1_1 =  XYZ(x_tp_1_1, y_tp1, levels.get_Parameter(BuiltInParameter.LEVEL_ELEV).AsDouble() + size_of_batten_1v_width)
p_tp_1_2 =  XYZ(x_tp_1_2, y_tp1, levels.get_Parameter(BuiltInParameter.LEVEL_ELEV).AsDouble() + size_of_batten_1v_width)
# Draw a line
wall_line_tp1 = Line.CreateBound(p_tp_1_1, p_tp_1_2)
# Create a Wall
wall_tp1 = Wall.Create(doc, wall_line_tp1, type.Id, levels.Id, h_tp_1, z_tp1, 0, 1)
# Here we get the parameter of the wall
cross_wall = Wall.get_Parameter(wall_tp1, BuiltInParameter.WALL_CROSS_SECTION)
# Set a value to the parameter ( 0 - slanted; 1 - vertical)
cross_wall.Set(0)
# assign the angle of the wall
angle_wall.get_Parameter(wall_tp1, BuiltInParameter.WALL_SINGLE_SLANT_ANGLE_FROM_VERTICAL)
# For example, we tilt it by 30 degrees: 
angle_wall.Set(0.30)