<?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: .Revit.Proxy.Exceptions in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/revit-proxy-exceptions/m-p/9463305#M35120</link>
    <description>&lt;P&gt;No thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please mark thread then as solved, for other users.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Michel&lt;/P&gt;</description>
    <pubDate>Wed, 22 Apr 2020 20:28:04 GMT</pubDate>
    <dc:creator>TripleM-Dev.net</dc:creator>
    <dc:date>2020-04-22T20:28:04Z</dc:date>
    <item>
      <title>.Revit.Proxy.Exceptions</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-proxy-exceptions/m-p/9445343#M35111</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;I am wanting to delete all the Elevation Views from a model.&amp;nbsp; I am running into this exception:&lt;/P&gt;&lt;P&gt;Autodesk.Revit.Proxy.Exception.InvalidObjectExceptionProxy&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I assume I need to load a Reference for 'Proxy' but I am not sure, nor can I find where to load from, it i not with the other .dll files.&lt;/P&gt;&lt;P&gt;I am trying to figure out which view or what is throw the exception or why it is happening&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for any assistance...&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;t.Start();

List&amp;lt;View&amp;gt; views = myFunctions.CollectedViews(doc);
List&amp;lt;ViewType&amp;gt; viewTypes = myFunctions.ReturnListOfViewTypes(doc);

foreach (View v in views.Distinct())
{
    if (!v.IsTemplate)
    {
        foreach (ViewType vt in viewTypes)
        {
            if(vt == v.ViewType)
            {
                try
                {
                    doc.Delete(v.Id);
                }
                catch (Autodesk.Revit.Proxy.Exceptions.InvalidObjectExceptionProxy)//&amp;lt;-- No Good
                {
                    TD(v.Name);// TaskDialog.Show shortcut
                }
            }
        }
    }
}

