auto CAD .NET二次开发 之 视图操作(1)通过视图类型改变视图

来源:互联网 发布:阿里云小号 编辑:程序博客网 时间:2024/05/17 03:32

本文中的视图操作指,图档视角的操作。

实现操作视图的流程为:

1、获得当前视图

 ViewTableRecord vtr = ed.GetCurrentView();

2、设置观察点

  vtr.SetViewDirection(ov);

3、设置视图

   ed.SetCurrentView(vtr);

方法如下:

 public bool ViewChanged(OrthographicView ov)
        {
        
            bool resultView = false;
       
            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
        
            ViewTableRecord vtr = ed.GetCurrentView();
       
            try
            {
           
                vtr.SetViewDirection(ov);
               
         
                ed.SetCurrentView(vtr);
           
                resultView = true;
              
                Application.DocumentManager.MdiActiveDocument.SendStringToExecute("zoom e ", false, false, false);
            }
          
            catch
            {
            
                resultView = false;
            }
      
            finally
            {
                vtr.Dispose();
            }
         
            return resultView;
        }

 

 

上述方法的参数为:

 public enum OrthographicView
    {
        NonOrthoView = 0,
        TopView = 1,
        BottomView = 2,
        FrontView = 3,
        BackView = 4,
        LeftView = 5,
        RightView = 6,
    }

传入适当参数即可