注册 登录
明经CAD社区 返回首页

鱼与熊掌的个人空间 http://bbs.mjtd.com/?7304311 [收藏] [复制] [分享] [RSS]

日志

.Net 实现Zoom

热度 1已有 1310 次阅读2015-8-10 23:58 |系统分类:应用

        public static void ZoomW(Point3d p1, Point3d p2 ,Editor ed)
        {
            Extents3d ext = GetExtens(p1, p2);
            Point3d p1x = ext.MinPoint;
            Point3d p2x = ext.MaxPoint;
            Point3d midP = p1x + (p2x - p1x) * 0.5;
            ViewTableRecord view =new ViewTableRecord();
            view.CenterPoint = new Point2d(midP.X, midP.Y);
            view.Height = p2x.Y - p1x.Y;
            view.Width = p2x.X - p1x.X;
            ed.SetCurrentView(view);
        }
        public static Extents3d GetExtens(params Point3d[] pts)
        {
            double Xmin, Ymin, Zmin, Xmax, Ymax, Zmax;
            Xmin = Ymin = Zmin = double.MaxValue;
            Xmax = Ymax = Zmax = double.MinValue;
            foreach (Point3d x in pts)
            {
                if (Xmin>x.X)
                {
                    Xmin = x.X;
                }
                if (Xmax<x.X)
                {
                    Xmax = x.X;
                }
                if (Ymin>x.Y)
                {
                    Ymin = x.Y;
                }
                if (Ymax<x.Y)
                {
                    Ymax = x.Y;
                }
                if (Zmin > x.Z)
                {
                    Zmin = x.Z;
                }
                if (Zmax < x.Z)
                {
                    Zmax = x.Z;
                }
            }
            return new Extents3d(new Point3d (Xmin,Ymin,Zmin),new Point3d(Xmax,Ymax,Zmax));
        }

路过

雷人

握手

鲜花

鸡蛋

发表评论 评论 (2 个评论)

回复 ivde 2015-9-18 17:53
public static Extents3d GetExtents(params Point3d[] pts)
        {
            var ext = new Extents3d();
            foreach (var point3D in pts)
            {
                ext.AddPoint(point3D);
            }
            return ext;
        }
回复 鱼与熊掌 2015-9-18 21:02
ivde: public static Extents3d GetExtents(params Point3d[] pts)
        {
            var ext = new Extents3d();
            foreach (var point3D in pts)
    ...
感谢关注  07版本的GetExtens有Bug

facelist doodle 涂鸦板

您需要登录后才可以评论 登录 | 注册

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-4-19 22:52 , Processed in 0.353014 second(s), 16 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部