zoukankan      html  css  js  c++  java
  • 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         }
  • 相关阅读:
    Redis_配置文件
    Redis_数据使用
    QQ登录测试用例
    JMeter性能测试入门--偏重工具的使用
    浅说《测试用例》
    axure界面功能
    性能测试相关术语
    测试用例设计和测试环境搭建
    测试需求分析
    软件测试的过程
  • 原文地址:https://www.cnblogs.com/oneday/p/3954385.html
Copyright © 2011-2022 走看看