zoukankan      html  css  js  c++  java
  • 一种将Region转为Polyline的方法

    在AutoCAD.NET二次开发中,如果要将面域转为Polyline主要有以下几种方式:

    1、使用Explode将面域炸成Line和Arc,然后再串起来,此方法可用于AutoCAD2007开始的所有版本。

    参考:http://through-the-interface.typepad.com/through_the_interface/2008/08/creating-a-seri.html

    2、想办法获取Region内的一个点,使用CAD的BO命令重新创建边界,并监听命令结束事件,获取最后一个生成的实体。

    3、使用C#和Lisp配合开发,在Lisp中使用bpoly创建边界。

    4、使用AutoCAD.NET接口中的Editor.TracBoundary方法取得新边界,但此方法从AutoCAD2011开始有。

    5、使用Brep和Edge来获取Region子实体,这几个接口从AutoCAD2009开始才添加进来的,

    使用Brep来取得Region的每条边,然后再将这些边转为弧和线段对象,再进行串联,示例代码如下:

    引用acdbmgdbrep.dll

    PromptEntityResult per = ed.GetEntity("
    请选择");
                if (per.Status == PromptStatus.OK)
                {
                    using (DocumentLock dlk = doc.LockDocument())
                    {
                        using (Transaction trans = db.TransactionManager.StartTransaction())
                        {
                            Entity ent = (Entity)trans.GetObject(per.ObjectId, OpenMode.ForWrite);
                            if (!(ent is Region))
                                return;
                            Region reg = (Region)ent;
                            Brep brep = new Brep(reg);
                            BrepEdgeCollection bec = brep.Edges;
                            if (bec != null)
                            {
                                foreach (Edge edge in bec)
                                {
                                    Curve3d cv3d = edge.Curve;
                                    ExternalCurve3d ecv3d = (ExternalCurve3d)cv3d;
                                    if (ecv3d.IsCircularArc)
                                    {
                                        CircularArc3d ca3d = ecv3d.NativeCurve as CircularArc3d;
                                        ed.WriteMessage("");
                                    }
                                    else if (ecv3d.IsLine)
                                    {
                                        ed.WriteMessage("
    线");
                                    }
                                    else if (ecv3d.IsLineSegment)
                                    {
                                        LineSegment3d ls3d = ecv3d.NativeCurve as LineSegment3d;
                                        ed.WriteMessage("
    线段");
                                    }
                                    else if (ecv3d.IsNativeCurve)
                                    {
                                        ed.WriteMessage("
    原始曲线");
                                    }
                                    else if (ecv3d.IsNurbCurve)
                                    {
                                        ed.WriteMessage("
    样条曲线");
                                    }
                                    else
                                    {
                                        ed.WriteMessage("
    " + ecv3d.ExternalCurveKind);
                                    }
                                    ed.WriteMessage("
    起点:" + cv3d.StartPoint.ToString() + "-终点:" + cv3d.EndPoint.ToString());
                                }
                            }
                        }
                    }
                }
  • 相关阅读:
    Python--前端之HTML
    Python--MySql(主键的创建方式、存储引擎、存储过程、索引、pymsql)
    python--MySql(外键约束、多表查询(*****))
    python--MySql 表记录的操作
    python--MySql
    Python--线程队列(queue)、multiprocessing模块(进程对列Queue、管道(pipe)、进程池)、协程
    Python--同步锁(互斥锁)、死锁(状态)、递归锁、信号量、Event对象
    Python--多线程、多进程常用概念
    Python--基础之socket编程
    ubuntu 安装 flashplayer
  • 原文地址:https://www.cnblogs.com/bomb12138/p/5985600.html
Copyright © 2011-2022 走看看