• CAD创建不规则形状视口


    选择CAD模型空间中多段线,在指定的布局中创建视口,方法如下:

     1         /// <summary>
     2         /// 创建视口
     3         /// </summary>
     4         /// <param name="roundLine">模型空间多段线</param>
     5         /// <param name="curentLayout">当前布局名称</param>
     6         /// <param name="insertPoint">布局空间视口插入点</param>
     7         /// <param name="scale">缩放比例</param>
     8         private void MakeViewport(Polyline roundLine, string curentLayout, Point3d insertPoint, double scale)
     9         {
    10             Database db = HostApplicationServices.WorkingDatabase;
    11             using (Transaction tran = db.TransactionManager.StartTransaction())
    12             {
    13                 BlockTable bt = tran.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
    14                 BlockTableRecord btr = tran.GetObject(bt[BlockTableRecord.PaperSpace], OpenMode.ForWrite) as BlockTableRecord;
    15                
    16                 Polyline bound =  roundLine.Clone() as Polyline;
    17                 bound.Closed = true;
    18                 Point3d maxPoint = bound.GeometricExtents.MaxPoint;
    19                 Point3d minPoint = bound.GeometricExtents.MinPoint;
    20                 Point3d centerPoint = new Point3d((maxPoint.X + minPoint.X) / 2, (maxPoint.Y + minPoint.Y) / 2, 0);
    21                 bound.TransformBy(Matrix3d.Scaling(scale, centerPoint));
    22                 bound.TransformBy(Matrix3d.Displacement(centerPoint.GetVectorTo(insertPoint)));
    23                 btr.AppendEntity(bound);
    24                 tran.AddNewlyCreatedDBObject(bound, true);
    25 
    26                 Viewport vp = new Viewport();
    27                 btr.AppendEntity(vp);
    28                 tran.AddNewlyCreatedDBObject(vp, true);
    29                 vp.NonRectClipEntityId = bound.Id;
    30 
    31                 vp.CenterPoint = insertPoint;  //视口插入位置
    32                 vp.ViewCenter = new Point2d(centerPoint.X, centerPoint.Y); //模型空间中心位置
    33 
    34                 vp.ViewHeight = maxPoint.Y - minPoint.Y; //模型空间高度
    35                 vp.Height = scale * vp.ViewHeight;  //视口高度
    36                 vp.NonRectClipOn = true;
    37                 vp.Locked = true;
    38                 vp.On = true;
    39                 tran.Commit();
    40             }
    41         }
  • 相关阅读:
    kernel-devel-3.10.0-957.el7.x86_64.rpm kernel-headers-3.10.0-957.el7.x86_64.rpm
    解决MySQL安装:找不到msvcr120.dll和msvcp120.dll
    Node.js安装
    大数据电商数据仓库
    spark
    redis 脑裂等极端情况分析
    Redis解决并发超卖问题
    解决OutOfMemoryError: unable to create new native thread问题
    好用的java工具
    java初始化和实例化
  • 原文地址:https://www.cnblogs.com/oneday/p/3954385.html
Copyright © 2020-2023  润新知