ORD | Get Feature definition.

ORD | 2021 release 2 update 10 | 10.10.21.04

In Ord, each element has a feature definition. Is there a way to get the feature definition for each element?



I have a list of IDgnECInstance. I need to get their feature definition and description

more code:

public IEnumerable<Instance> Scan(string schemaName)
        {
            var instances = GetInstances(GetSearchClasses(schemaName));
            
            foreach (var instance in instances)
            {
                yield return new Instance()
                {
                    ElementId = instance.Element.ElementId.ToString(),
                    ClassDefinitionDisplayLabel = instance.ClassDefinition.DisplayLabel,
                    FeatureDefinition = instance.Element.FeatureDefinition // this field doesn`t exist 
                };
            }
        }

        private IQueryable<IDgnECInstance> GetInstances(IECClass[] classes)
        {
            var query = new ECQuery(classes) { SelectClause = { SelectAllProperties = true } };

            var manager = DgnECManager.Manager;
            var scopeOptions = new FindInstancesScopeOption(DgnECHostType.Element, true);
            var dgnFile = _dgnFileProvider.GetActiveDgnFile();
            if (dgnFile == null) return null;
            var scope = FindInstancesScope.CreateScope(dgnFile, scopeOptions);
            var instances = manager.FindInstances(scope, query);
            return instances.AsQueryable();
        }

        private IECClass[] GetSearchClasses(string schemaName)
        {
            var scopeOptions = new FindInstancesScopeOption(DgnECHostType.All, true);
            var scope = FindInstancesScope.CreateScope(Session.Instance.GetActiveDgnFile(), scopeOptions);
            return DgnECManager.Manager.LocateSchemaInScope(scope, schemaName, 1,0,SchemaMatchType.Latest).GetClasses();
        }

Parents
  • Hi Ivan,

    because your question is about OpenRoads Designer programming, please move your question to Civil Programming forum. To move existing discussion to another forum, use More > Move tool, available under your original post. Please, do not ask again to do not duplicate discussions, but prefer to move existing one.

    Is there a way to get the feature definition for each element?

    OpenRoads Designer offers comprehensive API to work with civil objects (alignments, cants, speed tables...), both in C++ and NET. See examples delivered with ORD SDK how to access the data.

    to get the feature definition

    What is "feature definition" for you? Is it the feature name and description, or you are interested in complete definition tree (feature definition / symbology per the feature representation / annotation group / annotation definition / ...)? While to obtain name and description is simple, to reconstruct complete definition can be very complex task.

    I have a list of IDgnECInstance.

    It's not so simple. Civil model is extremely complex, modeled using tens of classes, connected using another tens of relationships, defined in many EC schemas (where some are created dynamically in memory, and other as ad-hoc structures). So to use API is preferred, although (at least) in ORD 2021 R2 not all data are available, and some can be obtained using EC Queries (or alternatively by hacking internal API).

    The civil data model is not published, so when you prefer (or must) to use EC Query instead public API, you must analyze it, decompose and design proper queries by yourself.

    With regards,

      Jan

  • Thanks for your reply. It is really important for me. 

    While to obtain name and description is simple,

    I need a name and description only. Do we have some generic approach?
    I know only this one: to try to find a feature definition for the element, we have to go by all geometric models. it looks very expensive.

    \\example for LinearEntities3d
    var linearEntity3ds = ConsensusConnectionEdit.GetActive()
                                                .GetAllGeometricModels()
                                                .SelectMany(_ => _.LinearEntities3d) \\ here need to iterate all the available geometric models
                                                .ToList();
    
    foreach (var linear in linearEntity3ds)
    {
        var featureObjectSetting = linear.FeatureDefinition.DomainObject as Bentley.CifNET.ContentManagementModel.ObjectSettings;
        var elementId = linear.Element.ElementId
        var featureName = linear.FeatureName;
        var featureDescription = featureObjectSetting?.Description ?? "";
    }


  • Hi Ivan,

    If you are only after the Feature Definition names you could simply use an interop Property Handle method to get the "ObjectSettings" property value for each element (or use VBA). 

    Regards,

    Mark


    OpenRoads Designer 2023  |  Microstation 2023.2  |  ProjectWise 2023

  • If you are only after the Feature Definition names you could simply...

    Examine the ORD schema files!  However, Jan comments that the overall schema is rather complex. XML files are plain text, but their content is rather indigestible.  One way to clarify their content is to examine them using Bentley's ECSchema Editor.

    Unfortunately, the ECSchema Editor is not a permanent member of Bentley's Software Downloads.  Perhaps can tell us more about the ECSchema Editor and its availability?

     
    Regards, Jon Summers
    LA Solutions

  • LINQ is a very good and compact way to provide an example. I do not understand why you are reacting to this in this thread - this is not the subject of our discussion.
    Idle talk, sorry! 

    t looks funny a bit when you are
  • Hi ,

    Unfortunately, the ECSchema Editor is not a permanent member of Bentley's Software Downloads.  Perhaps can tell us more about the ECSchema Editor and its availability?

    Interesting timing of the question...

    As of one year ago tomorrow (11/29/2021), I provided a High-level overview topic for "Class Editors" (anchor) that (still to the best of my knowledge) provides the best insights and most current options I could find and share.  I validated (today) that each of those insight links still work and point to the latest topics and software versions available.

    Thank you and HTH,
    Bob 



  • each of those insight links still work and point to the latest topics and software versions available

    Thanks for the reminder!

    The EC Class Editor is delivered with certain OpenPlant products... 

    1. Why is EC Class Editor not part of the platform delivery?
    2. Why is EC Class Editor not a separate download?

     
    Regards, Jon Summers
    LA Solutions

Reply Children
No Data