zoukankan      html  css  js  c++  java
  • civil 3d 体积曲面提取等高线

    为了求两个曲面的交线,

    采用创建体积曲面并提取高程为0的等高线方法来迂回实现,

    因缺少.net api,

    不得不使用com api,

    对于不熟悉Com用法的朋友(比如我自己),

    可能会卡在这样那样的问题上,

    这些问题在网络上能搜索到的有效信息比较少,

    因而解决起来也比较麻烦。

    难点在于类型的转换,

    吃不准对象的类型,

    转换就会失败。

    private void CreateSurfaceIntersectionLines(ref List<Point2dCollection> ptss)
    {
        //获取曲面样式Id
        ObjectId volumeSurfaceStyleId = GetVolumeSurfaceStyleId();
        //创建体积曲面
        var volumeSurfaceId = TinVolumeSurface.Create("辅助体积曲面", egSurfaceId, gradingSurfaceId, volumeSurfaceStyleId);
        //获取Com对象
        AeccTinVolumeSurface aeccTVS = _comDoc.ObjectIdToObject((volumeSurfaceId.OldIdPtr).ToInt64()) as AeccTinVolumeSurface;
        //提取等高线
        IEnumerable contours = aeccTVS.ExtractContour(AeccDisplayOrientation.aeccDisplayOrientationPlan, AeccSurfaceFilterType.aeccSFMajorContours, 0, 0) as IEnumerable;
        //顶点集合,可能存在多条等高线,所以需要用集合
        //List<Point2dCollection> ptss = new List<Point2dCollection>();
        foreach (var contour in contours)
        {
            //转换为AcadLWPolyline,起初转为AcadPolyline,类型不对
            AcadLWPolyline pl = contour as AcadLWPolyline;
            if (pl != null)
            {
                Point2dCollection pts = new Point2dCollection();
                //坐标是以doulbe数组形式存储的
                double[] cors = pl.Coordinates as double[];
                for (int i = 0; i < cors.Length - 2; i += 2)
                {
                    pts.Add(new Point2d(cors[i], cors[i + 1]));
                }
                ptss.Add(pts);
                //删除多段线
                pl.Delete();
            }
        }
        //删除辅助体积曲面
        aeccTVS.Delete();
    }
    
  • 相关阅读:
    一句SQL实现MYSQL的递归查询
    人生不过一个字【Life is but a word】
    VS2008 如何将Release版本设置可以调试的DEBUG版本
    微软 2018 年第一笔收购:文件存储公司 Avere Systems
    设置系统时间
    OpenVZ安装指南,一种操作系统级别的虚拟化技术
    云平台DevOps实践
    路由(Routing)
    Ubuntu命令
    net mvc中angular
  • 原文地址:https://www.cnblogs.com/myzw/p/13100386.html
Copyright © 2011-2022 走看看