[ORLD 2021 R2 C#] How to find alignment (complex geometry) for 3D Linear Enitty?

Hi,

in 3D model with sections, alignments are represented as 3D Linear Element objects.

They reside in referenced in 3D model. They represent 2D complex geometry plus defined profile. How it is possible to go from the entity (identified by file / model / id) to the geometry, to obtain the alignment?

I need to do some calculations for stationing in intersection between 3D Linear Element (representing alignment in 3D) and Named Boundary (representing section).

With regards,

  Jan

Parents
  • Hi Jan,

    Here is the sample code which might help your requirement:

    DgnModel dgnModel = Bentley.MstnPlatformNET.Session.Instance.GetActiveDgnModel();

    DgnModel activeModel = Session.Instance.GetActiveDgnModel();

     

    //get the elements from dgnModel

    ModelElementsCollection elements = dgnModel.GetElements();

    using (ConsensusConnection sdkCon = new Bentley.CifNET.SDK.ConsensusConnection(dgnModel))

    {

    //Iterate over the elements

    foreach (Bentley.DgnPlatformNET.Elements.Element element in elements)

        {

        //Check If current element is Graphics

        if (element.IsGraphics)

            {

            Bentley.CifNET.GeometryModel.SDK.FeaturizedModelEntity fme = Bentley.CifNET.GeometryModel.SDK.FeaturizedModelEntity.CreateFromElement(sdkCon, element);

     

            //get objectkey for current element

            Bentley.CifNET.Objects.ObjectKey civilKey = Bentley.CifNET.Model.DataAccess.DgnPersistenceManager.GetInstance().ActiveConnection.GetECObjectKey(element);

            Bentley.CifNET.SDK.Edit.ConsensusConnectionEdit sdkConEdit = Bentley.CifNET.SDK.Edit.ConsensusConnectionEdit.GetActive();

            IObjectSpace sdkObjSpace = SDK.Edit.EditItemFactory.GetObjectSpace(sdkConEdit);

     

            if (civilKey == null || sdkObjSpace == null)

                {

                continue;

                }

     

            //get the GeometricEntity from the objectKey

            Bentley.CifNET.GeometryModel.GeometricEntity obj = sdkObjSpace.GetObject(civilKey) as Bentley.CifNET.GeometryModel.GeometricEntity;

     

            if (obj != null)

                {

                if (fme != null)

                    {

                    if (string.IsNullOrWhiteSpace(fme.FeatureName))

                        {

                        continue;

                        }

     

                    try

                        {

                        Bentley.CifNET.GeometryModel.LinearEntity2dInPlan line2dEntity = obj as Bentley.CifNET.GeometryModel.LinearEntity2dInPlan;

                        Bentley.CifNET.GeometryModel.LinearEntity3d line3dEntity = obj as Bentley.CifNET.GeometryModel.LinearEntity3d;

     

                        if (line2dEntity != null)

                            {

                            if(line2dEntity.Geometry is LinearComplex)//Aligment

                                {

                                    //...

                                }

                            }

                        else if (line3dEntity != null)

                            {

                            if (line3dEntity.BaseGeometry is LinearComplex)//Aligment

                                {

                                //...

                                }

                            }

                        }

                    catch (Exception ex)

                        {

                        string exception = ex.ToString();                                   

                        }

                    }

                }

            }

        }

    }

     

  • Hi,

    thanks a lot for your code Thumbsup

    Meantime I found different solution / approach, where I start with GetAllGeometricModelsV2() method and I iterate the result. It provides information I need, but your code demonstrates some aspects that I maybe use in later steps in the code ;-)

    It would be nice to have documentation / explanation of concepts like keys, objectspace etc. To work with ORD SDK is like to play with black box with no documentation, hoping the right buttons are pushed in the right order...

    With regards,

      Jan

Reply Children
No Data