Quantcast
Channel: MicroStation Programming Forum - Recent Threads
Viewing all articles
Browse latest Browse all 7260

C# .NET MS Update 15 How to change and Item Type Property that has a pick list associated with it?

$
0
0

Hello All

I have an Item Type attached to an element in a model

One of the Properties in the Item Type is a string that has a pick list to choose the value with.

With C#.Net how do I programmatically change the value of the property attached to the element to a different value?

I am using the following code which will update a string property value, but will not update a value if the property has a PickList associated to it.

using Bentley.DgnPlatformNET;
using Bentley.DgnPlatformNET.Elements;
using Bentley.DgnPlatformNET.DgnEC;

/// <summary>Edit Property Double value on Element</summary>
        public bool EditPropertyStringValueOnElement(Element element, string itemLibraryName, string itemTypeName, string propertyName, string value)
        {
            ItemTypeLibrary itemTypeLibrary = ItemTypeLibrary.FindByName(itemLibraryName, m_ActiveDgnFile);
            if (itemTypeLibrary != null)
            {
                ItemType itemType = itemTypeLibrary.GetItemTypeByName(itemTypeName);
                if (itemType != null)
                {
                    CustomItemHost host = new CustomItemHost(element, false);
                    if (host != null) { 
                        IDgnECInstance item = host.GetCustomItem(itemLibraryName, itemTypeName);
                        if (item != null)
                        {
                            item[propertyName].StringValue = value;
                            item.WriteChanges();
                            return true;
                        }
                    }
                }
            }
            return false;
        }
 

Any ideas how to update a property value when a pick list is being used?


Viewing all articles
Browse latest Browse all 7260

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>