void ICommand.Execute(object parameter) { if (!(this as ICommand).CanExecute(parameter)) { Ac.ShowAlertDialog("Cannot execute " + this.DisplayName + " (Possible reason: there is no drawing environment)"); return; } try { InProgress = true; AppServices.Log.Add(this.GetType().FullName + ": Executing..."); //CommandManager.InvalidateRequerySuggested(); // Requests to modify objects or access AutoCAD can occur in any context, and coming from any number of applications. // To prevent conflicts with other requests, you are responsible for locking a document before you modify it. // http://help.autodesk.com/view/ACD/2015/ENU/?guid=GUID-A2CD7540-69C5-4085-BCE8-2A8ACE16BFDD //using (var docLock = Ac.Doc.LockDocument()) -> Lock document only when needed (Button pressed) //using (var uiLock = Ac.StartUserInteraction()) -> Lock user interaction only when needed (Button pressed) { ExecuteCore(); //uiLock.End(); } AppServices.Log.Add(this.GetType().FullName + ": Done."); } catch (Exception ex) { Ac.WriteError(ex, this.GetType().Name + ".Execute()", this.DisplayName); if (this.DisplayErrormMessageBox) { Ac.ShowAlertDialog(ex.Message); } } finally { InProgress = false; Ac.ClearProgress(); } var trans = Ac.Db.TransactionManager.TopTransaction; if (trans != null) { trans.Abort(); } CommandManager.InvalidateRequerySuggested(); }
public static void ClearProgress() { try { #if AutoCAD Autodesk.AutoCAD.Internal.Utils.RestoreApplicationStatusBar(); #else Ac.WriteLn(""); #endif DoEvents(); } catch (System.Exception ex) { Ac.WriteError(ex, "Ac.ClearProgress()", null); } }