|
Most of us who have been reading C# code for a while get to recognize and accept certain variable names to represent objects from the AutoCAD API.
For instance, this sort of template would be fairly easily grocked.
[ol]using System;
using System.IO;
using Autodesk.AutoCAD.DatabaseServices;
using MgdAcApplication = Autodesk.AutoCAD.ApplicationServices.Core.Application;
namespace NetAddinCS9 {
public class CmdGroup1 {
public void VariablesUsed() {
var doc = MgdAcApplication.DocumentManager.MdiActiveDocument;
// var ed = doc.Editor;
// OR if doc is not used ??
var ed = MgdAcApplication.DocumentManager.MdiActiveDocument.Editor;
var db = HostApplicationServices.WorkingDatabase;
using(var tr = db.TransactionManager.StartOpenCloseTransaction()) {
//TODO: add/access stuff in the Database
tr.Commit();
}
// working with an external Database
try {
using(var extDb = new Database(false, true)) {
extDb.ReadDwgFile("D:\\temp\\tester.dwg", FileShare.ReadWrite, false, "");
using(var extTr = extDb.TransactionManager.StartTransaction()) {
//TODO: add/access stuff in the external Database
extTr.Commit();
}
}
}
catch(System.Exception ex) {
ed.WriteMessage(Environment.NewLine + ex.ToString());
}
}
}
}
[/ol]
Without being too pedantic or anal about it, I like to be consistent with naming variables.
... there is a certain comfort associated with a familiar system.
With that in mind, I'm wondering what you guys like to use for object names.
Some that come to mind are.
doc Document
db Database
ed Editor
tr Transaction
extDb Database external
extTr Transaction external
docLock
id ObjectId
xxxxxId whatever ObjectId
ent Entity
bt BlockTable
btr BlockTableRecord
br BlockReference
cs CustomizationSection
ws Workspace
tab RibbonTab
rb ResultBuffer
peo PromptEntityOptions
per PromptEntityResult
pso PromptSelectionOptions // these can be confusing and not obvious sometimes
psr PromptSelectionResult
ucs Matrix3d : ed.CurrentUserCoordinateSystem
ucsTbl UcsTable
vt ViewportTable
vtr ViewPortTableRecord
lt LayerTable
ltr LayerTableRecord
Anyone got any favorites they like to use ??
... or alternatives ??
Regards,
|
|