Is it possible to define ECProperty as enum type?

Hi,

is it possible (and if yes, is there an example available) to define ECProperty as enum type, so the only predefined values will be possible to choose from MicroStation GUI when the property is edited? I guess a relationship to some class with array of values can be the solution, but was not able to create such schema so far.

With regards,

  Jan

Parents
  • is it possible (and if yes, is there an example available) to define ECProperty as enum type

    Hidden in MicroStation CONNECT Update 7 are Pick Lists.  In that Update I don't think that they were intended to be publicly visible.  Perhaps we'll see more in Update 8.

    See Krister Surell's post about Picklists and C#.  He obviously spotted something that I missed!

    AFAIK all ECProperties (and hence Item Types) are ultimately XML data.  There are structures such as ValueMaps (see the delivered EC Schemas) that could be interpreted as a C#/C++ enum,  but there's no way that I know of to convert a ValueMap to an enum at run-time.

     
    Regards, Jon Summers
    LA Solutions

  • I'm relatively certain the new "pick lists" are only usable with Item Types (created in MicroStation's Item Types dialog), not general ECSchemas. I could be wrong.

    However ECSchemas have for years supported custom attributes which behave like enums and are displayed to the user as a pick list in a drop-down when editing property values. For example, to define a "widget size" property with allowable values of Small, Medium, and Large:

    <ECProperty propertyName="WidgetSize" typeName="int" displayLabel="Widget Size">
        <ECCustomAttributes>
            <StandardValues xmlns="EditorCustomAttributes.01.00">
                <ValueMap>
                    <ValueMap>
                        <Value>0</Value>
                        <DisplayString>Small</DisplayString>
                    </ValueMap>
                    <ValueMap>
                        <Value>1</Value>
                        <DisplayString>Medium</DisplayString>
                    </ValueMap>
                    <ValueMap>
                        <Value>2</Value>
                        <DisplayString>Large</DisplayString>
                    </ValueMap>
                </ValueMap>
            </StandardValues>
        </ECCustomAttributes>
    </ECProperty>
    
    

    Regards,

    Paul

  • Thanks, Paul! This gets me 85% of the way there, which is enough for a working solution for my project. What I'm now hacking away at is to define a similar structure to a "ValueMap" which enables me to define their "Value" as a string as opposed to an integer, so that when users enter in a value not predefined, it will not error out with "ECStandardValues TypeConverter cannot convert from System.String". Something more like:

    <ECProperty propertyName="WidgetSize" typeName="string" displayLabel="Widget Size">
        <ECCustomAttributes>
            <StandardValuesString xmlns="MyOwnCustomAttributes.01.00">
                <ValueMapString>
                    <ValueMapString>
                        <Value>A</Value>
                        <DisplayString>Small</DisplayString>
                    </ValueMapString>
                    <ValueMapString>
                        <Value>B</Value>
                        <DisplayString>Medium</DisplayString>
                    </ValueMapString>
                    <ValueMapString>
                        <Value>C</Value>
                        <DisplayString>Large</DisplayString>
                    </ValueMapString>
                </ValueMapString>
            </StandardValuesString>
        </ECCustomAttributes>
    </ECProperty>

    I've been trying that, and it seems to work in the Bentley Class Editor, but when I apply the schema to an element the "Pick List" functionality isn't working.

Reply
  • Thanks, Paul! This gets me 85% of the way there, which is enough for a working solution for my project. What I'm now hacking away at is to define a similar structure to a "ValueMap" which enables me to define their "Value" as a string as opposed to an integer, so that when users enter in a value not predefined, it will not error out with "ECStandardValues TypeConverter cannot convert from System.String". Something more like:

    <ECProperty propertyName="WidgetSize" typeName="string" displayLabel="Widget Size">
        <ECCustomAttributes>
            <StandardValuesString xmlns="MyOwnCustomAttributes.01.00">
                <ValueMapString>
                    <ValueMapString>
                        <Value>A</Value>
                        <DisplayString>Small</DisplayString>
                    </ValueMapString>
                    <ValueMapString>
                        <Value>B</Value>
                        <DisplayString>Medium</DisplayString>
                    </ValueMapString>
                    <ValueMapString>
                        <Value>C</Value>
                        <DisplayString>Large</DisplayString>
                    </ValueMapString>
                </ValueMapString>
            </StandardValuesString>
        </ECCustomAttributes>
    </ECProperty>

    I've been trying that, and it seems to work in the Bentley Class Editor, but when I apply the schema to an element the "Pick List" functionality isn't working.

Children
  • This relates to what I have been asking in this thread.

    It is possible (and quite easy) to create PickLists for ItemTypes but the lists are strings only. I you attach such a PickList to an Int or a Double property you will get that "ECStandardValues TypeConverter cannot convert from System.String" message.

    Bentleys answer was to use  the PickListHandler class (which I have not succeded to do). I think that this kind of basic data type conversion should be done automatically. If not, the PicklLists should have a data type so they can only be attached to a matching property. Otherwise you will have a dgn file that needs some application to work since the pick lists are stored in the file but not the handler.

    /Krister

    Owner consultant at Surell Consulting AB