private void GenerateNodes(List <FoundationNode> nodes, ICollection <FoundationCentreLine> centrelines) { bool complete = false; while (!complete) { nodes.Clear(); complete = true; foreach (FoundationCentreLine fcl in centrelines) { fcl.AttachNodes(nodes); } Document acDoc = Application.DocumentManager.MdiActiveDocument; Database acCurDb = acDoc.Database; Transaction acTrans = acCurDb.TransactionManager.TopTransaction; // TODO: This section needs checking //Iterate over full collection, identifying any nodes that intersect part way through the lines and adjusting to suit BlockTableRecord modelSpace = HostDocument.Database.GetModelSpace(true); foreach (FoundationNode foundationNode in nodes) { for (int i = 0; i < centrelines.Count; i++) { Curve toBeChecked = acTrans.GetObject(centrelines.ElementAt(i).BaseObject, OpenMode.ForRead) as Curve; Point3d closest = toBeChecked.GetClosestPointTo(foundationNode.Location, false); if (!closest.IsEqualTo(toBeChecked.StartPoint) && !closest.IsEqualTo(toBeChecked.EndPoint)) { //TODO: Will global tolerance work?? if ((foundationNode.Location - closest).Length <= 0.0001) //Tolerance.Global.EqualPoint) { Point3dCollection splitPoint = new Point3dCollection(); splitPoint.Add(closest); //Node is one line DBObjectCollection splitSegments = toBeChecked.GetSplitCurves(splitPoint); foreach (DBObject splitSegment in splitSegments) { FoundationCentreLine fcl = new FoundationCentreLine(acDoc, _soilProperties, _foundationLayerName); fcl.BaseObject = modelSpace.AppendEntity(splitSegment as Entity); acTrans.AddNewlyCreatedDBObject(splitSegment, true); centrelines.Add(fcl); } toBeChecked.Erase(); //centrelines.RemoveAt(i); centrelines.Remove(centrelines.ElementAt(i)); complete = false; break; } } } } } }
private ICollection <FoundationCentreLine> GetCentrelines() { // Explode plots into foundation centrelines // TODO: Implement dirty List <FoundationCentreLine> centrelines = new List <FoundationCentreLine>(); foreach (DetailPlot detailPlot in ManagedObjects) { IReadOnlyCollection <LineDrawingObject> plotCentres = detailPlot.GetFoundationCentrelines(); foreach (LineDrawingObject lineDrawingObject in plotCentres) { FoundationCentreLine foundationCentreLine = FoundationCentreLine.CreateFromLine(lineDrawingObject, _soilProperties); foundationCentreLine.PlotIds.Add(detailPlot.PlotId); centrelines.Add(foundationCentreLine); } } return(centrelines); }