<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Posting OwnedByother failure in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/posting-ownedbyother-failure/m-p/6446575#M68440</link>
    <description>I found it can!&lt;BR /&gt;&lt;BR /&gt;public class EditingElementsWarningSwallower : IFailuresPreprocessor&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;public FailureProcessingResult PreprocessFailures(FailuresAccessor a)&lt;BR /&gt;{&lt;BR /&gt;// inside event handler, get all warnings&lt;BR /&gt;IList&amp;lt;FailureMessageAccessor&amp;gt; failures = a.GetFailureMessages();&lt;BR /&gt;&lt;BR /&gt;foreach (FailureMessageAccessor f in failures)&lt;BR /&gt;{&lt;BR /&gt;// check failure definition ids&lt;BR /&gt;// against ones to dismiss:&lt;BR /&gt;FailureDefinitionId id = f.GetFailureDefinitionId();&lt;BR /&gt;&lt;BR /&gt;if (BuiltInFailures.EditingFailures.CannotEditEditingElements == id)&lt;BR /&gt;{&lt;BR /&gt;if (failures.Count &amp;gt; 1)&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;a.DeleteWarning(f);&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;return FailureProcessingResult.Continue;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;//Swap types&lt;BR /&gt;using (Transaction trans = new Transaction(_doc, "Ungroup"))&lt;BR /&gt;{&lt;BR /&gt;trans.Start();&lt;BR /&gt;&lt;BR /&gt;failureHandlingOptions(trans);&lt;BR /&gt;element_old.ChangeTypeId(elemStyle_New.Id);&lt;BR /&gt;&lt;BR /&gt;trans.Commit();&lt;BR /&gt;}</description>
    <pubDate>Tue, 19 Jul 2016 09:56:00 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2016-07-19T09:56:00Z</dc:date>
    <item>
      <title>Posting OwnedByother failure</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/posting-ownedbyother-failure/m-p/5978344#M68436</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to use the API to check out an element and, if the checkout fails, post the normal error message with the opportunity to resolve it:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://forums.autodesk.com/t5/image/serverpage/image-id/210224i8512A9A8B151D1C3/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="Capture2.PNG" title="Capture2.PNG" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Attempting to check out is simple enough:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;ICollection&amp;lt;ElementId&amp;gt; checkedOutIds = WorksharingUtils.CheckoutElements(doc, new ElementId[] { eid });
bool checkedOutSuccessfully = checkedOutIds.Contains(eid);&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, when it fails it does so silently, without showing the failure box. I attempted to show the box manually:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;if (!checkedOutSuccessfully)
{
&amp;nbsp; &amp;nbsp; using (Transaction tr = new Transaction(doc, "Posting failure message"))
&amp;nbsp; &amp;nbsp; {
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; tr.Start();
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; FailureMessage fm = new FailureMessage(BuiltInFailures.EditingFailures.OwnedByOther);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; fm.SetFailingElement(eid);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; doc.PostFailure(fm);
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; tr.Commit();
&amp;nbsp; &amp;nbsp; }

&amp;nbsp; &amp;nbsp; return null;
}&lt;/PRE&gt;&lt;P&gt;But this gives me a box without a username and no way to resolve the issue (&lt;EM&gt;ie&lt;/EM&gt;&amp;nbsp;Place Request).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;IMG src="https://forums.autodesk.com/t5/image/serverpage/image-id/210223i00189031103C6097/image-size/original?v=mpbl-1&amp;amp;px=-1" border="0" alt="Capture.PNG" title="Capture.PNG" /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there some way I can accomplish what I am looking for?&lt;/P&gt;</description>
      <pubDate>Thu, 07 Jan 2016 19:57:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/posting-ownedbyother-failure/m-p/5978344#M68436</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-01-07T19:57:33Z</dc:date>
    </item>
    <item>
      <title>Re: Posting OwnedByother failure</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/posting-ownedbyother-failure/m-p/5979752#M68437</link>
      <description>&lt;P&gt;Dear&amp;nbsp;Drdanielfc,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I discussed this issue with the development team, and they say:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is an interesting test case.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Are you aware of Scott Conover's Autodesk University class on the Worksharing API?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://thebuildingcoder.typepad.com/blog/2013/12/au-day-2-worksharing-and-revit-2014-api-roundtables.html#4" target="_blank"&gt;http://thebuildingcoder.typepad.com/blog/2013/12/au-day-2-worksharing-and-revit-2014-api-roundtables.html#4&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;That would probably help.&lt;BR /&gt; &lt;BR /&gt;As far as I remember,&lt;BR /&gt; &lt;BR /&gt;1. If you want to have Revit just post the relevant message on a failure to edit, just try to perform the edit. Don’t checkout in advance. So if the edit is setting a parameter, open a transaction, edit the parameter, and on resolution you’ll get the posted error for the user to respond to. &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. If you want to handle failure to edit silently, you can respond to the failure message, or try to checkout first.&lt;BR /&gt; &lt;BR /&gt;I am wondering about the posted failure missing the expected text. I’m not sure if this is a bug or a missing API that we should have for customizing FailureMessage objects.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you can submit a reproducibkle case for this we could take a closer look:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="http://thebuildingcoder.typepad.com/blog/about-the-author.html#1b" target="_blank"&gt;http://thebuildingcoder.typepad.com/blog/about-the-author.html#1b&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I wish you a pleasant weekend.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeremy&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2016 15:34:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/posting-ownedbyother-failure/m-p/5979752#M68437</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2016-01-08T15:34:32Z</dc:date>
    </item>
    <item>
      <title>Re: Posting OwnedByother failure</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/posting-ownedbyother-failure/m-p/5979807#M68438</link>
      <description>&lt;P&gt;In my application, the user selects the element and then a custom dialog is opened where the user can edit the element. I want to check out the item before my dialog even opens so the user can receive permission to edit it before wasting their time working on it if someone else has the item checked out, because if another other person has it checked out then any edits they make in my dialog will have to be discarded so they can Reload Latest. I suppose if the checkout fails I could simply make a temporary edit to the element to force the Revit warning box to show up, but this seems inelegant and not a very universal solution.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will make a reproducible case next week.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have a good weekend!&lt;/P&gt;</description>
      <pubDate>Fri, 08 Jan 2016 16:02:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/posting-ownedbyother-failure/m-p/5979807#M68438</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-01-08T16:02:28Z</dc:date>
    </item>
    <item>
      <title>Re: Posting OwnedByother failure</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/posting-ownedbyother-failure/m-p/6443683#M68439</link>
      <description>&lt;P&gt;Can this dialog box be suppresed?&lt;/P&gt;</description>
      <pubDate>Sun, 17 Jul 2016 11:06:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/posting-ownedbyother-failure/m-p/6443683#M68439</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-07-17T11:06:28Z</dc:date>
    </item>
    <item>
      <title>Re: Posting OwnedByother failure</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/posting-ownedbyother-failure/m-p/6446575#M68440</link>
      <description>I found it can!&lt;BR /&gt;&lt;BR /&gt;public class EditingElementsWarningSwallower : IFailuresPreprocessor&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;public FailureProcessingResult PreprocessFailures(FailuresAccessor a)&lt;BR /&gt;{&lt;BR /&gt;// inside event handler, get all warnings&lt;BR /&gt;IList&amp;lt;FailureMessageAccessor&amp;gt; failures = a.GetFailureMessages();&lt;BR /&gt;&lt;BR /&gt;foreach (FailureMessageAccessor f in failures)&lt;BR /&gt;{&lt;BR /&gt;// check failure definition ids&lt;BR /&gt;// against ones to dismiss:&lt;BR /&gt;FailureDefinitionId id = f.GetFailureDefinitionId();&lt;BR /&gt;&lt;BR /&gt;if (BuiltInFailures.EditingFailures.CannotEditEditingElements == id)&lt;BR /&gt;{&lt;BR /&gt;if (failures.Count &amp;gt; 1)&lt;BR /&gt;{&lt;BR /&gt;&lt;BR /&gt;a.DeleteWarning(f);&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;return FailureProcessingResult.Continue;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;//Swap types&lt;BR /&gt;using (Transaction trans = new Transaction(_doc, "Ungroup"))&lt;BR /&gt;{&lt;BR /&gt;trans.Start();&lt;BR /&gt;&lt;BR /&gt;failureHandlingOptions(trans);&lt;BR /&gt;element_old.ChangeTypeId(elemStyle_New.Id);&lt;BR /&gt;&lt;BR /&gt;trans.Commit();&lt;BR /&gt;}</description>
      <pubDate>Tue, 19 Jul 2016 09:56:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/posting-ownedbyother-failure/m-p/6446575#M68440</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2016-07-19T09:56:00Z</dc:date>
    </item>
    <item>
      <title>Re: Posting OwnedByother failure</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/posting-ownedbyother-failure/m-p/6446762#M68441</link>
      <description>&lt;P&gt;Congratulations!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Well done!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for letting us know.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The source code is more readable if you use the 'Insert Code' {i} button to insert it.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Cheers,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Jeremy&lt;/P&gt;</description>
      <pubDate>Tue, 19 Jul 2016 11:58:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/posting-ownedbyother-failure/m-p/6446762#M68441</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2016-07-19T11:58:36Z</dc:date>
    </item>
    <item>
      <title>Re: Posting OwnedByother failure</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/posting-ownedbyother-failure/m-p/7170830#M68442</link>
      <description>&lt;P&gt;First I realized&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;public class MyWorksetElementPreprocessor : IFailuresPreprocessor
        {
            public FailureProcessingResult PreprocessFailures(FailuresAccessor failuresAccessor)
            {
                IList&amp;lt;FailureMessageAccessor&amp;gt; failList = new List&amp;lt;FailureMessageAccessor&amp;gt;();
                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;
            }
        }&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;Then used&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;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;
        }&lt;/PRE&gt;
&lt;P&gt;&lt;SPAN&gt;In main code&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;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;
        }&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;But there is one thing. I'm sending an edit request for an item. This window is displayed&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-left" image-alt="2017-06-22_3-56-14.jpg" style="width: 324px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/370302iE24D4C7575C5A1BA/image-size/medium?v=v2&amp;amp;px=400" role="button" title="2017-06-22_3-56-14.jpg" alt="2017-06-22_3-56-14.jpg" /&gt;&lt;/span&gt;&lt;BR /&gt;I do not know yet how to close this window automatically.&amp;nbsp;Does anyone have any advice?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Jun 2017 13:21:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/posting-ownedbyother-failure/m-p/7170830#M68442</guid>
      <dc:creator>talalaevd</dc:creator>
      <dc:date>2017-06-22T13:21:44Z</dc:date>
    </item>
    <item>
      <title>Re: Posting OwnedByother failure</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/posting-ownedbyother-failure/m-p/8278842#M68443</link>
      <description>&lt;P&gt;i reached the same result does any one solved that.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Sep 2018 16:16:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/posting-ownedbyother-failure/m-p/8278842#M68443</guid>
      <dc:creator>BIM_S_S</dc:creator>
      <dc:date>2018-09-19T16:16:33Z</dc:date>
    </item>
    <item>
      <title>Re: Posting OwnedByother failure</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/posting-ownedbyother-failure/m-p/10471043#M68444</link>
      <description>&lt;P&gt;errr&lt;/P&gt;</description>
      <pubDate>Thu, 15 Jul 2021 12:53:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/posting-ownedbyother-failure/m-p/10471043#M68444</guid>
      <dc:creator>AndrewButenko</dc:creator>
      <dc:date>2021-07-15T12:53:42Z</dc:date>
    </item>
  </channel>
</rss>

