<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://communities.bentley.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>[CONNECT C#] Faster method to extract all element Item Type Property values?</title><link>https://communities.bentley.com/products/programming/microstation_programming/f/microstation-programming---forum/236984/connect-c-faster-method-to-extract-all-element-item-type-property-values</link><description>Hi all, 
 
 I am trying to cycle through the elements in a dgn model and extract all Item Type property values for them but am finding that the EC IDgnInstance GetPropertyValue method is quite slow (takes 7 seconds per element that has approx 20 values</description><dc:language>en-US</dc:language><generator>Telligent Community 12</generator><item><title>RE: [CONNECT C#] Faster method to extract all element Item Type Property values?</title><link>https://communities.bentley.com/thread/760259?ContentTypeID=1</link><pubDate>Sat, 01 Apr 2023 04:08:38 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:fdb1bc4c-1f13-4122-bcb9-4fb27a74b9e5</guid><dc:creator>Mark Shamoun</dc:creator><description>&lt;p&gt;Hi Jan,&lt;/p&gt;
&lt;p&gt;Looking at this further, it looks like every time any IIF statement is trying to access an Item Type that contains an expression, that expression is reevaluated. Based on the nature of EC expressions that behaviour makes sense, however is extremely expensive performance wise for any practical use of a value derived from an Expression elsewhere.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Having the ability to access these values &amp;quot;read-only&amp;quot; surely would aid in general performance increases for operations on Expressions globally surely? I&amp;#39;m seeing that reevaluation looks to be also happening with data from read-only sources like external references.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="/resized-image/__size/640x480/__key/communityserver-discussions-components-files/343173/issue.JPG" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: [CONNECT C#] Faster method to extract all element Item Type Property values?</title><link>https://communities.bentley.com/thread/741422?ContentTypeID=1</link><pubDate>Fri, 11 Nov 2022 06:43:53 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:89ee0321-f519-41e1-98d3-180ee8eb40b7</guid><dc:creator>Jan Šlegr</dc:creator><description>&lt;p&gt;Hi Mark,&lt;/p&gt;
[quote userid="334014" url="~/products/programming/microstation_programming/f/microstation-programming---forum/236984/connect-c-faster-method-to-extract-all-element-item-type-property-values/741034"]Why would this be the case?[/quote]
&lt;p&gt;I think it&amp;#39;s hard to guess without knowing how individual functions are implemented.&lt;/p&gt;
[quote userid="334014" url="~/products/programming/microstation_programming/f/microstation-programming---forum/236984/connect-c-faster-method-to-extract-all-element-item-type-property-values/741034"]but we have confirmed that the GetRelatedInstance expression has minimal effects on performance.[/quote]
&lt;p&gt;To reference related instance is efficient, because it is already existing relationship, so&amp;nbsp;(I guess)&amp;nbsp;the only difference is that one more extra EC instance must be read.&lt;/p&gt;
[quote userid="334014" url="~/products/programming/microstation_programming/f/microstation-programming---forum/236984/connect-c-faster-method-to-extract-all-element-item-type-property-values/741034"]It seems that calculated values using IIF statements is slowing down the extraction of these properties substantially.[/quote]
&lt;p&gt;I do not think IIF itself is slow (although as I wrote, nobody know how exactly it is implemented ;-). But the used conditions, based on string operations, can be expensive (generally, in software development, string operations are one from the most expensive, because when not used carefully, require plenty of memory allocations and data iteration and comparing).&lt;/p&gt;
&lt;p&gt;I think, when complete data is available, it would be possible (at least for NET code) to do some benchmarks, to see what code is (A) called the most often and (B) what method in code consumes the most time.&lt;/p&gt;
&lt;p&gt;With regards,&lt;/p&gt;
&lt;p&gt;&amp;nbsp; Jan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: [CONNECT C#] Faster method to extract all element Item Type Property values?</title><link>https://communities.bentley.com/thread/741034?ContentTypeID=1</link><pubDate>Wed, 09 Nov 2022 12:13:34 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:76127549-3dba-4ecd-b207-b7bdab7e65c2</guid><dc:creator>Mark Shamoun</dc:creator><description>&lt;p&gt;Hi all,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;We think we are closer to tracking down the issue. It seems that calculated values using IIF statements is slowing down the extraction of these properties substantially. Why would this be the case?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Attached are the expressions we are using. Note that this was made for Civil GetRelatedInstance expressions, hence all references to corridors, etc. but we have confirmed that the GetRelatedInstance expression has minimal effects on performance.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://communities.bentley.com/cfs-file/__key/communityserver-discussions-components-files/343173/TfNSW_5F00_DE_5F00_Data_5F00_Arcadis.xlsx"&gt;communities.bentley.com/.../TfNSW_5F00_DE_5F00_Data_5F00_Arcadis.xlsx&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: [CONNECT C#] Faster method to extract all element Item Type Property values?</title><link>https://communities.bentley.com/thread/737148?ContentTypeID=1</link><pubDate>Tue, 18 Oct 2022 07:48:17 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:f5ca1803-9f6c-4b5b-8510-1c9d47a9bbe3</guid><dc:creator>Mark Shamoun</dc:creator><description>&lt;p&gt;Thanks guys, will do&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: [CONNECT C#] Faster method to extract all element Item Type Property values?</title><link>https://communities.bentley.com/thread/737124?ContentTypeID=1</link><pubDate>Tue, 18 Oct 2022 06:35:10 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:f6a9d94a-7147-431f-bf43-bddc056f878b</guid><dc:creator>Mangesh.Shelar</dc:creator><description>&lt;p&gt;CpropertyHandler is a COM wrapper over native ECInstance. When you call GetDisplayString or GetValue, we are directly returning a native value. It doesn&amp;#39;t involve managed-to-native marshalling and no intermediate callbacks. Moreover, when you try Civil elements at managed layer, I am doubting that they may have many other handlers or callbacks which might make things slower.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Mark, please raise this to Civil.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: [CONNECT C#] Faster method to extract all element Item Type Property values?</title><link>https://communities.bentley.com/thread/737118?ContentTypeID=1</link><pubDate>Tue, 18 Oct 2022 06:10:12 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:c142e518-8cc0-431d-ae09-3b51700e5901</guid><dc:creator>Jan Šlegr</dc:creator><description>[quote userid="334014" url="~/products/programming/microstation_programming/f/microstation-programming---forum/236984/connect-c-faster-method-to-extract-all-element-item-type-property-values/736979"]Interestingly, using Interop Property Handler to read the Property values is exponentially faster.[/quote]
&lt;p&gt;Wow, it is something I did not expect  &lt;/p&gt;
&lt;p&gt;&lt;a href="/members/9b2e18a2_2d00_f09e_2d00_4c49_2d00_bb42_2d00_66dd47c08ffb"&gt;Mangesh.Shelar&lt;/a&gt; Is there any reason for the behavior Mark described?&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;&amp;nbsp; Jan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: [CONNECT C#] Faster method to extract all element Item Type Property values?</title><link>https://communities.bentley.com/thread/736979?ContentTypeID=1</link><pubDate>Mon, 17 Oct 2022 14:03:08 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:f723222c-1c68-459e-bfac-61504e0bca8e</guid><dc:creator>Mark Shamoun</dc:creator><description>&lt;p&gt;Interestingly, using Interop Property Handler to read the Property values is exponentially faster. I&amp;#39;m thinking this may&amp;nbsp;not be re-evauating the same way as&amp;nbsp;EC direct methods. A little more messy than i was after, but SEEMS to work well...&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="csharp"&gt; List&amp;lt;PropertySetIfc&amp;gt; properties = new List&amp;lt;PropertySetIfc&amp;gt;();
                            CustomItemHost host = new CustomItemHost(meshHeader, false);
                            IList&amp;lt;IDgnECInstance&amp;gt; items = host.CustomItems;

                            BIM.Element eleInter = ElementOperation.ConvertToInteropEle(meshHeader);
                            BIM.PropertyHandler oProps = BMI.Utilities.ComApp.CreatePropertyHandler(eleInter);

                            foreach (IDgnECInstance item in items)
                            {
                                PropertySetIfc ps = new PropertySetIfc(item.ClassDefinition.Name, &amp;quot;&amp;quot;);
                                IEnumerable&amp;lt;IECProperty&amp;gt; itemProperties = item.ClassDefinition.Properties(false);

                                foreach (IECProperty itemProperty in itemProperties)
                                {
                                    string itemPropName = itemProperty.Name;
                                    MessageCenter.Instance.ShowMessage(MessageType.TempRight, &amp;quot;Scanning active model...Scanning Mesh &amp;quot; + (csCount + 1).ToString() + &amp;quot; of &amp;quot; + meshCount.ToString() + &amp;quot; &amp;gt; reading Item Type: &amp;quot; + itemPropName, &amp;quot;&amp;quot;, MessageAlert.None);
                                    string unitName = &amp;quot;&amp;quot;;
                                    object propValOut = null;

                                    try
                                    {

                                        oProps.GetAccessStrings();
                                        if (oProps.SelectByAccessString(itemPropName))
                                        {
                                            object propVal = oProps.GetDisplayString();
                                            propValOut = propVal;
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: [CONNECT C#] Faster method to extract all element Item Type Property values?</title><link>https://communities.bentley.com/thread/736964?ContentTypeID=1</link><pubDate>Mon, 17 Oct 2022 12:59:55 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:fd475620-2f24-4397-a0f2-edd809febeab</guid><dc:creator>Jan Šlegr</dc:creator><description>[quote userid="334014" url="~/products/programming/microstation_programming/f/microstation-programming---forum/236984/connect-c-faster-method-to-extract-all-element-item-type-property-values/736953"]but there is one creative GetRelatedInstance expression that may be exacerbating the whole thing.[/quote]
&lt;p&gt;Personally I do not think the usage of related instance can cause any substantial slow down: the relation between EC classes is a part of native EC data, so to read the relation definition to obtain access to target instance should be equally fast as to read normal EC data. Of course it depends how GetRelatedInstance method is implemented, but at least, it is about access inside DGN.&lt;/p&gt;
[quote userid="334014" url="~/products/programming/microstation_programming/f/microstation-programming---forum/236984/connect-c-faster-method-to-extract-all-element-item-type-property-values/736953"]Noting that the majority of values are Excel lookup string values[/quote]
&lt;p&gt;I have no experience with lookup tables in Excel, when used from Item Types, but I can imagine it can be slow, because external file must be opened and read.&lt;/p&gt;
&lt;p&gt;It would be great if somebody from Bentley is able to share best practices and what to check, when external tables are used so masivelly.&lt;/p&gt;
&lt;p&gt;With regards,&lt;/p&gt;
&lt;p&gt;&amp;nbsp; Jan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: [CONNECT C#] Faster method to extract all element Item Type Property values?</title><link>https://communities.bentley.com/thread/736953?ContentTypeID=1</link><pubDate>Mon, 17 Oct 2022 11:57:40 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:b4eb74e2-9bc1-4a4d-83e5-45788db38b27</guid><dc:creator>Mark Shamoun</dc:creator><description>&lt;p&gt;True, but the speed in extracting Item Type values i am finding here in isolation correlates to the speed it is taking to export to IFC, eg. 1350 elements taking 7 seconds to read Item Types per element = 2.6 hours. Noting that the majority of values are Excel lookup string values, but there is one creative GetRelatedInstance expression that may be exacerbating the whole thing.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;ll keep experimenting and see if i find something. Thanks for all the help, it is very good information.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: [CONNECT C#] Faster method to extract all element Item Type Property values?</title><link>https://communities.bentley.com/thread/736951?ContentTypeID=1</link><pubDate>Mon, 17 Oct 2022 11:53:48 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:03db1968-189b-4c3a-aaab-806771cb4ec0</guid><dc:creator>Jan Šlegr</dc:creator><description>[quote userid="334014" url="~/products/programming/microstation_programming/f/microstation-programming---forum/236984/connect-c-faster-method-to-extract-all-element-item-type-property-values/736950"] In both 10.10 and 10.11 it takes us hours (3-4) to write an IFC that includes Item Type data, and when no Item Type data is included it takes 5-10 minutes.[/quote]
&lt;p&gt;It tells more than IFC export is implemented in a wrong way than Item Types are slow.&lt;/p&gt;
[quote userid="334014" url="~/products/programming/microstation_programming/f/microstation-programming---forum/236984/connect-c-faster-method-to-extract-all-element-item-type-property-values/736950"]Unfortunately we can&amp;#39;t simplify our Item Types any more to get the automation we are looking for[/quote]
&lt;p&gt;I think you moved the discussion focus: Now it seems that it&amp;#39;s not about &amp;quot;fast Item Type exctaction&amp;quot;, because in general, there is no slow done and is really fast, but about to analyze why the evaluation of EC Expressions, that you use, seems to slow down the whole process.&lt;/p&gt;
&lt;p&gt;But, because nobody saw the expressions, it&amp;#39;s hard to even guess... And I would assume such analysis requires a knowledge of ORD internals.&lt;/p&gt;
&lt;p&gt;With regards,&lt;/p&gt;
&lt;p&gt;&amp;nbsp; Jan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: [CONNECT C#] Faster method to extract all element Item Type Property values?</title><link>https://communities.bentley.com/thread/736950?ContentTypeID=1</link><pubDate>Mon, 17 Oct 2022 11:44:26 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:c11ef062-03d5-47fe-b2a2-f476d0525995</guid><dc:creator>Mark Shamoun</dc:creator><description>[quote userid="2473" url="~/products/programming/microstation_programming/f/microstation-programming---forum/236984/connect-c-faster-method-to-extract-all-element-item-type-property-values/736948"]&lt;p&gt;Maybe to ensure Expression are written in efficient way is bettersolution. Although I alwyas tell and write that Expressions represents overhed and it is not &amp;quot;an aid for everything and anything&amp;quot;, I do not recall realy issue with Expressions. And what I remember from a presentation about Item Types new features in ORD 10.11, it was mentioned that even hundreds thousands of attache items, with expressions defined, does not cause any substatnial slow down.&lt;/p&gt;
&lt;p&gt;Or maybe it is the issue of 10.09 / 10.10? Did you try it with 10.11?&lt;/p&gt;[/quote]
&lt;p&gt;Funny you say that, the aim of this code is to resolve an issue with IFC export of ORD 10.11. In both 10.10 and 10.11 it takes us hours (3-4) to write an IFC that includes Item Type data, and when no Item Type data is included it takes 5-10 minutes. It is looking like this issue is the culprit. Unfortunately we can&amp;#39;t simplify our Item Types any more to get the automation we are looking for, but need to find a faster way to extract data out of our models. Even exporting Item Type data using the Excel Export Instances tool takes a very long time - something our users have started to do to reimport &amp;quot;static&amp;quot; data just for export.&lt;/p&gt;
&lt;p&gt;There have been performance gains in ORD 10.11 in this regard, but nothing substantial enough to save hours in this regard unfortunately.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: [CONNECT C#] Faster method to extract all element Item Type Property values?</title><link>https://communities.bentley.com/thread/736948?ContentTypeID=1</link><pubDate>Mon, 17 Oct 2022 11:33:53 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:edf4d791-21c7-428a-93a4-8bfc21f310c4</guid><dc:creator>Jan Šlegr</dc:creator><description>[quote userid="334014" url="~/products/programming/microstation_programming/f/microstation-programming---forum/236984/connect-c-faster-method-to-extract-all-element-item-type-property-values/736944"]I take it there is no &amp;quot;Read-only&amp;quot; method to evaluate the Item Type values?[/quote]
&lt;p&gt;I think there is no such method.&lt;/p&gt;
&lt;p&gt;I am not sure (but maybe &lt;a href="/members/9b2e18a2_2d00_f09e_2d00_4c49_2d00_bb42_2d00_66dd47c08ffb"&gt;Mangesh.Shelar&lt;/a&gt; can explain this aspect), but maybe when EC Expression is defined, and &amp;quot;Use last valid value&amp;quot; is not used, the value is not even stored and is alwyas recalculated?&lt;/p&gt;
&lt;p&gt;Maybe to ensure Expression are written in efficient way is bettersolution. Although I alwyas tell and write that Expressions represents overhed and it is not &amp;quot;an aid for everything and anything&amp;quot;, I do not recall realy issue with Expressions. And what I remember from a presentation about Item Types new features in ORD 10.11, it was mentioned that even hundreds thousands of attache items, with expressions defined, does not cause any substatnial slow down.&lt;/p&gt;
&lt;p&gt;Or maybe it is the issue of 10.09 / 10.10? Did you try it with 10.11?&lt;/p&gt;
[quote userid="334014" url="~/products/programming/microstation_programming/f/microstation-programming---forum/236984/connect-c-faster-method-to-extract-all-element-item-type-property-values/736944"]Would VBA interop methods like Property Handler&amp;nbsp;behave the same way?[/quote]
&lt;p&gt;Yes. As far as I know, at background PropertyHandler use code close to &lt;em&gt;Properties&lt;/em&gt; dialog, so I assume EC Expressions are evaluated too.&lt;/p&gt;
&lt;p&gt;With regards,&lt;/p&gt;
&lt;p&gt;&amp;nbsp; Jan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: [CONNECT C#] Faster method to extract all element Item Type Property values?</title><link>https://communities.bentley.com/thread/736944?ContentTypeID=1</link><pubDate>Mon, 17 Oct 2022 11:17:44 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:2389f29f-859b-4409-88b2-88878f2ddc98</guid><dc:creator>Mark Shamoun</dc:creator><description>&lt;p&gt;Thanks Jan,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;That is very helpful. I take it there is no &amp;quot;Read-only&amp;quot; method to evaluate the Item Type values? Would VBA interop methods like Property Handler&amp;nbsp;behave the same way?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: [CONNECT C#] Faster method to extract all element Item Type Property values?</title><link>https://communities.bentley.com/thread/736941?ContentTypeID=1</link><pubDate>Mon, 17 Oct 2022 10:47:21 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:0b2bb1c2-6e1c-44c5-8db4-040bc6612418</guid><dc:creator>Jan Šlegr</dc:creator><description>&lt;p&gt;Hi Mark,&lt;/p&gt;
[quote userid="334014" url="~/products/programming/microstation_programming/f/microstation-programming---forum/236984/connect-c-faster-method-to-extract-all-element-item-type-property-values/736933"]it seems like the Item Type expressions are being recalculated as the item types are being read[/quote]
&lt;p&gt;Yes, it is how EC Expressions are designed: They are evaluated every time the value &amp;quot;is asked&amp;quot; (like an element is selected and displayed in Properties dialog or the data is read by code).&lt;/p&gt;
[quote userid="334014" url="~/products/programming/microstation_programming/f/microstation-programming---forum/236984/connect-c-faster-method-to-extract-all-element-item-type-property-values/736933"]The ones which have if statements involving numerical calcs run slower than the rest and some based on Expressions with a State value of &amp;quot;NotYetCalculated&amp;quot; take even longer.[/quote]
&lt;p&gt;I do not recall any sych benchmarks. EC Expressions are &amp;quot;just string&amp;quot;, that is evaluated and interpreted when used. So there is alwas some overhead, because string operations are expensive, but it&amp;#39;s typically not an issue. So I assume the real source of the slowness are expressions itself or how the symbol provider is implemented.&lt;/p&gt;
&lt;p&gt;I think there are not best practices available how to write efficient Expression (and what to don&amp;#39;t do), it&amp;#39;s more &amp;quot;knowledge based&amp;quot; process.&lt;/p&gt;
&lt;p&gt;To evaluate what Expression slows down the process, I can imagine to add a filter to code, so only not calculated properties are processed. If the different is big, it makes sense to analyze expressions step by step.&lt;/p&gt;
[quote userid="334014" url="~/products/programming/microstation_programming/f/microstation-programming---forum/236984/connect-c-faster-method-to-extract-all-element-item-type-property-values/736933"]I&amp;#39;ll be trying Manesh&amp;#39;s suggestion to see if it helps.[/quote]
&lt;p&gt;I think Mangesh&amp;#39;s approach is nearly eqaul to my code. The main difference is that I do not use EC Query to access (potentiall all) EC data, because you mentioned you are interested in Item Types only. &lt;/p&gt;
&lt;p&gt;When you have ECInstance and you know ECClass, how to access propertis values are always the same.&lt;/p&gt;
&lt;p&gt;With regards,&lt;/p&gt;
&lt;p&gt;&amp;nbsp; Jan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: [CONNECT C#] Faster method to extract all element Item Type Property values?</title><link>https://communities.bentley.com/thread/736933?ContentTypeID=1</link><pubDate>Mon, 17 Oct 2022 10:12:40 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:63280ad0-2339-4adc-adeb-e92b33cf0a0e</guid><dc:creator>Mark Shamoun</dc:creator><description>&lt;p&gt;Thanks Jan, that looks to be much more cleaner than what i had and works a bit better.&lt;/p&gt;
&lt;p&gt;it is a bit faster, but still much more excessive than expected - it seems like the Item Type expressions are being recalculated as the item types are being read into my code. The ones which have if statements involving numerical calcs run slower than the rest and some based on Expressions with a State value of &amp;quot;NotYetCalculated&amp;quot; take even longer.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I am only really interested in extracting the Item Type text and numerical values per element for an export addin i am putting together. I&amp;#39;ll be trying Manesh&amp;#39;s suggestion to see if it helps. There looks to be something strange happening with these Expressions...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: [CONNECT C#] Faster method to extract all element Item Type Property values?</title><link>https://communities.bentley.com/thread/736884?ContentTypeID=1</link><pubDate>Mon, 17 Oct 2022 05:43:45 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:5998e835-7e1b-4af3-ab8a-44a8fff664c4</guid><dc:creator>Mangesh.Shelar</dc:creator><description>&lt;p&gt;Hi Mark,&lt;/p&gt;
&lt;p&gt;Your code snippet will be slower. You are iterating each element, then for each element, you are doing&amp;nbsp;itemTypeLibrary.HasInstancesInFile. This method will query the whole dgn to check if all library classes have instances. I think you don&amp;#39;t need the following loop:&lt;/p&gt;
&lt;p&gt;foreach (ItemTypeLibrary itemTypeLibrary in ItemTypeLibraries)&lt;br /&gt; {&lt;br /&gt; if (itemTypeLibrary.HasInstancesInFile &amp;amp;&amp;amp; itemTypeLibrary.ItemTypeCount &amp;gt; 0)&lt;br /&gt; {&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;And, with Direct EC APIs you can avoid iterating all elements:&lt;/p&gt;
&lt;p&gt;1. Create ECQuery for all classes.&amp;nbsp;&amp;nbsp;ECQuery readGadget = new ECQuery(&amp;lt;list of all classes&amp;gt;);readGadget.SelectClause.SelectAllProperties = true;&lt;/p&gt;
&lt;p&gt;2. Create scope:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;FindInstancesScope scope = FindInstancesScope.CreateScope(activeDgnModel.GetDgnFile(), new FindInstancesScopeOption(DgnECHostType.Element));&lt;/p&gt;
&lt;p&gt;3. Execute:&lt;/p&gt;
&lt;p&gt;DgnECInstanceCollection instanceCollection = dgnECManager.FindInstances(scope, readGadget);&lt;/p&gt;
&lt;p&gt;Please&amp;nbsp;try SDK sample:&amp;nbsp;MstnExamples\DgnEC\DgnECCrudExample\ManagedExample.&lt;/p&gt;
&lt;p&gt;Thanks,&lt;/p&gt;
&lt;p&gt;Mangesh&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: [CONNECT C#] Faster method to extract all element Item Type Property values?</title><link>https://communities.bentley.com/thread/736794?ContentTypeID=1</link><pubDate>Fri, 14 Oct 2022 17:58:10 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:02b387aa-c787-4b35-90b2-ef930f7112c8</guid><dc:creator>Jan Šlegr</dc:creator><description>&lt;p&gt;Hi Mark,&lt;/p&gt;
&lt;p&gt;I do not know a structure of your files, but code similar to this one should work. I had no time to test it in detail, but it lists &amp;quot;something&amp;quot; when used with simple test DGN.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="csharp"&gt;DgnModel dgnModel = Session.Instance.GetActiveDgnModel();
ModelElementsCollection elements = dgnModel.GetGraphicElements();

foreach (Element element in elements)
{
    CustomItemHost host = new CustomItemHost(element, false);

    IList&amp;lt;IDgnECInstance&amp;gt; items = host.CustomItems;

    foreach (IDgnECInstance item in items)
    {
        IEnumerable&amp;lt;IECProperty&amp;gt; properties = item.ClassDefinition.Properties(false);

        StringBuilder sb = new StringBuilder();

        foreach (IECProperty property in properties)
        {
            IECPropertyValue value = item.GetPropertyValue(property.Name);

            if (value is null) { continue; }

            sb.AppendLine($&amp;quot;Property &amp;#39;{property.DisplayLabel}&amp;#39; = {value.StringValue} &amp;quot;);
        }

        string msg = $&amp;quot;Element id {element.ElementId} / Item {item.ClassDefinition.DisplayLabel}&amp;quot;;
        string details = sb.ToString();
        NotifyMessageDetails message = new NotifyMessageDetails(OutputMessagePriority.Information, msg, details, NotifyTextAttributes.None, OutputMessageAlert.None);
        NotificationManager.OutputMessage(message);
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;There is a space for improvements, like to use value formatters, plus this snippet does not support arrays.&lt;/p&gt;
&lt;p&gt;With regards,&lt;/p&gt;
&lt;p&gt;&amp;nbsp; Jan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: [CONNECT C#] Faster method to extract all element Item Type Property values?</title><link>https://communities.bentley.com/thread/736778?ContentTypeID=1</link><pubDate>Fri, 14 Oct 2022 16:00:58 GMT</pubDate><guid isPermaLink="false">6dad98f5-dbc9-4c4d-a9ba-e9da8dc6aa8e:51c49d5a-8d0f-4668-a44a-d3de60f98d98</guid><dc:creator>Jan Šlegr</dc:creator><description>&lt;p&gt;Hi Mark,&lt;/p&gt;
[quote userid="334014" url="~/products/programming/microstation_programming/f/microstation-programming---forum/236984/connect-c-faster-method-to-extract-all-element-item-type-property-values"]takes 7 seconds per element that has approx 20 values[/quote]
&lt;p&gt;7 seconds sounds absurdly slow, I would expect something like 7 ms.&lt;/p&gt;
[quote userid="334014" url="~/products/programming/microstation_programming/f/microstation-programming---forum/236984/connect-c-faster-method-to-extract-all-element-item-type-property-values"]I am trying to cycle through the elements in a dgn model and extract all Item Type property values[/quote]
&lt;p&gt;I do not work with Item Types API, as I typically use general EC data API for my own data structures, so my knowledge is limited a bit, but your code looks weird. I must think about it.&lt;/p&gt;
&lt;p&gt;Are you interested in all EC data (both intrinsic and extrinsic), or specifically in Items, created by a used as Item Types?&lt;/p&gt;
[quote userid="334014" url="~/products/programming/microstation_programming/f/microstation-programming---forum/236984/connect-c-faster-method-to-extract-all-element-item-type-property-values"]Note that it looks to bog down for string values that were generated from Expressions.[/quote]
&lt;p&gt;Despite of it may be true, I don&amp;#39;t think so: In OpenRoads Designer presentation it was mentioned that expressions cause some slow-down, but it would be minimal.&lt;/p&gt;
&lt;p&gt;With regards,&lt;/p&gt;
&lt;p&gt;&amp;nbsp; Jan&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>