Hi everybody,
I am developing a plugin Autocad and have a problem about NullReferenceException at line code "
using (Transaction tr = db.TransactionManager.StartTransaction())
How to fix this error. Please have a look code below and advice.
What I have tried:
public void Aba(int Width)
{
Document doc = AcAp.DocumentManager.MdiActiveDocument;
Database db = doc.Database;
Editor ed = doc.Editor;
//PromptEntityResult selRes = ed.GetEntity("\nPick a Curve entity:");
PromptSelectionOptions selOp = new PromptSelectionOptions();
PromptSelectionResult selRes = ed.GetSelection(selOp);
PromptKeywordOptions chRes = new PromptKeywordOptions("\nVuong hay khong?[Y/N]:", "Y N");
chRes.Keywords.Default = "Y";
PromptResult pStrRes = ed.GetKeywords(chRes);
try
{
using (Transaction tr = db.TransactionManager.StartTransaction())
{
if (selRes.Status == PromptStatus.OK)
{
SelectionSet acSSet = selRes.Value;
// Step through the objects in the selection set
foreach (SelectedObject acSSObj in acSSet)
{
Entity ent = (Entity)tr.GetObject(acSSObj.ObjectId, OpenMode.ForRead);
double angle = GetAngle(ent as Curve);
int CurLenght = Convert.ToInt32((GetLength(ent as Curve)));