i have an item type that contains a property. this property has Is Array set to true and its type is a custom property type that i made.
trying to figure out how to add a value to this array property.
Not seeing it in the sdk. i see there is a XmlStringValue that is a get/set. but when i try to set it, it just crashes. assuming i cant use that to add a new value to an array but could use it to change existing values??
Anyways anyone see a way to do this. i hope im just missing it.
EDIT:
adding some code that i have, the array property is named Values, the custom type is named linker. the custom type contains several string properties...
CustomItemHost host = new CustomItemHost(Views.LinkSetup._MainWindowViewModel.selTextElement, false); IList<BD.DgnEC.IDgnECInstance> ItemTypes = host.CustomItems; //loop each itemtype attached to element foreach (BD.DgnEC.IDgnECInstance curItemType in ItemTypes) { //find item type with specfied name if (curItemType.ClassDefinition.Name.ToUpper().Contains(Globals.itemTypeName.ToUpper())) {//found, update //find array property (its named Values) foreach (var curprop in curItemType) { if (curprop.Property.DisplayLabel.ToUpper() == "VALUES") { //add entry to values array //stuck on how to do this.. //try and modify xml string to add another value to the VALUES propety (which is a custom propety tyoe named linker) string newxmlstring = curprop.XmlStringValue; newxmlstring.Replace("</Values>", ""); newxmlstring += "<linker><isFromReference>False</isFromReference><ElementID>5</ElementID><ModelName>f</ModelName><PropertyName>df</PropertyName><FilePath>test2</FilePath><PropertyType>Element</PropertyType><PropertyValue>df</PropertyValue><AccessString>afsdfdfasf</AccessString><ItemTypeName /></linker></Values>"; //causes crash curprop.XmlStringValue = newxmlstring; } } } }
i was thinking i would need to get the custom property type and populate it with what i want, then add it as a value to the item type property. but see nothing in the SDK for this...i starting to do this to get the property type...
BD.ItemTypeLibrary OHDOTLinkersLib = BD.ItemTypeLibrary.FindByName(Globals.itemTypeLibName, activeFile); BD.ItemType it_TextFieldLinker = OHDOTLinkersLib.GetItemTypeByName(Globals.itemTypeName); BD.CustomProperty itProp = it_TextFieldLinker.GetPropertyByName("Values"); BD.CustomPropertyType itPropType = OHDOTLinkersLib.GetCustomTypeByName("linker");
Editing the XML directly sounds like a recipe for disaster...
All the EC stuff originated as C# code. The API is extremely broad. I believe it is documented separately as part of the ECFramework.
In this particular case your "values" property is an IECArrayValue. IECArrayValue.Add() appends a new entry to the array and returns it. You can then modify the properties of that returned object (assuming it is a struct type).
Robert Hook can hopefully tell you where to find the ECFramework documentation.
Answer Verified By: John Drsek
Paul Connelly said:Robert Hook can hopefully tell you where to find the ECFramework documentation.
Hi John Drsek,
The latest MicroStation CONNECT Edition Update 13 Announcement adds new EC help documentation below to the prior existing:
HTH,Bob
Thanks Bob. John, ecobjects.chm is the one you want. See IECInstance, IECPropertyValue, IECArrayValue.