A MicroStation DGN file is a container: it contains one or more DGN models. A DGN model is also a container: it contains DGN elements, reference attachments and other objects. XML files delivered with MicroStation define multiple schemas, known as ECSchemas, that define DGN element, model, file and other classes and properties.
An ECInstance
represents an instance of an ECClass
related to a DGN element.
The instance has properties and sub-classes that supply further properties of that element.
Examples are published on Be Communities blog page
Operations on EC Properties.
To start with EC element properties, you must obtain an ECInstance
from a DGN element.
Here we get an instance list rather than a single instance.
However, unless there are data attached from another EC schema, the list usually contains a single instance.
This is the simplest piece of code you will see in this series of articles …
ECN::ECInstanceList GetElementProperties (ElementHandleCR element, DgnPlatform::ECQueryProcessFlags flags) { ECInstanceList ecInstanceList; DgnECManagerR dgnECManager = DgnECManager::GetManager(); FindInstancesScopePtr scope = FindInstancesScope::CreateScope (element, FindInstancesScopeOption(DgnECHostType::Element)); ECQueryPtr findAll = ECQuery::CreateQuery(flags); for each (DgnECInstancePtr instance in dgnECManager.FindInstances(*scope, *findAll)) ecInstanceList.push_back(instance); return ecInstanceList; }
Usage …
ECQueryProcessFlags flags = static_cast<ECQueryProcessFlags> (ECQUERY_PROCESS_SearchAllIntrinsic | ECQUERY_PROCESS_SearchAllExtrinsic); ECN::ECInstanceList list = schemaDebug.GetElementProperties (*first, flags);
The ECInstanceList
usually has one member — a single ECInstance
.
The next task is to parse or analyse the ECInstance
to find its properties, sub-classes and the sub-class properties.
For example, for an EC LineElement
we want to find its one and only Segment
(i.e. Segments[0]
),
and from that
get its Length
, Direction
and other properties.
Get each ECInstance
from the list …
for (IECInstancePtr instance: list) { TraceInstance (instance); }
Instantiate an LASolutions::EcSegments
class from that EC instance …
void TraceInstance (IECInstancePtr instance) { LASolutions::EcSegments ecSegments(instance); ecSegments.Trace (); }
Read about the EcBaseClass.
Post questions about C# and C++ to the MicroStation Programming Forum.