Python

MicroStation Engineering Content: EC Schemas

Bentley Systems introduced Engineering Content with MicroStation CONNECT in 2015. Engineering Content is commonly abbreviated to EC.

The foundation of Engineering Content is contained in its schemas. A schema is a general framework or category that organizes and interprets information.

MicroStation Schemas: Folders and Files

MicroStation's EC schemas are defined in XML files that are installed in the ..\MicroStation\ECSchemas folder (something like C:\Program Files\Bentley\MicroStation 2026\MicroStation\ECSchemas).

Under that ..\MicroStation\ECSchemas folder you'll see sub-folders including ..\MicroStation\ECSchemas\Dgn. There is a number of XML files in that folder. Most you will seldom use, but one or two are invaluable as you venture along the path to EC enlightenment …

Never edit, modify or delete those files! You can inspect them, and since they are XML it's best to use an XML reader such as NotePad++ or XMLSpy. Prefer to open schema files read-only.

The files are large. The first we'll look at is BaseElementSchema.01.00.ecschema.xml, which contains about 13,000 lines. They are designed to be read by an app that understands their structure and content. That app is MicroStation!

For example, here's the beginning of ECClass Segment. A segment is part of a line or line-string …

<ECClass typeName="Segment" isStruct="True" isDomainClass="True">
     …
    lines omitted
     …
</ECClass>

That XML structure is intended to build an MSPyECObjects.ECClass at run-time.

BaseElementSchema

BaseElementSchema.01.00.ecschema.xml is intended to be merged (overridden) by other schemas. For example, the DgnElementSchema (DgnElementSchema.01.00.ecschema.xml) references the base schema in this line near the beginning of the file …

<ECSchema schemaName="DgnElementSchema" nameSpacePrefix="dgnElem" version="1.0" displayLabel="Dgn Elements" xmlns="http://www.bentley.com/schemas/Bentley.ECXML.2.0">
    <ECSchemaReference name="BaseElementSchema" version="01.00" prefix="baseElem" />
     …
    lines omitted
     …
</ECSchema>

DgnElementSchema

The DgnElementSchema (DgnElementSchema.01.00.ecschema.xml) is the schema used for common DGN elements. You will recognise such names as TextElement, ConeElement, LineElement and many more. Here is the ECClass meta-data for a LineElement …

<ECClass typeName="LineElement" isDomainClass="True" displayLabel="Lines">
    <BaseClass>GraphicalElement</BaseClass>
    <BaseClass>baseElem:MstnLineSegments</BaseClass>
    <ECCustomAttributes>
        <DisplayOptions xmlns="Bentley_Standard_CustomAttributes.01.10">
            <Hidden>False</Hidden>
        </DisplayOptions>
        <ElementHeaderPropertyOverrides>
            <PropertyNames>
                <string>Thickness</string>
                <string>LineStyleParams</string>
            </PropertyNames>
        </ElementHeaderPropertyOverrides>
      <CustomImageSpecification xmlns="Bentley_Standard_CustomAttributes.01.10">
        <Moniker_Default>ECLiteralImage://Line</Moniker_Default>
        <Moniker_Expanded>ECLiteralImage://Line</Moniker_Expanded>
        <Moniker_Collapsed>ECLiteralImage://Line</Moniker_Collapsed>
      </CustomImageSpecification>
    </ECCustomAttributes>
    <ECArrayProperty propertyName="Segments" typeName="baseElem:Segment" minOccurs="1" maxOccurs="1" isStruct="True" displayLabel="Segments">
        <ECCustomAttributes>
            <Category xmlns="EditorCustomAttributes.01.00">
                <Standard>8</Standard>
            </Category>
            <PropertyPriority xmlns="EditorCustomAttributes.01.00">
                <Priority>350000</Priority>
            </PropertyPriority>
            <MembersIndependent xmlns="EditorCustomAttributes.01.00" />
            <ExtendType xmlns="EditorCustomAttributes.01.00">
                <Standard>12</Standard>
            </ExtendType>
            <ArrayBehaviorAttributes xmlns="EditorCustomAttributes.01.01">
                <SupportsAddAndRemove>False</SupportsAddAndRemove>
            </ArrayBehaviorAttributes>
        </ECCustomAttributes>
    </ECArrayProperty>
</ECClass>

The first few lines tell us that a LineElement …

Use the element information tool (Ctrl-I) on a line element in MicroStation, and you can see how those class definitions contribute to the display.

EC Classes at Runtime

As MicroStation starts, it reads those schema files and builds an EC model in memory. That EC model is stored in MicroStation's non-graphical cache — as a user, you can't see it.

Use DgnECManager to query EC data in a DGN model and to create EC data.

Each DGN element has a link to its EC class. The class determines how that element is presented to you. The EC class participates in MicroStation's rendering of the element. It also participates in tools such as Element Properties that display element data in tabular form. The EC class determines the labels and data that are shown.

Questions

Post questions about MicroStation programming to the MicroStation Programming Forum.