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). I need to do this for 1000s of elements so this method will take hours to run.
Does anyone have any ideas to get Item Type property values extracted to a List faster? I am using the latest version of Microstation (U17.1).
Note that it looks to bog down for string values that were generated from Expressions.
using Bentley.DgnPlatformNET; using Bentley.DgnPlatformNET.DgnEC; using Bentley.DgnPlatformNET.Elements; using Bentley.ECObjects; using Bentley.ECObjects.Instance; CustomItemHost customItemHost = new CustomItemHost(element, false); IEnumerator<IDgnECInstance> customItemList = customItemHost.CustomItems.GetEnumerator(); while (customItemList.MoveNext()) { IDgnECInstance customItem = customItemList.Current; ItemType itemType = null; foreach (ItemTypeLibrary itemTypeLibrary in ItemTypeLibraries) { if (itemTypeLibrary.HasInstancesInFile && itemTypeLibrary.ItemTypeCount > 0) { itemType = itemTypeLibrary.GetItemTypeByName(customItem.ClassDefinition.Name); if (itemType = null) { break; } CustomPropertyContainer itemTypeCont = itemType; foreach (CustomProperty customProperty1 in itemTypeCont) { if (customProperty1 != null) { string propName = customProperty1.InternalName; object propValOut = null; IECPropertyValue propVal = null; propVal = customItem.GetPropertyValue(propName); int type = (int)customProperty1.Type; if (type == 0) { propValOut = Convert.ToBoolean(propVal.IntValue); } else if (type == 2) { propValOut = propVal.DoubleValue; } else if (type == 3) { propValOut = propVal.IntValue; } else if (type == 4) { DPoint3d dpoint3d = DPoint3d.FromXY(0.0, 0.0); dpoint3d = (DPoint3d)propVal.NativeValue; propValOut = (string)(dpoint3d.X + "," + dpoint3d.Y); } else if (type == 5) { propValOut = propVal.StringValue; } else { propValOut = propVal.NativeValue; } } } } }
Regards,
Mark
Hi Mark,
Mark Shamoun said:takes 7 seconds per element that has approx 20 values
7 seconds sounds absurdly slow, I would expect something like 7 ms.
Mark Shamoun said:I am trying to cycle through the elements in a dgn model and extract all Item Type property values
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.
Are you interested in all EC data (both intrinsic and extrinsic), or specifically in Items, created by a used as Item Types?
Mark Shamoun said:Note that it looks to bog down for string values that were generated from Expressions.
Despite of it may be true, I don't think so: In OpenRoads Designer presentation it was mentioned that expressions cause some slow-down, but it would be minimal.
With regards,
Jan
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point