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
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))
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 Shasank,
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);
Regards,
Mark
OpenRoads Designer 2023 | Microstation 2023.2 | ProjectWise 2023
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.