Problem how catch event ViewScale

Problem how catch event ViewScale

Anonymous
Not applicable
466 Views
0 Replies
Message 1 of 1

Problem how catch event ViewScale

Anonymous
Not applicable
Hi all

Is it possible to catch or realize this event by .NET when change of viewscale or current scale comes (when i change scale through wheel of mouse or zoom in the toolbar )?

We tried that code but the event currentMap.CurrentScaleModified does't work.

Autodesk.Gis.Map.Project.ProjectModel AcMapProject = Autodesk.Gis.Map.HostMapApplicationServices.Application.ActiveProject
Autodesk.AutoCAD.DatabaseServices.ObjectId managerId = Autodesk.Gis.Map.DisplayManagement.DisplayManager.Create(AcMapProject ).MapManagerId(AcMapProject , true);
Autodesk.AutoCAD.DatabaseServices.Transaction tran = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database.TransactionManager.StartTransaction();
Autodesk.Gis.Map.DisplayManagement.MapManager manager = tran.GetObject(managerId, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForRead) as Autodesk.Gis.Map.DisplayManagement.MapManager;
string mapName = manager.Current; //Return Defaulf
Autodesk.Gis.Map.DisplayManagement.Map currentMap = tran.GetObject(manager.CurrentMapId, Autodesk.AutoCAD.DatabaseServices.OpenMode.ForRead) as Autodesk.Gis.Map.DisplayManagement.Map;

currentMap.CurrentScaleModified += new Autodesk.Gis.Map.DisplayManagement.CurrentScaleModifiedEventHandler(currentMap_CurrentScaleModified);

void currentMap_CurrentScaleModified(object sender, Autodesk.Gis.Map.DisplayManagement.CurrentScaleModifiedEventArgs e) {

AcEditor.WriteMessage(string.Format("\r\nCurrent ViewScale is: 1:{0}", e.NewScale));

}


And i tried to catch this event via SystemVariableChanged or SystemVariableChanging this:

Application.SystemVariableChanged += new SystemVariableChangedEventHandler(Application_SystemVariableChanged);
Application.SystemVariableChanging += new SystemVariableChangingEventHandler(Application_SystemVariableChanging);

void Application_SystemVariableChanging(object sender, Autodesk.AutoCAD.ApplicationServices.SystemVariableChangingEventArgs e) {

AcEditor.WriteMessage(string.Format("\r\nCurrent ViewScale is: 1:{0}", Autodesk.Gis.Map.Platform.AcMapMap.GetCurrentMap().GetViewScale()));
}

void Application_SystemVariableChanged(object sender, Autodesk.AutoCAD.ApplicationServices.SystemVariableChangedEventArgs e) {
AcEditor.WriteMessage(string.Format("\r\nCurrent ViewScale is: 1:{0}", Autodesk.Gis.Map.Platform.AcMapMap.GetCurrentMap().GetViewScale()));
}

but this doesn't work too, but i don't know why because when i change viewscale via wheel of mouse or zoom icon in toolbar and then i write VIEWSIZE or VIEWCTR to command editor so these system variables are changed.

Thank you very much for your advice Milan. Edited by: hokrm on Mar 9, 2010 12:23 PM
0 Likes
467 Views
0 Replies
Replies (0)