示例#1
0
        ///<summary> This gets called when when the user runs this command.</summary>
        public override IRhinoCommand.result RunCommand(IRhinoCommandContext context)
        {
            MRhinoView view = RhUtil.RhinoApp().ActiveView();

            if (null == view)
            {
                return(IRhinoCommand.result.failure);
            }

            MRhinoViewport             vp = view.ActiveViewport();
            MRhinoDisplayPipeline      dp = view.DisplayPipeline();
            MDisplayPipelineAttributes da = view.DisplayAttributes();

            // Prevent capturing of the frame buffer on every update
            MRhinoDisplayPipeline.EnableFrameBufferCapture(false);
            // Prevent the draw list from updating on every frame
            dp.FreezeDrawing(true);

            int    dir         = 0; // 0 = Right, 1 = Left, 2 = Down, and 3 = Up
            int    frame_count = 100;
            double delta_angle = 5.0 * (Math.PI / 180.0);

            for (int i = 0; i < frame_count; i++)
            {
                switch (dir)
                {
                case 0:
                    vp.LeftRightRotate(delta_angle);
                    break;

                case 1:
                    vp.LeftRightRotate(-delta_angle);
                    break;

                case 2:
                    vp.DownUpRotate(delta_angle);
                    break;

                case 3:
                    vp.DownUpRotate(-delta_angle);
                    break;
                }
                //dp.DrawFrameBuffer(da);
                view.Redraw();
                RhUtil.RhinoApp().Wait(0);
            }

            dp.FreezeDrawing(false);
            MRhinoDisplayPipeline.EnableFrameBufferCapture(true);

            view.Redraw();

            return(IRhinoCommand.result.success);
        }