How to identify clashes are 2D or 3D

How to identify clashes are 2D or 3D

preeti.kumari9TBN6
Enthusiast Enthusiast
204 Views
1 Reply
Message 1 of 2

How to identify clashes are 2D or 3D

preeti.kumari9TBN6
Enthusiast
Enthusiast
  public static void AnalyzeGridsInSheetViews(Document doc, List<ViewSheet> selectedSheets)
        {
            // Dictionary to store results
            Dictionary<string, List<string>> sheetGridSummary = new Dictionary<string, List<string>>();

            foreach (ViewSheet sheet in selectedSheets)
            {
                List<string> summaryList = new List<string>();

                // Collect all viewports on this sheet
                var viewports = new FilteredElementCollector(doc, sheet.Id)
                    .OfClass(typeof(Viewport))
                    .Cast<Viewport>()
                    .ToList();

                foreach (Viewport vp in viewports)
                {
                    View view = doc.GetElement(vp.ViewId) as View;
                    if (view == null) continue;

                    // Collect grids visible in the current view
                    var grids = new FilteredElementCollector(doc, view.Id)
                        .OfClass(typeof(Grid))
                        .Cast<Grid>()
                        .ToList();

                    int count2D = 0;
                    int count3D = 0;

                    foreach (Grid grid in grids)
                    {
                       var type= grid.GetType();
                        IList<Curve> viewCurves = grid.GetCurvesInView(DatumExtentType.ViewSpecific, view);
                        IList<Curve> modelCurves = grid.GetCurvesInView(DatumExtentType.Model, view);
                    if(viewCurves.Count>0 )
                        {
                           count2D++;
                        }
                        else
                        {
                            count3D++;
                        }

                        //if (extentData == null)
                        //    continue;

                        //bool is2D = extentData.IsViewSpecific;   // True if the grid is 2D in that view
                        //bool is3D = !extentData.IsViewSpecific;  // False means it’s 3D
                        //                                         //#endif

                        //if (is2D && !is3D)
                        //    count2D++;
                        //else if (is3D)
                        //    count3D++;
                    }

                    string summary = $"View: {view.Name} → 2D Grids: {count2D}, 3D Grids: {count3D}";
                    summaryList.Add(summary);
                }

                sheetGridSummary[sheet.Name] = summaryList;
            }

            // Print or log results
            foreach (var kvp in sheetGridSummary)
            {
                TaskDialog.Show("Grid Summary",
                    $"Sheet: {kvp.Key}\n" + string.Join("\n", kvp.Value));
            }
        }But here grids data are coming for both viewCurves  and modelCurves.
 
0 Likes
205 Views
1 Reply
Reply (1)
Message 2 of 2

npetulla
Contributor
Contributor

Clashes in Revit will always be a pain. Revit dosnt really do clash detection either.

What I know works: 

Revit Face objects you can detect intersections from curves or lines but this really only works reliably from a Plan View (2D / Birds Eye View) in my experience.

 

I dont really understand what you mean by how to identify if the clash is 2D or 3D, The clash is a clash regardless of the view.

Whats your end goal?

0 Likes