[英]How to create a Slanted wall with Revit API?
Im trying to develop script for myself in dynamo(Revit 2021), but I don't understand how can I create the slanted wall?我试图在发电机(Revit 2021)中为自己开发脚本,但我不明白如何创建倾斜的墙? According to this blog of changes in revit 2021, there are such parameters for creating inclined walls as BuiltInParameter.WALL_CROSS_SECTION.
根据这篇关于 revit 2021 更改的博客,用于创建倾斜墙的参数有 BuiltInParameter.WALL_CROSS_SECTION。 However, there are no examples of using them to existing parameters or classes.
但是,没有将它们用于现有参数或类的示例。 Therefore, I do not understand exactly where to use it at the stage of creating a line or wall and what should be the appeal?
因此,在创建线条或墙壁的阶段,我不明白在哪里使用它,应该有什么吸引力?
The part of the code where the wall itself is created, in the end I tried to turn to the wall and change its orientation parameter to an inclined one, because there are no other appeals.创建墙壁本身的代码部分,最后我尝试转向墙壁并将其方向参数更改为倾斜的,因为没有其他吸引力。
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))
If there is anyone who has encountered this, the example can be in C++ or c#, I will try to adapt it in python.如果有人遇到过这个,例子可以是C++或者c#,我会尝试在python中进行适配。 And thanks for any help.
并感谢您的帮助。
As I mentioned in my answer to your question in The Revit API discussion forum , here are some API samples and updates from The Building Coder that may be of use:正如我在 The Revit API 讨论论坛中对您的问题的回答中提到的,以下是来自 The Building Coder 的一些 API 示例和更新,它们可能有用:
So I figured it out on my own.所以我自己想通了。 If anybody have the same question, there is a cod:
如果有人有同样的问题,有一个鳕鱼:
# 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)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.