Cannot retrieve level line coordinates in section and elevation views

Cannot retrieve level line coordinates in section and elevation views

pivanovTWWT5
Explorer Explorer
555 Views
2 Replies
Message 1 of 3

Cannot retrieve level line coordinates in section and elevation views

pivanovTWWT5
Explorer
Explorer

Hi all,

 

I want to retrieve the coordinates of each level line (start and end point) and the center point of the level bubble circle in section and elevetion views. As an example I use "section trough main stairs" view from  "rac_advanced_sample_project.rvt" model (from Samples folder that comes with the instalation). 

 

pivanovTWWT5_1-1682974049855.png

 

The Revit version I am using is 2019. Here is my code:

 

FilteredElementCollector ostViewersCollector = new FilteredElementCollector(rvtDocument, bimView.Id).OfCategory(BuiltInCategory.OST_Levels);
var levelElements = ostViewersCollector.ToElements();
var options = new Options();
options.View = bimView;
foreach (var level in levelElements)
{                                 
   BoundingBoxXYZ levelBB = level.get_BoundingBox(bimView);
   GeometryElement geomElem = level.get_Geometry(options);
   if (geomElem != null)
   {
      foreach (GeometryObject obj in geomElem)
      { 
         //try cast obj to Line               
      }
   }
}

 

 

I cannot retrieve the geometry of the level with this approach, level.get_Geometry returns a null object. I am wandering if OST_Levels is the right BuiltInCategory for the filter (I didn't find any other appropriate). Just to mention that I can retrieve the geometry of the callout lines in the same view if I use OST_Grids as a BuiltInCategory for the filter, get_Geometry return the geometry as Line(s).

 

In case there is no offset of the level from its bubble I can use the middle horizontal line of the Bounding Box of the level and the radius of the bubble circle to determine its center. But when there is offset(like the snapshot bellow), then I cannot find level start and end point, also the center of the bubble circle (the bubble might be from left, right or both sides of the level line).

pivanovTWWT5_0-1682975751854.png

Can you advice me how can I achive my goal. Thanks in advance.

Accepted solutions (1)
556 Views
2 Replies
Replies (2)
Message 2 of 3

architect.bim
Collaborator
Collaborator
Accepted solution

Hi!

You can get level curves using GetCurvesInView method:

View view = doc.ActiveView;
FilteredElementCollector levels = new FilteredElementCollector(doc, view.Id).OfClass(typeof(Level));

foreach (Level level in levels)
{
    IList<Curve> curves = level.GetCurvesInView(DatumExtentType.ViewSpecific, view);
    foreach (Curve curve in curves)
    {
        TaskDialog.Show("Level Curves", curve.ToString());
    }
}

From each curve you can get start and end point.

As for the bubble, I'm not sure its geometry can be obtained (at least, so far I haven't found such a method). But it seems to me that the centre of the circle can be calculated mathematically, using the coordinate of the end of the curve.


Maxim Stepannikov | Architect, BIM Manager, Instructor
Message 3 of 3

pivanovTWWT5
Explorer
Explorer

Hi Maxim!
Thank you for the solution. It realy solve my problem.