<?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: WPF - Window With TreeView - Slow Load With Virtualization in Revit API Forum</title>
    <link>https://forums.autodesk.com/t5/revit-api-forum/wpf-window-with-treeview-slow-load-with-virtualization/m-p/8629976#M44098</link>
    <description>&lt;P&gt;Edited and shared for posterity by The Building Coder:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://thebuildingcoder.typepad.com/blog/2019/03/forum-fran%C3%A7ais-and-treeview-performance.html" target="_blank"&gt;https://thebuildingcoder.typepad.com/blog/2019/03/forum-fran%C3%A7ais-and-treeview-performance.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you again!&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 01 Mar 2019 11:48:21 GMT</pubDate>
    <dc:creator>jeremytammik</dc:creator>
    <dc:date>2019-03-01T11:48:21Z</dc:date>
    <item>
      <title>WPF - Window With TreeView - Slow Load With Virtualization</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/wpf-window-with-treeview-slow-load-with-virtualization/m-p/8609110#M44094</link>
      <description>&lt;P&gt;A tool i'm building has a TreeView Control (Telerik RadTreeView) which will show all element instances in a Project/Active/Selection. The problem is that even with &lt;A href="https://docs.telerik.com/devtools/wpf/controls/radgridview/features/ui-virtualization" target="_blank" rel="noopener"&gt;UI Virtualization &lt;/A&gt;the window load times are far too long. I'm not sure what to suspect now and am hoping one of the community has ran across this.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Some examples of window load times below.&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Project with around 150,000 model Element Instances it takes about 2 minutes to build.&lt;/LI&gt;
