<?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: Select all &amp;quot;UI visible&amp;quot; instances in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/select-all-quot-ui-visible-quot-instances/m-p/12995165#M3297</link>
    <description>&lt;P&gt;Yup, that is what I thought. Here is an article on retrieving elements visible in view that might help:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="https://thebuildingcoder.typepad.com/blog/2017/05/retrieving-elements-visible-in-view.html" target="_blank"&gt;https://thebuildingcoder.typepad.com/blog/2017/05/retrieving-elements-visible-in-view.html&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 02 Sep 2024 06:44:13 GMT</pubDate>
    <dc:creator>jeremy_tammik</dc:creator>
    <dc:date>2024-09-02T06:44:13Z</dc:date>
    <item>
      <title>Select all "UI visible" instances</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/select-all-quot-ui-visible-quot-instances/m-p/12995081#M3294</link>
      <description>&lt;P&gt;One of my users came up with an interesting question of whether or not it's possible to create a "Select All Instances &amp;gt; Visible in View" command taking into consideration the view's zoom level, meaning that everything outside the user's field of view is "not visible" and it wouldn't be part of the selection.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried to find references in the API and online articles on the below topics and ran some UI tests and compared values via the Revit Lookup but no success.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Active view zoom level&lt;/LI&gt;&lt;LI&gt;Active view window size&lt;/LI&gt;&lt;LI&gt;Bounding boxes XYZ and UV and whether they change under different zoom levels&lt;/LI&gt;&lt;/UL&gt;</description>
      <pubDate>Mon, 02 Sep 2024 05:57:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/select-all-quot-ui-visible-quot-instances/m-p/12995081#M3294</guid>
      <dc:creator>floretti</dc:creator>
      <dc:date>2024-09-02T05:57:18Z</dc:date>
    </item>
    <item>
      <title>Re: Select all "UI visible" instances</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/select-all-quot-ui-visible-quot-instances/m-p/12995123#M3295</link>
      <description>&lt;P&gt;Well, the first thing to try out is the filtered element collector taking a view element id:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="https://www.revitapidocs.com/2024/6359776d-915e-f8a2-4147-b31024671ee1.htm" target="_blank"&gt;https://www.revitapidocs.com/2024/6359776d-915e-f8a2-4147-b31024671ee1.htm&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The description says,&amp;nbsp;Constructs a new FilteredElementCollector that will search and filter the visible elements in a view, which exactly matches your query. I would be surprised if the two exactly matching descriptions really mean exactly the same thing, but who knows, you may be in luck.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Sep 2024 06:22:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/select-all-quot-ui-visible-quot-instances/m-p/12995123#M3295</guid>
      <dc:creator>jeremy_tammik</dc:creator>
      <dc:date>2024-09-02T06:22:44Z</dc:date>
    </item>
    <item>
      <title>Re: Select all "UI visible" instances</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/select-all-quot-ui-visible-quot-instances/m-p/12995139#M3296</link>
      <description>&lt;P&gt;Thanks, Jeremy. Unfortunately that overload of the &lt;STRONG&gt;FilteredElementCollector&lt;/STRONG&gt; doesn't do what I'm after. The definition of "visible" to the API is different to the definition of what a user considers visible. The example below shows what I mean.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;View B shows 8x wall elements. If I decrease the size of a view/window or simply zoom in or pan I won't be able to see all the 8x walls anymore like shown on View A. Regardless of whether or not I use the &lt;STRONG&gt;FilteredElementCollector&lt;/STRONG&gt; and pass the view Id as a 2nd parameter or use the UI command &lt;STRONG&gt;Select All Instances &amp;gt; Visible in View&lt;/STRONG&gt;, Revit will select all 8x wall instances.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="floretti_0-1725258558909.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1404644iB9B0316986778690/image-size/medium?v=v2&amp;amp;px=400" role="button" title="floretti_0-1725258558909.png" alt="floretti_0-1725258558909.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Sep 2024 06:34:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/select-all-quot-ui-visible-quot-instances/m-p/12995139#M3296</guid>
      <dc:creator>floretti</dc:creator>
      <dc:date>2024-09-02T06:34:28Z</dc:date>
    </item>
    <item>
      <title>Re: Select all "UI visible" instances</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/select-all-quot-ui-visible-quot-instances/m-p/12995165#M3297</link>
      <description>&lt;P&gt;Yup, that is what I thought. Here is an article on retrieving elements visible in view that might help:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="https://thebuildingcoder.typepad.com/blog/2017/05/retrieving-elements-visible-in-view.html" target="_blank"&gt;https://thebuildingcoder.typepad.com/blog/2017/05/retrieving-elements-visible-in-view.html&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Sep 2024 06:44:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/select-all-quot-ui-visible-quot-instances/m-p/12995165#M3297</guid>
      <dc:creator>jeremy_tammik</dc:creator>
      <dc:date>2024-09-02T06:44:13Z</dc:date>
    </item>
    <item>
      <title>Re: Select all "UI visible" instances</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/select-all-quot-ui-visible-quot-instances/m-p/12995225#M3298</link>
      <description>&lt;P&gt;Thanks again, Jeremy. I just tested that approach and these are the results.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is &lt;STRONG&gt;View A&lt;/STRONG&gt; showing all 8x wall instances and its &lt;STRONG&gt;ViewPlan.CropBox&lt;/STRONG&gt; values underneath as recommended by the article.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="floretti_0-1725260516091.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1404653iB6F7EF5CCF937FB8/image-size/medium?v=v2&amp;amp;px=400" role="button" title="floretti_0-1725260516091.png" alt="floretti_0-1725260516091.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I then panned across View A so only 4x wall instances are shown in the UI and again the&amp;nbsp;&lt;STRONG&gt;ViewPlan.CropBox&lt;/STRONG&gt; values underneath.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="floretti_1-1725260576416.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1404655iFD87F65F7BFFD979/image-size/medium?v=v2&amp;amp;px=400" role="button" title="floretti_1-1725260576416.png" alt="floretti_1-1725260576416.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You probably noticed that the values didn't change and based on that I'm not expecting the outcome to be different if I turn this into code. I noticed that the API has two boolean properties to indicate whether the CropBox is either active and visible and you can see that in my case neither of them are true. Based on that, my assumption is that the recommended approach in the article you shared can only work via the cropbox use and not by zooming in/out and panning across a view.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="floretti_2-1725260796000.png" style="width: 600px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1404662i7E88B54F6ADD48AB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="floretti_2-1725260796000.png" alt="floretti_2-1725260796000.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Sep 2024 07:10:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/select-all-quot-ui-visible-quot-instances/m-p/12995225#M3298</guid>
      <dc:creator>floretti</dc:creator>
      <dc:date>2024-09-02T07:10:13Z</dc:date>
    </item>
    <item>
      <title>Re: Select all "UI visible" instances</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/select-all-quot-ui-visible-quot-instances/m-p/12995239#M3299</link>
      <description>&lt;P&gt;Yes, tricky. Here are two specific solutions for other situations:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="https://forums.autodesk.com/t5/revit-api-forum/how-to-list-only-elements-that-are-quot-visible-quot-in-a-view/m-p/10663861" target="_blank"&gt;https://forums.autodesk.com/t5/revit-api-forum/how-to-list-only-elements-that-are-quot-visible-quot-in-a-view/m-p/10663861&lt;/A&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;A href="https://forums.autodesk.com/t5/revit-api-forum/selection-filter-for-only-what-is-visible-from-camera/m-p/12534209" target="_blank"&gt;https://forums.autodesk.com/t5/revit-api-forum/selection-filter-for-only-what-is-visible-from-camera/m-p/12534209&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In your case, maybe the UIView can help:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="https://www.revitapidocs.com/2024/2a070256-00f0-5cab-1412-bee5bbfcfc5e.htm" target="_blank"&gt;https://www.revitapidocs.com/2024/2a070256-00f0-5cab-1412-bee5bbfcfc5e.htm&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The View element is part of the document and lives in the database. It maybe does not know how it is currently being "looked at". The UIView may know that and provides the current zoom corners from which you can determine wihether an element is currently within them or not. However, for non-planar views, you will have some intersting calculations to perform.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I used the UIView to implement a tooltip that detects which elements are visible under the cursor:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;&lt;A href="https://thebuildingcoder.typepad.com/blog/2012/10/uiview-windows-coordinates-referenceintersector-and-my-own-tooltip.html" target="_blank"&gt;https://thebuildingcoder.typepad.com/blog/2012/10/uiview-windows-coordinates-referenceintersector-and-my-own-tooltip.html&lt;/A&gt;&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Oh, and it also uses the ReferenceIntersector, also used by one of the solutions I pointed out above.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Sep 2024 07:23:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/select-all-quot-ui-visible-quot-instances/m-p/12995239#M3299</guid>
      <dc:creator>jeremy_tammik</dc:creator>
      <dc:date>2024-09-02T07:23:04Z</dc:date>
    </item>
    <item>
      <title>Re: Select all "UI visible" instances</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/select-all-quot-ui-visible-quot-instances/m-p/12995315#M3300</link>
      <description>&lt;P&gt;Amazing, thanks Jeremy. It's end of shift here in Australia but I'll check those out tomorrow as soon as I can.&lt;/P&gt;</description>
      <pubDate>Mon, 02 Sep 2024 08:11:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/select-all-quot-ui-visible-quot-instances/m-p/12995315#M3300</guid>
      <dc:creator>floretti</dc:creator>
      <dc:date>2024-09-02T08:11:56Z</dc:date>
    </item>
    <item>
      <title>Re: Select all "UI visible" instances</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/select-all-quot-ui-visible-quot-instances/m-p/12996479#M3301</link>
      <description>Amazing, thanks Jeremy. The GetZoomCorners() method is exactly what I need. Much appreciated. &lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;&lt;span class="lia-unicode-emoji" title=":smiling_face_with_smiling_eyes:"&gt;😊&lt;/span&gt;</description>
      <pubDate>Mon, 02 Sep 2024 22:48:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/select-all-quot-ui-visible-quot-instances/m-p/12996479#M3301</guid>
      <dc:creator>floretti</dc:creator>
      <dc:date>2024-09-02T22:48:52Z</dc:date>
    </item>
    <item>
      <title>Re: Select all "UI visible" instances</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/select-all-quot-ui-visible-quot-instances/m-p/12996530#M3302</link>
      <description>&lt;P&gt;Just giving back.&amp;nbsp;&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note this only works with family instances and it won't work with system families.&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;// Get active view's zoom
