예제 #1
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));
        }
예제 #2
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));
        }
예제 #3
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));
        }