Message 1 of 2
How to identify clashes are 2D or 3D
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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.