&lt;LI&gt;Project with around 66,000&amp;nbsp;model Element Instances it takes about a minute to build&lt;/LI&gt;
&lt;LI&gt;Project with less than 400 model Element Instances it takes about 5 seconds to build&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is some additional pertinent information .&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;I'm using WPF / XAML / MVVM / C# to build it.&lt;/LI&gt;
&lt;LI&gt;Ive timed the Filtered Element Collectors and found they are incredible fast and dont seem to be the issue.&lt;/LI&gt;
&lt;LI&gt;Ive submitted a support ticket to Telerik which only confirmed that the code should be working and does outside of Revit where I can create 180000 objects into 4 tiers in seconds.&lt;/LI&gt;
&lt;LI&gt;There are 4 tiers (See screenshot 1) of data arranged in the following manner
&lt;UL&gt;
&lt;LI&gt;Tier 1: Category
&lt;UL&gt;
&lt;LI&gt;Tier 2: Family Name
&lt;UL&gt;
&lt;LI&gt;Tier 3: Type
&lt;UL&gt;
&lt;LI&gt;Tier 4: Instance&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;/UL&gt;
&lt;/LI&gt;
&lt;LI&gt;The TreeView is initially fully collapsed with only the first tier showing.&lt;/LI&gt;
&lt;LI&gt;Ive enabled UI Virtualization to show more as a user expands each node.&lt;/LI&gt;
&lt;LI&gt;Ive attached a zip file with the code in question&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Screenshot #1&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SS1.png" style="width: 424px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/605337i1B28C3390A92800F/image-size/large?v=v2&amp;amp;px=999" role="button" title="SS1.png" alt="SS1.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Screenshot #2&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="SS2.png" style="width: 504px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/605338i40A7C041A5B53F33/image-size/large?v=v2&amp;amp;px=999" role="button" title="SS2.png" alt="SS2.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 20 Feb 2019 17:32:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/wpf-window-with-treeview-slow-load-with-virtualization/m-p/8609110#M44094</guid>
      <dc:creator>TheRealChrisHildebran</dc:creator>
      <dc:date>2019-02-20T17:32:40Z</dc:date>
    </item>
    <item>
      <title>Re: WPF - Window With TreeView - Slow Load With Virtualization</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/wpf-window-with-treeview-slow-load-with-virtualization/m-p/8610488#M44095</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Dear Chris,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Thank you for your query.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I would suggest initially populating only the Tier 1, and then populating the other ones and their subnodes on demand when clicked by the user to open them.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;If a specific node is never opened, there is no need to ever load its subnodes.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I am sure such techniques have already been implemented and published in the past.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;In fact, I see a large number of solutions when searching the Internet for 'populate tree view on demand':&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&lt;A href="https://duckduckgo.com/?q=populate+tree+view+on+demand" target="_blank"&gt;https://duckduckgo.com/?q=populate+tree+view+on+demand&lt;/A&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I hope this helps.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Best regards,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Jeremy&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Feb 2019 06:51:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/wpf-window-with-treeview-slow-load-with-virtualization/m-p/8610488#M44095</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2019-02-21T06:51:18Z</dc:date>
    </item>
    <item>
      <title>Re: WPF - Window With TreeView - Slow Load With Virtualization</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/wpf-window-with-treeview-slow-load-with-virtualization/m-p/8622528#M44096</link>
      <description>&lt;P&gt;Jeremy, thank you for your suggestions and for continuing to help me and the community!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Much has happened since last Wednesday and i can report back that i now have a virtualized TreeView which will quickly handles projects with 200,000+ model elements!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I will gladly share this solution with any needing it so if you're interested please contact me.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Initially, my inexperience drove me to go the "safe" route towards populating the TreeView but on thursday i deleted most of what id done and fully embraced MVVM and working with Objects, in an object, in an object, in an object! Was a mind melter for me but it really paid off!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The method below is truly the meat of the solution and along with the XAML in the previously attached ZIP file make it work. Way shorter and simpler than i thought it would be.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;private static void InitializeDataSource()
		{
			Tier1CategoryNames = new ObservableCollection&amp;lt;Tier1Object&amp;gt;();
			Tier1Object tier1Object = null;
			Tier2Object tier2Object = null;
			Tier3Object tier3Object = null;
			Tier4Object tier4Object = null;

			foreach(var revitElementInstance in _revitElementInstances)
			{
				// ########## Tier 1 Start ##########
				var currentCategoryName = revitElementInstance.Category.Name;

				if(Tier1CategoryNames.Count == 0 || Tier1CategoryNames.All(tier1Object1 =&amp;gt; tier1Object1.Tier1CategoryName != currentCategoryName))
				{
					Tier1CategoryNames.Add(tier1Object = new Tier1Object(currentCategoryName));
				}


				// ########## Tier 2 Start ##########
				var currentFamilyName = revitElementInstance.FamilyName;

				if(tier1Object.Tier2FamilyNames.Count == 0 || tier1Object.Tier2FamilyNames.All(tier2Object1 =&amp;gt; tier2Object1.Tier2FamilyName != currentFamilyName))
				{
					tier1Object.Tier2FamilyNames.Add(tier2Object = new Tier2Object(currentFamilyName));
				}


				// ########## Tier 3 Start ##########
				var currentElementTypeName = revitElementInstance.ElementType.Name;

				if(tier2Object.Tier3ElementTypeNames.Count == 0 || tier2Object.Tier3ElementTypeNames.All(tier3Object1 =&amp;gt; tier3Object1.Tier3ElementTypeName != currentElementTypeName))
				{
					tier2Object.Tier3ElementTypeNames.Add(tier3Object = new Tier3Object(currentElementTypeName));
				}


				// ########## Tier 4 Start ##########
				var currentElementInstanceName = revitElementInstance.ElementInstance.Name;

				tier3Object.Tier4ElementInstanceNames.Add(tier4Object = new Tier4Object(currentElementInstanceName));
			}
		}&lt;/PRE&gt;</description>
      <pubDate>Tue, 26 Feb 2019 17:36:59 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/wpf-window-with-treeview-slow-load-with-virtualization/m-p/8622528#M44096</guid>
      <dc:creator>TheRealChrisHildebran</dc:creator>
      <dc:date>2019-02-26T17:36:59Z</dc:date>
    </item>
    <item>
      <title>Re: WPF - Window With TreeView - Slow Load With Virtualization</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/wpf-window-with-treeview-slow-load-with-virtualization/m-p/8622720#M44097</link>
      <description>&lt;P&gt;Congratulations on the brilliant result!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sometimes it helps tremendously to start over, build on your existing experience, throw out the baggage...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you for sharing the solution.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 26 Feb 2019 18:35:09 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/wpf-window-with-treeview-slow-load-with-virtualization/m-p/8622720#M44097</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2019-02-26T18:35:09Z</dc:date>
    </item>
    <item>
      <title>Re: WPF - Window With TreeView - Slow Load With Virtualization</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/wpf-window-with-treeview-slow-load-with-virtualization/m-p/8629976#M44098</link>
      <description>&lt;P&gt;Edited and shared for posterity by The Building Coder:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://thebuildingcoder.typepad.com/blog/2019/03/forum-fran%C3%A7ais-and-treeview-performance.html" target="_blank"&gt;https://thebuildingcoder.typepad.com/blog/2019/03/forum-fran%C3%A7ais-and-treeview-performance.html&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you again!&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;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 01 Mar 2019 11:48:21 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/wpf-window-with-treeview-slow-load-with-virtualization/m-p/8629976#M44098</guid>
      <dc:creator>jeremytammik</dc:creator>
      <dc:date>2019-03-01T11:48:21Z</dc:date>
    </item>
    <item>
      <title>Re: WPF - Window With TreeView - Slow Load With Virtualization</title>
      <link>https://forums.autodesk.com/t5/revit-api-forum/wpf-window-with-treeview-slow-load-with-virtualization/m-p/9804002#M44099</link>
      <description>&lt;P&gt;Thanks.!!&amp;nbsp; it will&amp;nbsp;&lt;SPAN&gt;help&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Oct 2020 06:34:16 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/revit-api-forum/wpf-window-with-treeview-slow-load-with-virtualization/m-p/9804002#M44099</guid>
      <dc:creator>umesh.mhaskar</dc:creator>
      <dc:date>2020-10-15T06:34:16Z</dc:date>
    </item>
  </channel>
</rss>

