控制台程序直接打开mxd放大缩小后获取不到当前比例尺了?

通过mxd获取的mapscale,没有mapcontrol、arcmap等图形界面;放大或缩小后,获取不到当前比例尺了
已邀请:

刘峥 - ArcGIS多面手

赞同来自:

【解决办法】:
如果程序中没有图形界面的话,需要先激活一下activeview,如: 


mapdoc = new MapDocumentClass(); 
mapdoc.Open(@G:\Untitled.mxd); 
actView = mapdoc.ActiveView; 
//激活 
actView.Activate(GetDesktopWindow()); 

IEnvelope currentEnv = actView.Extent; 
currentEnv.Expand(1.2, 1.2, true); 
actView.Extent = currentEnv; 
actView.Refresh(); 

double newscale = actView.FocusMap.MapScale; 
MessageBox.Show(newscale.ToString()); 


[System.Runtime.InteropServices.DllImport(user32.dll)] 

public extern static int GetDesktopWindow();

要回复问题请先登录注册