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");
John Drsek said:trying to figure out how to add a value to this array property
I had the same question from a user point of view. Here's the answer in the MicroStation Forum.
Let us know if you can achieve the same programmatically!
Regards, Jon Summers LA Solutions
yeah I knew how to add an entry graphically but not seeing anything in the SDK to do that same...ill keep looking and trying to get something to work.