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();
        }

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

    The feature definition is presumably supplied by the ORD schema (XML file).  An element has an Item instance, which is data.  An element doesn't have the definition — only those data that were created in accordance with the definition.

     
    Regards, Jon Summers
    LA Solutions

  • 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

  • The feature definition is presumably supplied by the ORD schema (XML file).

    Yes, but it is not one definition in one schema. The feature definition represents tree structure of different definitions (how feature is represented in different views/plans/sections, how every such representation is annotated, where every annotation consists potentially from many definitions etc.). So to reconstruct the whole definition is complex task (I spent days and days to understand some aspects of the civil mode, to be able to obtain data I need).

    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 ?? "";
    }


  •  it looks very expensive.

    It looks funny a bit when you are worried about performance, but use LINQ queries, that are one from "safe ways" how to make code slower (depending on context from "a bit" to "thousands times" slower).

    I know only this one: to try to find a feature definition for the element

    Your original question is "Is there a way to get the feature definition for each element?", so how such information can be retrieved without analyzing every existing feature?

    Small uncertainty exists here, because an element may have feature definition assigned (so it become "civil feature"), or it can be plain DGN element. To enumerate all element and to enumerate civil features are done using different code.

    I know only this one

    I do not quite understand why this code is written in this specific way. Not did not do any analysis, so I can be wrong, but subjectively it is written to consume as much memory as possible (why to create the list of entities?) and to be slow (switching context of models is not controlled).

    Do we have some generic approach?

    It depends what exactly you need and also what context exist.

    Simple straightforward approach is similar to what you mentioned: enumerate existing geometric models (representing active model and attached references) and in every model, to get objects (can be Liner3dEntities, Alignments or whatever else).

    Another approach, but not with the same result, is to query feature definitions, hold in every geometric model. The difference is that GeometricModel.FeatureDefinitions() method does not return definitions, used by objects, but all definitions, stored in the file. It means it can return mode definitions (when the definition is assigned to a feature and replaced by another definition assignment later).

    it looks very expensive.

    Sorry, but in software development "it looks" does not sound very professional. When there is a threat algorithm is not optimal, do performance analysis, memory allocation / GC analysis, or any other relevant benchmark.

    With regards,

      Jan