描述
获取Revit模型的截面线、横切面线、截面轮廓。
用途
用于获取模型的截面线、横切面线、截面轮廓。
实现方式
- 创建视图平面;
- 从视图平面获取轮廓线;
- 获取平面标高处的截面线。
效果
示例
/// <summary>
/// 截面轮廓线
/// </summary>
[Transaction(TransactionMode.Manual)]
public class SectionProfileOfElement : IExternalCommand
{
public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
{
UIApplication uiapp = commandData.Application;
UIDocument uidoc = uiapp.ActiveUIDocument;
Document doc = uidoc.Document;
//截面高度
double height = 1000 / 304.8;
Transaction tran1 = new Transaction(doc, "创建平面轮廓线");
tran1.Start();
//创建临时平面
View view = CreateViewPlaneByHeight(doc, height);
tran1.Commit();
Transaction tran2 = new Transaction(doc, "创建平面轮廓线");
tran2.Start();
FilteredElementCollector collection = new FilteredElementCollector(doc, view.Id);
Options opt = new Options() { ComputeReferences = false, IncludeNonVisibleObjects = false, View = view };
//绘制轮廓线
List<Curve> curves = new List<Curve>();
foreach (Element elem in collection)
{
GeometryElement geo = elem.get_Geometry(opt);
GetEdgeLines(curves, geo);
}
foreach (var curve in curves)
{
try
{
CreateModeLinesInView(doc, new List<Curve> { curve }, view);
}
catch (Exception)
{
}
}
//删除临时创建的视图和标高
doc.Delete(view.GenLevel.Id);
tran2.Commit();
return Result.Succeeded;
}
源码及示例文件
全部源码获取关注微信号回复 “获取模型截面线源码” 。
关于笔者
我是旋转De陀螺,笔者将持续分享Revit二次开发思路及入门经验,感谢点赞、关注、留言、一键三连,获取更多分享。
- 微信公众号: BIM开发
- QQ群: 1009105743
- CSDN: 旋转De陀螺
- 知乎: 旋转De陀螺