using Autodesk.AutoCAD.ApplicationServices;using Autodesk.AutoCAD.Runtime;using Autodesk.AutoCAD.EditorInput;[assembly: CommandClass(typeof(CommandClasses.FirstClass))][assembly: CommandClass(typeof(CommandClasses.SecondClass))]namespace CommandClasses{ static public class FirstClass { private static int counter = 0; [Autodesk.AutoCAD.Runtime.CommandMethod("glob")] public static void global() { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; ed.WriteMessage("\nCounter value is: " + counter++); } } public class SecondClass { private int counter = 0; [Autodesk.AutoCAD.Runtime.CommandMethod("loc")] public void local() { Editor ed = Application.DocumentManager.MdiActiveDocument.Editor; ed.WriteMessage("\nCounter value is: " + counter++); } }}
Here’s what happens when you execute the two commands in two separate documents:
[From first drawing...]
Command: glob
Counter value is: 0
Command: glob
Counter value is: 1
Command: glob
Counter value is: 2
Command: loc
Counter value is: 0
Command: loc
Counter value is: 1
Command: loc
Counter value is: 2
Command: new
[From second drawing...]
Command: glob
Counter value is: 3
Command: glob
Counter value is: 4
Command: glob
Counter value is: 5
Command: loc
Counter value is: 0
Command: loc
Counter value is: 1
Command: loc
Counter value is: 2