When you say " I've tried creating an ObjectOverrule for Groups but only the Open event fires when a Group is copied", are you saying that in your overridden Open() and Close() methods, only code in the Open() method runs and code in Close() is not triggered? Or, you did not override Close() method?
I wrote a simple ObjectOverrule class and did a quick test:
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Runtime;
namespace GroupObjectOverrule
{
public class MyGroupObjectOverrule : ObjectOverrule
{
private static MyGroupObjectOverrule _instance = null;
public static MyGroupObjectOverrule Instance
{
get
{
if (_instance == null) _instance = new MyGroupObjectOverrule();
return _instance;
}
}
public void StartOverrule()
{
AddOverrule(RXClass.GetClass(typeof(Group)), this, false);
this.SetNoFilter();
Overruling = true;
}
public void StopOverrule()
{
RemoveOverrule(RXClass.GetClass(typeof(Group)), this);
Overruling = false;
}
public override void Open(DBObject dbObject, OpenMode mode)
{
base.Open(dbObject, mode);
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
//ed.WriteMessage("\nDBObject is opened: {0}", dbObject.GetType().Name);
}
public override void Close(DBObject dbObject)
{
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
//ed.WriteMessage("\nDBObject is to be closed: {0}", dbObject.GetType().Name);
if (dbObject.IsNewObject)
{
Group g = dbObject as Group;
if (g != null)
{
ed.WriteMessage(
"\nGroup name: {0}; group description: {1}\n",
g.Name, g.Description);
}
}
base.Close(dbObject);
}
}
}
and
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.Runtime;
using CadApp = Autodesk.AutoCAD.ApplicationServices.Application;
[assembly: CommandClass(typeof(GroupObjectOverrule.MyCadCommands))]
namespace GroupObjectOverrule
{
public class MyCadCommands
{
private static bool _overruled = false;
[CommandMethod("GroupOR")]
public static void ToggleGroupOverrule()
{
Document dwg = CadApp.DocumentManager.MdiActiveDocument;
if (dwg == null) return;
Editor ed = dwg.Editor;
try
{
if (!_overruled)
{
MyGroupObjectOverrule.Instance.StartOverrule();
_overruled = true;
ed.WriteMessage("\nMyGroupOverrule enabled.");
}
else
{
MyGroupObjectOverrule.Instance.StopOverrule();
_overruled = false;
ed.WriteMessage("\nMyGroupOverrule disabled.");
}
}
catch (System.Exception ex)
{
ed.WriteMessage("\nError: {0}\n{1}", ex.Message, ex.StackTrace);
}
finally
{
Autodesk.AutoCAD.Internal.Utils.PostCommandPrompt();
}
}
}
}
In testing, I start AutoCAD, NETLOAD the code, run the command GROUPOR.
Then I create a few entities, run command GROUP to put the entities in a anonymous group. Then I select the group, and copy the group to different location. I can clearly see the command line list the new anonymous group name (*A2) printed by my code in Close() method.
By the way, the original anonymous group is named *A1, if I use "ClassicGroup" command to examine the groups in drawing.
So, yes, you can use ObjectOverrule to catch the newly created group. However, you may need to find out a way to determine if the newly created group is your targeting group you want to assign description to it.