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).
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
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)
//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)
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();
thanks a lot for your code
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...
Bentley Accredited Developer: iTwin Platform - AssociateLabyrinth Technology | dev.notes() | cad.point
I have been trying out this code for a similar application, but cant find where "EditItemFactory" comes from?
Shashank Gokhale said: IObjectSpace sdkObjSpace = SDK.Edit.EditItemFactory.GetObjectSpace(sdkConEdit);
OpenRoads Designer 2022 R1 (10.11) | Microstation CE Update 17.2 | ProjectWise CE 3.4
You can find it in: Bentley.CifNET.SDK.Edit.EditItemFactory
Try referring to: Bentley.CifNET.SDK.Edit.4.0.dll
Excellent thanks. I didn't see it because i was using 10.10. Now available with the 10.11 SDK.