var zoomCorners = new List&amp;lt;XYZ&amp;gt;();

var openUIviews = uidoc.GetOpenUIViews();
foreach (var uiView in openUIviews)
{
	if(uiView.ViewId == doc.ActiveView.Id) zoomCorners = uiView.GetZoomCorners().ToList();
}

// Get selection and expand it
var selIds = uidoc.Selection.GetElementIds();
var finalSelectionIds = new List&amp;lt;ElementId&amp;gt;();

foreach (ElementId id in selIds)
{
	Outline viewExtents = new Outline(new XYZ(zoomCorners.First().X, zoomCorners.First().Y, -1000),
									  new XYZ(zoomCorners.Last().X, zoomCorners.Last().Y, 1000));
	var filter = new BoundingBoxIntersectsFilter(viewExtents);

	var famInst = doc.GetElement(id) as FamilyInstance;
	var allFamInst = new FilteredElementCollector(doc, doc.ActiveView.Id)
						.WherePasses(filter)
						.OfClass(typeof(FamilyInstance))
						.Cast&amp;lt;FamilyInstance&amp;gt;()
						.Where(x =&amp;gt; x.Symbol.Family.Name.Equals(famInst.Symbol.Family.Name)) // family
						.Where(x =&amp;gt; x.Name.Equals(famInst.Name)); // family type

	foreach (FamilyInstance item in allFamInst)
	{
		finalSelectionIds.Add(item.Id);
	}
}

uidoc.Selection.SetElementIds(finalSelectionIds);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Sep 2024 23:39:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/select-all-quot-ui-visible-quot-instances/m-p/12996530#M3302</guid>
      <dc:creator>floretti</dc:creator>
      <dc:date>2024-09-02T23:39:10Z</dc:date>
    </item>
  </channel>
</rss>