t.Commit();&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Capture.PNG" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/754718iA9F08604E67BDC63/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Capture.PNG" alt="Capture.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2020 16:19:31 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-proxy-exceptions/m-p/9445343#M35111</guid>
      <dc:creator>aclarke</dc:creator>
      <dc:date>2020-04-15T16:19:31Z</dc:date>
    </item>
    <item>
      <title>Re: .Revit.Proxy.Exceptions</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-proxy-exceptions/m-p/9445651#M35112</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not sure about the Proxy message (strange), but a couple of things:&lt;/P&gt;&lt;P&gt;- Views.Distinct not needed if you want to delete all elevation views (would always be unique)&lt;/P&gt;&lt;P&gt;- Make sure one of the open views isn't a Elevation! This gives a error message in the Revit UI&lt;/P&gt;&lt;P&gt;- Is the error raised at the first deletion ?&lt;/P&gt;&lt;P&gt;- in place of doc.delete(v.id), collect the id's in a collection and delete them together AFTER the loop.&lt;/P&gt;&lt;P&gt;- What is the viewTypes collection contain?&lt;/P&gt;&lt;P&gt;- Make sure not to try and delete a dependent view if parent view is already deleted.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;See code below, do check if a non-elevation view is open first!&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;    FilteredElementCollector ViewCollector = new FilteredElementCollector(doc).OfClass(typeof(View));
    List&amp;lt;ElementId&amp;gt; DeleteViewIds = ViewCollector.Cast&amp;lt;View&amp;gt;.Where(v =&amp;gt; (!v.IsTemplate) &amp;amp;&amp;amp; v.ViewType == ViewType.Elevation &amp;amp;&amp;amp; (v.GetPrimaryViewId != ElementId.InvalidElementId)).Select(e =&amp;gt; e.Id).ToList;
    using (var t = new Transaction(doc, "Delete Elevations"))
    {
        t.Start();
        doc.Delete(DeleteViewIds);
        t.Commit();
    }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Michel&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2020 18:05:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-proxy-exceptions/m-p/9445651#M35112</guid>
      <dc:creator>TripleM-Dev.net</dc:creator>
      <dc:date>2020-04-15T18:05:50Z</dc:date>
    </item>
    <item>
      <title>Re: .Revit.Proxy.Exceptions</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-proxy-exceptions/m-p/9445662#M35113</link>
      <description>&lt;P&gt;I figured out why I was getting this error...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The collection grabs all the views, and I failed to filter for Primary from the Dependent views, so as the deletion iterates thru the list of ID's, once the primary is deleted and then it gets to the dependent Id, the element is no longer there because it was deleted with the primary.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Filtering into two lists, a primary and dependent, then delete all the dependent views first then the primaries views fixed my issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am still curious for the Revit.Proxy Exception&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2020 18:10:42 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-proxy-exceptions/m-p/9445662#M35113</guid>
      <dc:creator>aclarke</dc:creator>
      <dc:date>2020-04-15T18:10:42Z</dc:date>
    </item>
    <item>
      <title>Re: .Revit.Proxy.Exceptions</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-proxy-exceptions/m-p/9445710#M35114</link>
      <description>&lt;P&gt;Thanks for the example code.&amp;nbsp; I like seeing examples of LINQ.&amp;nbsp; I am trying to do more with LINQ but I still struggle with it.&lt;/P&gt;&lt;P&gt;the Distinct() was me trying to understand how an ID was being deleted then trying to delete again, so I thought the ID was being captured twice...&amp;nbsp; I was throwing rocks at the problem trying to figure it out.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;viewType collection:&lt;/P&gt;&lt;P&gt;It was going to contain a list of all the view types I wanted to delete, but this doesn't seem feasible now, seems better to tackle each view type independently.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your reply&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;public static List&amp;lt;ViewType&amp;gt; ReturnListOfViewTypes(Document doc)
{
    return new List&amp;lt;ViewType&amp;gt;()
    {
        ViewType.Elevation
    };
}&lt;/LI-CODE&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;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2020 18:33:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-proxy-exceptions/m-p/9445710#M35114</guid>
      <dc:creator>aclarke</dc:creator>
      <dc:date>2020-04-15T18:33:28Z</dc:date>
    </item>
    <item>
      <title>Re: .Revit.Proxy.Exceptions</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-proxy-exceptions/m-p/9445813#M35115</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I didn't test the code, below a correction for functional code:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;FilteredElementCollector ViewCollector = new FilteredElementCollector(doc).OfClass(typeof(View));

            List&amp;lt;ElementId&amp;gt; DeleteViewIds = ViewCollector.Cast&amp;lt;View&amp;gt;().Where(v =&amp;gt; !v.IsTemplate &amp;amp;&amp;amp; 
                        v.ViewType == ViewType.Elevation &amp;amp;&amp;amp; 
                        v.GetPrimaryViewId() == ElementId.InvalidElementId).Select(e =&amp;gt; e.Id).ToList();

            using (var t = new Transaction(doc, "Delete Elevations"))
            {
                t.Start();
                doc.Delete(DeleteViewIds);
                t.Commit();
            }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below a sample for using grouping on a property, ViewType in this case.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;            FilteredElementCollector ViewCollector = new FilteredElementCollector(doc).OfClass(typeof(View));

            var groupedData = ViewCollector.Cast&amp;lt;View&amp;gt;().Where(v =&amp;gt; !v.IsTemplate &amp;amp;&amp;amp; v.GetPrimaryViewId() == ElementId.InvalidElementId).GroupBy(v =&amp;gt; v.ViewType);

            foreach (var group in groupedData)
             {
                var groupkey = group.Key;

               //if(groupkey == ViewType.Elevation)
               // { 
               //     // only do something now
               // }

                foreach (var groupeditem in group)
                {
                    // the Views = groupeditem for the Viewtype = groupkey

                }

            }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Michel&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2020 19:25:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-proxy-exceptions/m-p/9445813#M35115</guid>
      <dc:creator>TripleM-Dev.net</dc:creator>
      <dc:date>2020-04-15T19:25:28Z</dc:date>
    </item>
    <item>
      <title>Re: .Revit.Proxy.Exceptions</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-proxy-exceptions/m-p/9445876#M35116</link>
      <description>&lt;P&gt;Another great LINQ example...&amp;nbsp; &amp;nbsp;I will use this...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for sharing with me..&amp;nbsp; &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2020 19:54:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-proxy-exceptions/m-p/9445876#M35116</guid>
      <dc:creator>aclarke</dc:creator>
      <dc:date>2020-04-15T19:54:21Z</dc:date>
    </item>
    <item>
      <title>Re: .Revit.Proxy.Exceptions</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-proxy-exceptions/m-p/9445970#M35117</link>
      <description>&lt;P&gt;Why the use of 'var' because I wouldn't know to use it for this case?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;var groupedData = ViewCollector.Cast&amp;lt;View&amp;gt;()
