Пример #1
0
 public void RotateView(Document doc, ScreenAxisRotation axis)
 {
 }
Пример #2
0
        public void TestViewDir(ScreenAxisRotation axis)
        {
            Document        doc = AcadApp.DocumentManager.MdiActiveDocument;
            ViewTableRecord vtr = doc.Editor.GetCurrentView();

            Vector3d dirVectorInitial = vtr.ViewDirection;
            Vector3d sideVectorAxis   = dirVectorInitial.GetPerpendicularVector();

            // If there is existing ViewTwist angle
            // rotate the side vector with that angle
            // so it will coincide with the side vector
            if (vtr.ViewTwist > 1e-6)
            {
                sideVectorAxis = sideVectorAxis.RotateBy(-vtr.ViewTwist, dirVectorInitial);
            }
            Vector3d upVectorAxis = dirVectorInitial.CrossProduct(sideVectorAxis).GetNormal();

            Vector3d axisRotation = new Vector3d();

            switch (axis)
            {
            case ScreenAxisRotation.SideAxis:
                axisRotation = sideVectorAxis;
                break;

            case ScreenAxisRotation.UpAxis:
                axisRotation = upVectorAxis;
                break;

            case ScreenAxisRotation.Twist:
                break;

            default:
                break;
            }

            double angle5deg = 0.0872664626;

            for (int i = 0; i < 72; i++)
            {
                Thread.Sleep(50);

                // By X axis
                vtr.ViewDirection = vtr.ViewDirection.RotateBy(angle5deg, sideVectorAxis);
                upVectorAxis      = upVectorAxis.RotateBy(angle5deg, sideVectorAxis);
                vtr.ViewTwist     = AutoCADManager.CalcViewTwist(doc, vtr);
                doc.Editor.SetCurrentView(vtr);

                // By Y axis
                vtr.ViewDirection = vtr.ViewDirection.RotateBy(angle5deg, upVectorAxis);
                sideVectorAxis    = sideVectorAxis.RotateBy(angle5deg, upVectorAxis);
                vtr.ViewTwist     = AutoCADManager.CalcViewTwist(doc, vtr);
                doc.Editor.SetCurrentView(vtr);

                doc.Editor.Regen();
            }

            angle5deg *= -1;
            for (int i = 72; i > 0; i--)
            {
                Thread.Sleep(50);

                // By Y axis
                vtr.ViewDirection = vtr.ViewDirection.RotateBy(angle5deg, upVectorAxis);
                sideVectorAxis    = sideVectorAxis.RotateBy(angle5deg, upVectorAxis);
                vtr.ViewTwist     = AutoCADManager.CalcViewTwist(doc, vtr);
                doc.Editor.SetCurrentView(vtr);

                // By X axis
                vtr.ViewDirection = vtr.ViewDirection.RotateBy(angle5deg, sideVectorAxis);
                upVectorAxis      = upVectorAxis.RotateBy(angle5deg, sideVectorAxis);
                vtr.ViewTwist     = AutoCADManager.CalcViewTwist(doc, vtr);
                doc.Editor.SetCurrentView(vtr);

                doc.Editor.Regen();
            }
        }