By Daniel Du

在Map 3D Geospatial Platform API中,AcMapMap.GroupModified 和AcMapMap.LayerModified 事件的参数类型由AcMapMappingEventArgs 变成了AcMapMapObjectModifiedEventArgs. 这个变化主要是在参数中增加了一个Modification 属性。通过这个属性我们可以判断是什么东西发生了变化。Modification 可能的取值是:

      /// <summary>

      /// Name property changed during the event.

      ///</summary>

      static const INT32 Name               = 1;

      /// <summary>

      /// Visibility changed during the event.

      ///</summary>

      static const INT32 Visibility         = 2;

      /// <summary>

      /// Layer selectability during the event.

      ///</summary>

      static const INT32 LayerSelectability = 4;

      /// <summary>

      /// Parent changed during the event.

      ///</summary>

      static const INT32 ParentChanged      = 8;

 

下面是如何使用的示例代码:

 

[CommandMethod("ListenToLayerChange")]

public void ListenToLayerChange()

{

  AcMapMap currentMap = AcMapMap.GetCurrentMap();

  currentMap.GroupModified +=

    new GroupModifiedHandler(currentMap_GroupModified);

  currentMap.LayerModified +=

    new LayerModifiedHandler(currentMap_LayerModified);

 

}

 

void currentMap_LayerModified(object sender,

                              AcMapMapObjectModifiedEventArgs args)

{

  OutputChanges(args.Modification);

}

void currentMap_GroupModified(object sender,

                              AcMapMapObjectModifiedEventArgs args)

{

  OutputChanges(args.Modification);

}

 

private static void OutputChanges(int modification)

{

  Editor ed = Autodesk.AutoCAD.ApplicationServices.Application

    .DocumentManager.MdiActiveDocument.Editor;

 

  ///// <summary>

  ///// Name property changed during the event.

  /////</summary>

  //static const INT32 Name               = 1;

  ///// <summary>

  ///// Visibility changed during the event.

  /////</summary>

  //static const INT32 Visibility         = 2;

  ///// <summary>

  ///// Layer selectability during the event.

  /////</summary>

  //static const INT32 LayerSelectability = 4;

  ///// <summary>

  ///// Parent changed during the event.

  /////</summary>

  //static const INT32 ParentChanged      = 8;

  switch (modification)

  {

    case 1:

      ed.WriteMessage("\n Layer or LayerGroup name is changed.");

      break;

 

    case 2:

      ed.WriteMessage(" \nLayer or LayerGroup Visibility  is changed.");

      break;

 

    case 4:

      ed.WriteMessage(" \nLayer or LayerGroup LayerSelectability is changed.");

      break;

 

    case 8:

      ed.WriteMessage(" \nLayer or LayerGroup Parent is changed.");

      break;

    default:

      break;

  }

}

 

当我在任务面板里对图层或者图层组进行更改时,就可以收到哪些发生变化的提示信息。

when I change the name of layer in task pane of Map 3D, the LayerModified event is trigger, with “args.Modification”, I know that it is the layer’s name is changed. Similarly, when I turn on/off a layer, I get a notification of the changes of visibility of layer. And when I drag one layer from one layer group to another, I get a notification saying that the parent of layer is changed.

 

The result output is as below:

-------------------------------------

Command:
Command: netload
Command: LISTENTOLAYERCHANGE
Layer or LayerGroup name is changed.
Layer or LayerGroup Visibility  is changed
Layer or LayerGroup Parent is changed.
Command:

-------------------------------------

Hope this helps.

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-01
  • 2021-07-16
  • 2021-12-04
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2021-10-05
  • 2022-12-23
  • 2021-07-09
  • 2021-06-13
  • 2022-12-23
相关资源
相似解决方案