How to close the Editing Request Placed window programmatically

How to close the Editing Request Placed window programmatically

talalaevd
Collaborator Collaborator
538 Views
3 Replies
Message 1 of 4

How to close the Editing Request Placed window programmatically

talalaevd
Collaborator
Collaborator

I implemented the error handling as follows

public class MyWorksetElementPreprocessor : IFailuresPreprocessor
        {
            public FailureProcessingResult PreprocessFailures(FailuresAccessor failuresAccessor)
            {
                IList<FailureMessageAccessor> failList = new List<FailureMessageAccessor>();
                failList = failuresAccessor.GetFailureMessages();
                foreach (FailureMessageAccessor failure in failList)
                {
                    FailureDefinitionId failID = failure.GetFailureDefinitionId();
                    if (failID == BuiltInFailures.EditingFailures.OwnedByOther)
                    {
                        failuresAccessor.ResolveFailure(failure);
                        return FailureProcessingResult.ProceedWithRollBack;
                    }
                }
                return FailureProcessingResult.Continue;
            }
        }
private static Transaction MakeTransaction(Document doc, string name, bool useFailureHandlingOpts)
        {
            Transaction t = new Transaction(doc, name);
            if (useFailureHandlingOpts)
            {
                FailureHandlingOptions opts = t.GetFailureHandlingOptions();
                opts.SetClearAfterRollback(true);
                opts.SetFailuresPreprocessor(new MyWorksetElementPreprocessor());
                t.SetFailureHandlingOptions(opts);
            }
            return t;
        }
public bool UpdateProjectEdit(Document _doc, TreeView _treeview, string _name)
        {
            bool result = false;
            TreeNode elms = _treeview.SelectedNode;
            Element elm_rename = (Element)elms.Tag;
            TransactionStatus t_status;
            using (Transaction t = MakeTransaction(_doc, "Rename element " + elm_rename.Name, true))
            {
                t.Start();
                elm_rename.Name = _name;
                t_status = t.Commit();
            }
            if (t_status != TransactionStatus.RolledBack)
            {
                result = true;
            }
            return result;
        }


But when processing a borrowed item error, this window appears2017-06-27_14-26-22.jpg

 

I do not know yet how to close this window automatically. Does anyone have any advice?



Дмитрий Талалаев
Эксперт BIM2B
Блог
Facebook | Twitter | LinkedIn

0 Likes
539 Views
3 Replies
Replies (3)
Message 2 of 4

talalaevd
Collaborator
Collaborator

I tried to use EventHandler <DialogBoxShowingEventArgs> but the specified window is not intercepted in any way. In the log there is an entry about the event Jrn.PushButton "Modal, Hosted editing request, Dialog_Revit_CheckEditabilityGrants", "Close, IDOK".

What can Dialog_Revit_CheckEditabilityGrants mean and where can I use it?



Дмитрий Талалаев
Эксперт BIM2B
Блог
Facebook | Twitter | LinkedIn

0 Likes
Message 3 of 4

jeremytammik
Autodesk
Autodesk

Dear Дмитрий,

 

Thank you for your query.

 

All that I can say about handling dialogues and failures is covered by The Building Coder topic group 5.32:

 

http://thebuildingcoder.typepad.com/blog/about-the-author.html#5.32

 

If all else fails, you can always use the Windows API to simulate mouse clicks and all other required user input:

 

http://thebuildingcoder.typepad.com/blog/2009/10/dismiss-dialogue-using-windows-api.html

 

In this case, with one single button to click, that should be fairly easy.

 

You can also submit a request to the Revit Idea Station for future versions of the Revit API to support this action directly.

 

I hope this helps.

 

Best regards,

 

Jeremy



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Message 4 of 4

talalaevd
Collaborator
Collaborator

Thanks Jeremy.
I'll have to use the Windows API to simulate a user clicking a button.



Дмитрий Талалаев
Эксперт BIM2B
Блог
Facebook | Twitter | LinkedIn

0 Likes