[V8i C#] Add Category attribute to a class programmatically

Hi,

in MicroStation V8i (SELECTseries 4), using C# and EC SDK, I am creating EC schema "on the fly" as necessary based on external data source and save it to file (so the schema is not created externally using Bentley Class Editor).

I am able to create the schema, add classes and it seems there are also no problems with attributes like Units or ECCalculatedProperty.

I have a problem with Category attribute I'd like to attach to different classes to control how they will be displayed in Element Information dialog. I know the attribute definition is stored in EditorCustomAttributes supplemental schema, but I have not found a way how to reference this schema with my schema.

I know I can access different standard schemas using StandardSchemas class, but it does not contain EditorCustomAttributes.

What is the right solution, when there are ECSchema and ECClass instances available, to reference the supplement schema (as far as I know there is no xml file for EditorCustomAttributes available in V8i installation) using C# code?

With regards,

  Jan

Parents
  • Hi Jan,

    I am not aware of V8i code. But, I can give you CE code snipp. May be, you can give a try in V8i.

    #Create Category: ECPropertyPane.CreateCategory(...)

    /// <param name="name">The non-localized name of the category.</param>

    /// <param name="displayLabel">The localized name of the category that will be displayed to users.</param>

    /// <param name="description">The description of the category.</param>

    /// <param name="sortPriority">The default sort priority for the category.</param>

    /// <param name="defaultExpand">True if category should be expanded by default.</param>

    For sort priority somthig like ECPropertyPane. PropertySortPriorityVeryLow should work.

    So, CreateCategory will give you category custom attribute instance. You need to apply it to ECProperty.

    For e.g.

    IECProperty p = new ECProperty (name, dataType); //or get existing property

    if (null != categoryCustomAttribute)

    p.SetCustomAttribute (categoryCustomAttribute);

    Please try this and let me know if you have any problems.


    This is a test

    Answer Verified By: Jan Šlegr 

Reply
  • Hi Jan,

    I am not aware of V8i code. But, I can give you CE code snipp. May be, you can give a try in V8i.

    #Create Category: ECPropertyPane.CreateCategory(...)

    /// <param name="name">The non-localized name of the category.</param>

    /// <param name="displayLabel">The localized name of the category that will be displayed to users.</param>

    /// <param name="description">The description of the category.</param>

    /// <param name="sortPriority">The default sort priority for the category.</param>

    /// <param name="defaultExpand">True if category should be expanded by default.</param>

    For sort priority somthig like ECPropertyPane. PropertySortPriorityVeryLow should work.

    So, CreateCategory will give you category custom attribute instance. You need to apply it to ECProperty.

    For e.g.

    IECProperty p = new ECProperty (name, dataType); //or get existing property

    if (null != categoryCustomAttribute)

    p.SetCustomAttribute (categoryCustomAttribute);

    Please try this and let me know if you have any problems.


    This is a test

    Answer Verified By: Jan Šlegr 

Children