예제 #1
0
        /// <summary>
        /// 设置UCS的原点
        /// </summary>
        /// <param name="ucsId">UCS的Id</param>
        /// <param name="pt">要设置的UCS原点坐标</param>
        public static void SetUCSOrigin(this ObjectId ucsId, Point3d pt)
        {
            Database db    = ucsId.Database;
            var      trans = db.TransactionManager;
            //打开UCS
            UcsTableRecord utr = trans.GetObject(ucsId, OpenMode.ForRead) as UcsTableRecord;

            if (utr == null)
            {
                return;          //若UCS不存在,则返回
            }
            utr.UpgradeOpen();   //切换UCS为写的状态
            utr.Origin = pt;     //设置UCS的原点
            utr.DowngradeOpen(); //为了安全,切换UCS为读的状态
        }
예제 #2
0
        /// <summary>
        /// 旋转UCS
        /// </summary>
        /// <param name="ucsId">UCS的Id</param>
        /// <param name="rotateAngle">旋转角度</param>
        /// <param name="rotateAxis">旋转轴</param>
        public static void RotateUCS(this ObjectId ucsId, double rotateAngle, Vector3d rotateAxis)
        {
            Database db    = ucsId.Database;
            var      trans = db.TransactionManager;
            //打开UCS
            UcsTableRecord utr = trans.GetObject(ucsId, OpenMode.ForRead) as UcsTableRecord;

            if (utr == null)
            {
                return;                 //若UCS不存在,则返回
            }
            utr.UpgradeOpen();          //切换UCS为写的状态
            Vector3d xAxis = utr.XAxis; //UCS的X轴方向
            Vector3d yAxis = utr.YAxis; //UCS的Y轴方向

            //旋转UCS
            utr.XAxis = xAxis.RotateBy(rotateAngle * Math.PI / 180, rotateAxis);
            utr.YAxis = yAxis.RotateBy(rotateAngle * Math.PI / 180, rotateAxis);
            utr.DowngradeOpen();//为了安全,切换UCS为读的状态
        }