Today’s post is focused on productivity, an aspect that is sometimes left behind due our intense work load…And I believe that small improvements can make a huge difference on our daily work.
Now the idea is to save us some time typing a new command for AutoCAD, that includes, for instance, database, editor and transaction. Sure you can adjust the code.
How make this work? Simple:
- Create a .snippet file using any text editor (Notepad can do the trick).
- Copy & paste the XML content below
- Save at [My Documents]\Visual Studio 2012\Code Snippets\Visual C#\My Code Snippets\ folder, or other version that you have.
- At your Visual Studio code, type AcadCmd and press TAB, the code should appear, press TAB again to move between command name and method name, both marked in yellow.
Like it? You may adjust to other commands or other pieces that you use repeatedly. Here is the .snippet for download.
<?xml version="1.0" encoding="utf-8" ?>
<Description>Code snippet for AutoCAD command method with transaction</Description>
<ToolTip>Replace with the command name</ToolTip>
<ToolTip>Replace with the method name</ToolTip>
public static void $METHOD_NAME$()
Database db = Application.DocumentManager.MdiActiveDocument.Database;
Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
using (Transaction trans = db.TransactionManager.StartTransaction())