首页 > 代码库 > CAD创建不规则形状视口
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 }
CAD创建不规则形状视口
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。