- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello to all
Im facing a problem, my application asks the user to pick a point but when the user presses escape, the application throws this exception:
then non of the other application work and after a few seconds, autocad crashes.
I noticed when the transaction is not aborted, this happens.
so what Im doing is manually aborting the transaction from the caller method.
this is the code where I abort the transaction:
I have to validate if pointList is null in the last piece of my code in the first method.
public static void TestBlockIntersection2()
{
var doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
var ed = doc.Editor;
var db = doc.Database;
var tr = db.TransactionManager.StartTransaction();
var layerTable = (LayerTable)tr.GetObject(db.LayerTableId, OpenMode.ForWrite);
var layerName = "SPRKVIEW";
if (!layerTable.Has(layerName))
{
ed.WriteMessage("\nSPRKVIEW layer does not exist!");
CreateLayers(layerName as String, layerTable as LayerTable);
}
List<Point3d> pointList = CornerPoints(ed as Editor);
if (pointList==null)
{
tr.Abort();
return;
}
}
private static List<Point3d> CornerPoints(Editor ed)
{
var ppo = new PromptPointOptions("\nPick first corner");
ppo.AllowNone=true;
PromptPointResult ppr = ed.GetPoint(ppo);
if (ppr.Status!=PromptStatus.OK) return null;
Point3d firstCorner = ppr.Value;
var pco = new PromptCornerOptions("\npick second corner", firstCorner);
//pco.BasePoint=firstCorner;
var pcr = ed.GetCorner(pco);
if (pcr.Status!=PromptStatus.OK) return null;
Point3d secondCorner = pcr.Value;
var pointLists = new List<Point3d>();
pointLists.Add(firstCorner);
pointLists.Add(secondCorner);
return pointLists;
}
do I have to abort the transaction every single time Im getting a value from another method?
lets say I have 50 other methods that the user might press escape. do I have to validate the value every single time?
Solved! Go to Solution.