基于.net的CAD二次开发——返回两点之间的直线距离与获取指定实体对象

1 public static double getDistance(double x, double y, double x1, double y1)
2         {
3             double dis = 0;
4             double a = Math.Pow(x1 - x, 2);//求x的y次方
5             double b = Math.Pow(y1 - y, 2);
6             dis = Math.Sqrt(a + b);
7             return dis;
8         }
public static DBObject GetDBObject(ObjectId id)
        {
            Document doc = MgdAcApplication.DocumentManager.MdiActiveDocument;
            //Editor ed = MgdAcApplication.DocumentManager.MdiActiveDocument.Editor;
            using (Transaction trans = doc.TransactionManager.StartTransaction())
            {
                DBObject pline = trans.GetObject(id, OpenMode.ForRead);//数据库对象可读
                trans.Commit();
                return pline;
            }
        }

 

posted @ 2020-12-03 16:49  梦想是拥有一台帕加尼  阅读(856)  评论(0)    收藏  举报