RevitAPI: 如何获取点云PointCloud数据?

通过Revit菜单的“插入>点云"操作,可以把点云数据插入到Revit中,那么如何才能获得导入的这些点云数据呢?

通过使用RevitLookup查看到,点云数据在RevitAPI中表现为PointCloudInstance,再看PointCloudInstance有个方法叫GetPoints(),这个方法就是我们想要的。


GetPoints()有三个参数

public PointCollection GetPoints(PointCloudFilter filter, double averageDistance, int numPoints);

averageDistance表示最小点距离,这个值越小,在一定范围内返回的点越多。

numPoints表示返回点的最大数量

filter是一个过滤器,通过条件来过滤哪些点被返回。

问题就在于如何创建filter,经过查找发现PointCloudFilter这个类没有构造函数,也没有静态的Create函数,也无法通过Document.Create或者Application.Create来创建,不过我们找到了PointCloudFilterFactory类的CreateMultiPlaneFilter函数,

public static PointCloudFilter CreateMultiPlaneFilter(IList<Autodesk.Revit.DB.Plane> planes);
public static PointCloudFilter CreateMultiPlaneFilter(IList<Autodesk.Revit.DB.Plane> planes, int exactPlaneCount);

planes:一系列的面,过滤出所有位于这些面正方向的点。可以理解为这些面形成一个包围区域,返回包围区域内的点。包围区域可以是非闭合的。

exactPlaneCount:精确匹配的面的个数。数字越大,匹配月精确,同时速度越慢。不指定该数值,则默认是planes的数量。

下面的代码展示如何使用过滤出一个方盒内的点。

if (pointCloudInstance != null)
{
    int SIZE = 100;
    List<Plane> planes = new List<Plane>();
    var min = new XYZ(-SIZE,-SIZE, -SIZE);
    var max = new XYZ(SIZE, SIZE, SIZE);

    //x planes
    planes.Add(new Plane(XYZ.BasisX, min));
    planes.Add(new Plane(-XYZ.BasisX, max));

    //y planes
    planes.Add(new Plane(XYZ.BasisY, min));
    planes.Add(new Plane(-XYZ.BasisY, max));

    //z planes
    planes.Add(new Plane(XYZ.BasisZ, min));
    planes.Add(new Plane(-XYZ.BasisZ, max));

    PointCloudFilter pcf = PointCloudFilterFactory.CreateMultiPlaneFilter(planes);
    var points = pointCloudInstance.GetPoints(pcf, 1, 100000);
}


  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值