Beispiel #1
0
        /// <summary>
        /// 两点绘制圆
        /// </summary>
        /// <param name="db">图形数据库</param>
        /// <param name="point1">第一个电</param>
        /// <param name="point2">第二个点</param>
        /// <returns></returns>
        public static ObjectId AddCircleModeSpace(this Database db, Point3d point1, Point3d point2)
        {
            // 获取两点的中心点
            Point3d center = point1.GetCenterPointBetweenTwoPoint(point2);
            // 获取半径
            double radius = point1.GetDistanceBetweenTwoPoint(center);

            return(db.AddCircleModeSpace(center, radius));
        }
Beispiel #2
0
        /// <summary>
        /// 两点绘制圆(两点的中心为圆心)
        /// </summary>
        /// <param name="db">图形数据库</param>
        /// <param name="point1">起点</param>
        /// <param name="point2">终点</param>
        /// <returns>对象Id</returns>
        public static ObjectId AddCircleToModelSpace(this Database db, Point3d point1, Point3d point2)
        {
            //获取中心点
            Point3d centerPoint = point1.GetCenterPointBetweenTwoPoint(point2);
            //获取半径
            double radius = centerPoint.GetDistanceBetweenToPoint(point1);

            return(AddCircleToModelSpace(db, centerPoint, radius));
        }
Beispiel #3
0
        /// <summary>
        /// 绘制椭圆
        /// </summary>
        /// <param name="db">图形数据库</param>
        /// <param name="majorRadius1">长轴端点1</param>
        /// <param name="majorRadius2">长轴端点2</param>
        /// <param name="shortRadius">短轴的长度</param>
        /// <returns>ObjectId</returns>
        public static ObjectId AddEllipseToModelSpace(this Database db, Point3d majorRadius1, Point3d majorRadius2, double shortRadius)
        {
            Point3d center = majorRadius1.GetCenterPointBetweenTwoPoint(majorRadius2);
            //获取短轴与长轴的比例 不能大于1 否则会生成原点的一个圆形
            double   ratio     = (2 * shortRadius) / majorRadius1.GetDistanceBetweenToPoint(majorRadius2);
            Vector3d MajorAxis = majorRadius1.GetVectorTo(center);
            Ellipse  ellipse   = new Ellipse(center, Vector3d.ZAxis, MajorAxis, ratio, 0, 2 * Math.PI);

            return(AddEntityToModelSpace(db, ellipse));
        }
Beispiel #4
0
        /// <summary>
        /// 绘制椭圆 两点
        /// </summary>
        /// <param name="db"></param>
        /// <param name="point1">所在矩形的顶点</param>
        /// <param name="point2">所在矩形的顶点2</param>
        /// <returns></returns>
        public static ObjectId AddEllipseToModeSpace(this Database db, Point3d point1, Point3d point2)
        {
            // 椭圆圆心
            Point3d center = point1.GetCenterPointBetweenTwoPoint(point2);

            double   ratio       = Math.Abs((point1.Y - point2.Y) / (point1.X - point2.X));
            Vector3d majorVector = new Vector3d(Math.Abs((point1.X - point2.X)) / 2, 0, 0);
            // 声明椭圆对象
            Ellipse elli = new Ellipse(center, Vector3d.ZAxis, majorVector, ratio, 0, 2 * Math.PI);

            return(db.AddEntityToModeSpace(elli));
        }
Beispiel #5
0
        /// <summary>
        /// 三点绘制椭圆
        /// </summary>
        /// <param name="db">图形数据库</param>
        /// <param name="majorPoint1">长轴端点1</param>
        /// <param name="majorPoint2">长轴端点2</param>
        /// <param name="shortRadius">短轴的长度</param>
        /// <returns>ObjectId</returns>
        public static ObjectId AddEllipseToModeSpace(this Database db, Point3d majorPoint1, Point3d majorPoint2, double shortRadius)
        {
            // 椭圆圆心
            Point3d center = majorPoint1.GetCenterPointBetweenTwoPoint(majorPoint2);
            // 短轴与长轴的比例
            double ratio = 2 * shortRadius / majorPoint1.GetDistanceBetweenTwoPoint(majorPoint2);
            // 长轴的向量
            Vector3d majorAxis = majorPoint2.GetVectorTo(center);
            Ellipse  elli      = new Ellipse(center, Vector3d.ZAxis, majorAxis, ratio, 0, 2 * Math.PI);

            return(db.AddEntityToModeSpace(elli));
        }
Beispiel #6
0
        /// <summary>
        /// 绘制椭圆(矩形内切圆)
        /// </summary>
        /// <param name="db"></param>
        /// <param name="point1">矩形对角顶点1</param>
        /// <param name="point2">矩形对角顶点1</param>
        /// <returns>ObjectId</returns>
        public static ObjectId AddEllipseToModelSpace(this Database db, Point3d point1, Point3d point2)
        {
            //获取圆心点
            Point3d center = point1.GetCenterPointBetweenTwoPoint(point2);
            //获取长轴与短轴的长度
            double major_Y = Math.Abs(point1.Y - point2.Y);
            double major_X = Math.Abs(point1.X - point2.X);
            //设置短轴与长轴的比例  不能大于1
            double   ratio     = major_Y / major_X;
            Vector3d MajorAxis = new Vector3d(major_X, 0, 0);

            if ((major_Y / major_X) > 1)
            {
                ratio     = major_X / major_Y;
                MajorAxis = new Vector3d(0, major_Y, 0);
            }
            Ellipse ellipse = new Ellipse(center, Vector3d.ZAxis, MajorAxis, ratio, 0, 2 * Math.PI);

            return(AddEntityToModelSpace(db, ellipse));
        }