描述
获取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;
}
备注
你好啊,我是旋转の陀螺,欢迎关注我的博客,笔者将持续分享Revit二次开发思路及入门经验;
- 关注微信公众号: BIM开发 回复 “获取模型截面线源码” 获取源码。
- 欢迎加入Revit二次开发交流群,获取更多分享资料,群号:1009105743 。
- 知乎:旋转De陀螺