public void RandDeteleVertGrids(Document doc, Wall curtainWall, int probabilityVert, double vertCounterMax) { CurtainGrid grid = curtainWall.CurtainGrid; ICollection <ElementId> vertGrids = grid.GetVGridLineIds(); List <int> removalCounters = null; foreach (ElementId eIdV in vertGrids) { CurtainGridLine cglV = (CurtainGridLine)doc.GetElement(eIdV); Debug("CW Grid ID" + cglV.Id); List <Curve> curvesV = cglV.AllSegmentCurves.Cast <Curve>().ToList(); if (removalCounters == null) { removalCounters = curvesV.Select(g => 0).ToList(); } for (int i = 0; i < curvesV.Count; i++) { Curve cV = curvesV[i]; int randNumber = rand.Next(0, 99); if (randNumber < probabilityVert && removalCounters[i] < vertCounterMax) { Debug("removal counters value" + removalCounters[i]); cglV.RemoveSegment(cV); removalCounters[i]++; Debug("Deleted Vert Seg " + i); Debug("Vert randNumber " + randNumber); Debug("curve list length" + curvesV.Count); } else { removalCounters[i] = 0; Debug("Did not delete Vert Seg " + i); Debug("Vert randNumber " + randNumber); } } Debug("CW Grid ID after" + cglV.Id); } }
public void RandDeteleHorizGrids(Document doc, Wall curtainWall, int porbabilityHoriz, double horizCounterMax) { CurtainGrid grid = curtainWall.CurtainGrid; ICollection <ElementId> horizGrids = grid.GetUGridLineIds(); List <int> removalCounters = null; foreach (ElementId eIdH in horizGrids) { CurtainGridLine cglH = (CurtainGridLine)doc.GetElement(eIdH); Debug("CW Grid ID" + cglH.Id); List <Curve> curvesH = cglH.AllSegmentCurves.Cast <Curve>().ToList(); if (removalCounters == null) { removalCounters = curvesH.Select(g => 0).ToList(); } for (int i = 0; i < curvesH.Count; i++) { Curve cH = curvesH[i]; int randNumber = rand.Next(0, 99); if (randNumber < porbabilityHoriz && removalCounters[i] < horizCounterMax) { cglH.RemoveSegment(cH); removalCounters[i]++; Debug("Deleted Horiz Seg " + i); Debug("Horiz randNumber " + randNumber); } else { removalCounters[i] = 0; Debug("Did not delete Horiz Seg " + i); Debug("Horiz randNumber " + randNumber); } } Debug("CW Grid ID after" + cglH.Id); } }