.Where(v =&amp;gt; !v.IsTemplate
&amp;amp;&amp;amp; v.GetPrimaryViewId() == ElementId.InvalidElementId).GroupBy(v =&amp;gt; v.ViewType);&lt;/LI-CODE&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;P&gt;Thanks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2020 20:30:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-proxy-exceptions/m-p/9445970#M35117</guid>
      <dc:creator>aclarke</dc:creator>
      <dc:date>2020-04-15T20:30:34Z</dc:date>
    </item>
    <item>
      <title>Re: .Revit.Proxy.Exceptions</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-proxy-exceptions/m-p/9446008#M35118</link>
      <description>&lt;P&gt;It's just easier:&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;var groupedData = ViewCollector.Cast&amp;lt;View&amp;gt;().Where(v =&amp;gt; !v.IsTemplate &amp;amp;&amp;amp; v.GetPrimaryViewId() == ElementId.InvalidElementId).GroupBy(v =&amp;gt; v.ViewType);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;is identical to, both can be used.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;IEnumerable&amp;lt;IGrouping&amp;lt;ViewType, View&amp;gt;&amp;gt; groupedData = ViewCollector.Cast&amp;lt;View&amp;gt;().Where(v =&amp;gt; !v.IsTemplate &amp;amp;&amp;amp; v.GetPrimaryViewId() == ElementId.InvalidElementId).GroupBy(v =&amp;gt; v.ViewType);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The type of groupedData is already&amp;nbsp;inferred because of the GroupBy.&lt;/P&gt;&lt;P&gt;If that's what you mean?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Michel&lt;/P&gt;</description>
      <pubDate>Wed, 15 Apr 2020 20:49:36 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-proxy-exceptions/m-p/9446008#M35118</guid>
      <dc:creator>TripleM-Dev.net</dc:creator>
      <dc:date>2020-04-15T20:49:36Z</dc:date>
    </item>
    <item>
      <title>Re: .Revit.Proxy.Exceptions</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-proxy-exceptions/m-p/9463273#M35119</link>
      <description>&lt;P&gt;you have answered my question,&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 22 Apr 2020 20:14:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-proxy-exceptions/m-p/9463273#M35119</guid>
      <dc:creator>aclarke</dc:creator>
      <dc:date>2020-04-22T20:14:13Z</dc:date>
    </item>
    <item>
      <title>Re: .Revit.Proxy.Exceptions</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-proxy-exceptions/m-p/9463305#M35120</link>
      <description>&lt;P&gt;No thanks.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please mark thread then as solved, for other users.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;- Michel&lt;/P&gt;</description>
      <pubDate>Wed, 22 Apr 2020 20:28:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-proxy-exceptions/m-p/9463305#M35120</guid>
      <dc:creator>TripleM-Dev.net</dc:creator>
      <dc:date>2020-04-22T20:28:04Z</dc:date>
    </item>
    <item>
      <title>Re: .Revit.Proxy.Exceptions</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-proxy-exceptions/m-p/9463329#M35121</link>
      <description>&lt;P&gt;I am confused by your 'no thanks'&lt;/P&gt;</description>
      <pubDate>Wed, 22 Apr 2020 20:37:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-proxy-exceptions/m-p/9463329#M35121</guid>
      <dc:creator>aclarke</dc:creator>
      <dc:date>2020-04-22T20:37:57Z</dc:date>
    </item>
    <item>
      <title>Re: .Revit.Proxy.Exceptions</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/revit-proxy-exceptions/m-p/9463360#M35122</link>
      <description>&lt;P&gt;Sorry, poor choice of words on my side.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;No thanks needed.&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":face_with_tears_of_joy:"&gt;😂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Apr 2020 20:52:47 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/revit-proxy-exceptions/m-p/9463360#M35122</guid>
      <dc:creator>TripleM-Dev.net</dc:creator>
      <dc:date>2020-04-22T20:52:47Z</dc:date>
    </item>
  </channel>
</rss>

