Ejemplo n.º 1
0
        /// <summary>
        /// 三点绘制圆弧
        /// </summary>
        /// <param name="db">图形数据库</param>
        /// <param name="startPoint3d">起点坐标</param>
        /// <param name="pointOnArc">圆弧上的点</param>
        /// <param name="endPoint3d">重点坐标</param>
        /// <returns></returns>
        public static ObjectId AddArcToModelSpace(this Database db, Point3d startPoint3d, Point3d pointOnArc, Point3d endPoint3d)
        {
            //判断三点是否在同一条直线上
            if (startPoint3d.IsOnOneLine(pointOnArc, endPoint3d))
            {
                Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
                ed.WriteMessage("3个顶点在同一条直线上,无法绘制圆弧");
                return(ObjectId.Null);
            }
            //创建几何对象
            CircularArc3d CArc = new CircularArc3d(startPoint3d, pointOnArc, endPoint3d);
            //获取几何对象的属性
            double  radius = CArc.Radius; //半径
            Point3d conter = CArc.Center; //圆心

            //Vector3d cs = conter.GetVectorTo(startPoint3d);//圆心与第一个点构成向量
            //Vector3d ce = conter.GetVectorTo(endPoint3d);//圆心与第二个点构成向量
            //Vector3d xVector = new Vector3d(1, 0, 0);//X正方向的向量

            ////获取角度
            //double startAngle = cs.Y>0 ? xVector.GetAngleTo(cs): -xVector.GetAngleTo(cs);//圆心与第一个点的角度
            //double endAngle = ce.Y>0 ? xVector.GetAngleTo(ce): -xVector.GetAngleTo(ce);//圆心与第二个点的角度
            //获取角度
            double startAngle = conter.GetAngle(startPoint3d);
            double endAngle   = conter.GetAngle(endPoint3d);
            //创建圆弧对象
            Arc arc = new Arc(conter, radius, startAngle, endAngle);

            return(AddEntityToModelSpace(db, arc));//添加到图形数据库中
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 根据圆心、起点、角度绘制圆弧
        /// </summary>
        /// <param name="db">图形数据库</param>
        /// <param name="center">圆心</param>
        /// <param name="startPoint3d">起点</param>
        /// <param name="degree">夹角值(角度值)</param>
        /// <returns></returns>
        public static ObjectId AddArcToModelSpace(this Database db, Point3d center, Point3d startPoint3d, double degree)
        {
            //获取半径
            double radius = center.GetDistanceBetweenToPoint(startPoint3d);
            //获取起始角度
            double startAngle = center.GetAngle(startPoint3d);
            //声明圆弧对象  //角度转换为弧度
            Arc arc = new Arc(center, radius, startAngle, startAngle + degree.DegreeToAngle());

            //添加到图形数据库中
            return(AddEntityToModelSpace(db, arc));
        }