欢迎来到我的博客
Civil 3D开发与应用,欢迎加入QQ群:484124761
AutoCAD开发,欢迎加入QQ群:193522571

如何获取Civil 3d视口类型

在AU社区中搜索到的帖子
留存备忘。

代码复制至此:

    public static class ViewportExtensions
    {
        /// <summary>
        /// Returns the Viewort type:
        /// 0 = undefined,
        /// 1 = Plan,
        /// 2 = Profile,
        /// 3 = Section
        /// </summary>
        /// <param name="vp"></param>
        /// <returns></returns>
        public static short GetViewportType(this Viewport vp)
        {
            short vptype = 0;
            var xArray = vp.XData.AsArray();
            int i = -1;
            foreach (TypedValue tv in xArray)
            {
                i++;
                try
                {
                    if ((string)tv.Value == "AeccPlanProd50ViewportType")
                    {
                        vptype = (short)xArray[i + 1].Value;
                        break;
                    }
                }
                catch { }
            }
            return vptype;
        }

感谢Jeff_M!

posted @ 2022-02-21 08:45  david96007  阅读(81)  评论(0编辑  收藏  举报