[ORD SDK C#] How to scan a reference for Alignments?

Hi all,

I am having issues trying to figure out how to scan reference attachments for Civil data, like Alignments. There is nothing I can find in the examples or any of the (limited) documentation.

Does anyone have a snippet they can share that does this? I can scan references using Microstation methods, just confused on how the ConsensusConnectionEdit/GeometricModel methods interact with this.

Regards,

Mark

Parents
  • Here's a method we use, it will return a list of alignment objects of all alignments in the active model and reference models (note: the reference model needs to be visible to find alignments in the reference).

    We are only looking for baseline & centerline alignments. Hope this helps.

            public static List<Alignment> GetAlignments()
            {
                Dictionary<string, Alignment> alignmentDictionary = new Dictionary<string, Alignment>();
    
                //Get all the civil models in the current dgn model
                BentleyCifNETSDK.ConsensusConnection sdkConnection = new BentleyCifNETSDK.ConsensusConnection(Session.Instance.GetActiveDgnModel());
                List<GeometricModel> models = sdkConnection.GetAllGeometricModels().ToList();
    
                foreach (GeometricModel geoModel in models)
                {
                    foreach (Alignment alignment in geoModel.Alignments)
                    {
                        if (!alignmentDictionary.ContainsKey(alignment.Name))
                        {
                            if (alignment.IsFinalElement && alignment.Name != string.Empty)
                            {
                                string featureName = alignment.FeatureName;
                                //be sure alignment has not already been added from a different model and is either a baseline or centerline
                                if (featureName.ToLower() == "alignment\\baseline" || featureName.ToLower() == "alignment\\centerline")
                                {
                                    alignmentDictionary.Add(alignment.Name, alignment);
                                }
                            }
                        }
                    }
                }
    
                List<Alignment> alignments = new List<Alignment>();
                foreach (KeyValuePair<string, Alignment> kvp in alignmentDictionary)
                {
                    alignments.Add(kvp.Value);
                }
                return alignments;
            }

    Answer Verified By: Mark Shamoun 

  • Excellent - thanks Mike!

    Regards,

    Mark


    OpenRoads Designer 2023  |  Microstation 2023.2  |  ProjectWise 2023

Reply Children
No Data