예제 #1
0
        /// <summary>
        /// 起点坐标,角度,长度 绘制直线
        /// </summary>
        /// <param name="db">图形数据库</param>
        /// <param name="startPoint">起点</param>
        /// <param name="length">长苏</param>
        /// <param name="degree">角度</param>
        /// <returns></returns>
        public static ObjectId AddLineToModeSpace(this Database db, Point3d startPoint, Double length, Double degree)
        {
            // 利用长度和角度以及起点 计算终点坐标
            double  X        = startPoint.X + length * Math.Cos(BaseTools.AngleToDegree(degree));
            double  Y        = startPoint.Y + length * Math.Sin(BaseTools.AngleToDegree(degree));
            Point3d endPoint = new Point3d(X, Y, 0);

            return(db.AddEntityToModeSpace(new Line(startPoint, endPoint)));
        }
예제 #2
0
        /// <summary>
        /// 绘制椭圆
        /// </summary>
        /// <param name="db">图形数据库</param>
        /// <param name="center">椭圆中心</param>
        /// <param name="majorRadius">长轴长度</param>
        /// <param name="shortRadius">短轴长度</param>
        /// <param name="degree">长轴与X夹角 角度值</param>
        /// <param name="startDegree">起始角度</param>
        /// <param name="endDegree">终止角度</param>
        /// <returns></returns>
        public static ObjectId AddEllipseToModeSpace(this Database db, Point3d center, double majorRadius, double shortRadius, double degree, double startDegree, double endDegree)
        {
            // 计算相关参数
            double   ratio     = shortRadius / majorRadius;
            Vector3d majorAxis = new Vector3d(majorRadius * Math.Cos(BaseTools.AngleToDegree(degree)), majorRadius * Math.Sin(BaseTools.AngleToDegree(degree)), 0);
            Ellipse  elli      = new Ellipse(center, Vector3d.ZAxis, majorAxis, ratio, BaseTools.DegreeToAngle(startDegree), BaseTools.DegreeToAngle(endDegree)); // VVector3d.ZAxis 等价于 new Vector3d(0,0,1) 平行于z轴法向量

            return(db.AddEntityToModeSpace(elli));
        }