private void SetProtectionMethods(List <SlopeLine> slopeLines, string protMethod, int[] slopeLevels) { // 提取规则 var fp = new ForceProtection(protMethod, slopeLevels); var es = EditStateIdentifier.GetCurrentEditState(_docMdf); es.CurrentBTR.UpgradeOpen(); //var layer_Slope = Utils.GetOrCreateLayer(_docMdf, ProtectionConstants.LayerName_ProtectionMethod_Slope); //var layer_Platform = Utils.GetOrCreateLayer(_docMdf, ProtectionConstants.LayerName_ProtectionMethod_Platform); // 先修改内存中的防护 foreach (var slp in slopeLines) { slp.ForceProtect(fp); } // 再刷新到 AutoCAD 文档与界面中 var protLayers = ProtectionTags.MapProtectionLayers(_docMdf, slopeLines); foreach (var slp in slopeLines) { // 将数据刷新到界面与边坡线中 slp.Pline.UpgradeOpen(); slp.PrintProtectionMethod(es.CurrentBTR, protLayers); slp.FlushXData(); slp.Pline.DowngradeOpen(); } _docMdf.acEditor.UpdateScreen(); }
/// <summary> 将分割开的多个子边坡进行合并 </summary> public ExternalCmdResult MergeSlopeSegs(DocumentModifier docMdf, SelectionSet impliedSelection) { _docMdf = docMdf; SQUtils.SubgradeEnvironmentConfiguration(docMdf); // var selectedSlopes = SQUtils.SelecteExistingSlopeLines(docMdf, left: null, sort: true); if (selectedSlopes == null || selectedSlopes.Count == 0) { return(ExternalCmdResult.Cancel); } // MergeProtectionDirection dir; var succ = GetProtectionDirection(docMdf, out dir); if (!succ) { return(ExternalCmdResult.Cancel); } // //var layer_Slope = Utils.GetOrCreateLayer(_docMdf, ProtectionConstants.LayerName_ProtectionMethod_Slope); //var layer_WaterLine = Utils.GetOrCreateLayer_WaterLine(_docMdf); //var layer_Platform = Utils.GetOrCreateLayer(_docMdf, ProtectionConstants.LayerName_ProtectionMethod_Platform); var es = EditStateIdentifier.GetCurrentEditState(_docMdf); es.CurrentBTR.UpgradeOpen(); bool haveSegsMerged = false; int mergedCount = 0; docMdf.WriteLineIntoDebuger("合并的边坡对象:"); var protLayers = ProtectionTags.MapProtectionLayers(_docMdf, selectedSlopes); foreach (var slp in selectedSlopes) { haveSegsMerged = MergeSlope(slp.XData, dir); if (haveSegsMerged) { // 将刷新后的数据保存到 AutoCAD 文档与界面中 slp.Pline.UpgradeOpen(); // slp.ClearAllWaterlines(_docMdf.acDataBase); SlopeConstructor.SetSlopeUI(slp); slp.PrintProtectionMethod(es.CurrentBTR, protLayers); slp.FlushXData(); // slp.Pline.DowngradeOpen(); mergedCount += 1; docMdf.WriteLineIntoDebuger(slp); } } docMdf.WriteLineIntoDebuger($"总计:{mergedCount} 个"); // return(ExternalCmdResult.Commit); }
/// <summary> 按标高将边坡对象进行分割,以实现同一级边坡中分别设置不同的防护形式 </summary> private void CutSlopes(DocumentModifier docMdf, SlopeLine[] selectedSlopes, CutMethod method, double elev, double waterLineLength) { // ProtectionUtils.SubgradeEnvironmentConfiguration(docMdf); // //var layer_Slope = Utils.GetOrCreateLayer(docMdf, ProtectionConstants.LayerName_ProtectionMethod_Slope); var layer_WaterLine = eZcad.SubgradeQuantity.Utility.SQUtils.GetOrCreateLayer_WaterLine(docMdf); //var layer_Platform = Utils.GetOrCreateLayer(docMdf, ProtectionConstants.LayerName_ProtectionMethod_Platform); var es = EditStateIdentifier.GetCurrentEditState(docMdf); es.CurrentBTR.UpgradeOpen(); // Point2d intersPt; Slope intersSlopeSeg; int cutCount = 0; docMdf.WriteLineIntoDebuger("被分割的边坡对象:"); var protLayers = ProtectionTags.MapProtectionLayers(_docMdf, selectedSlopes); foreach (var slp in selectedSlopes) { var inters = ValidateElevation(slp, method, elev, out intersPt, out intersSlopeSeg); if (inters) { // 将子边坡按指定的交点进行剪切 var newSegs = CutSlopeSegment(slp.XData, intersSlopeSeg, new Point3d(intersPt.X, intersPt.Y, 0)); slp.XData.Slopes = newSegs; // 将被剪切掉的子边坡所绑定的文字删除 SlopeLine.EraseText(intersSlopeSeg, docMdf.acDataBase); // 绘制水位线 var line = new Line(new Point3d(intersPt.X - waterLineLength / 2, intersPt.Y, 0), new Point3d(intersPt.X + waterLineLength / 2, intersPt.Y, 0)); line.LayerId = layer_WaterLine.Id; es.CurrentBTR.AppendEntity(line); docMdf.acTransaction.AddNewlyCreatedDBObject(line, true); slp.XData.Waterlines.Add(line.Handle); // 将刷新后的数据保存到 AutoCAD 文档与界面中 slp.Pline.UpgradeOpen(); SlopeConstructor.SetSlopeUI(slp); slp.PrintProtectionMethod(es.CurrentBTR, protLayers); slp.FlushXData(); slp.Pline.DowngradeOpen(); // cutCount += 1; docMdf.WriteLineIntoDebuger(slp); } } es.CurrentBTR.DowngradeOpen(); docMdf.WriteLineIntoDebuger($"总计:{cutCount} 个"); }
/// <summary> 根据边坡多段线进行道路边坡的筛选、信息提取、防护方式的设置等操作 </summary> public void ConfigerSlopes(IList <Polyline> slopeLines, bool justModifyCalculated) { if (slopeLines == null || slopeLines.Count == 0) { return; } // var app = SymbolTableUtils.GetOrCreateAppName(_docMdf.acDataBase, _docMdf.acTransaction, SlopeData.AppName); var selectedSlpLines = new List <SlopeLine>(); string errMsg; foreach (var sl in slopeLines) { var slpLine = SlopeLine.Create(_docMdf, sl, out errMsg); if (slpLine != null) { // 将存储的数据导入边坡对象 slpLine.ImportSlopeData(slpLine.XData); // if (!slpLine.XData.FullyCalculated || !justModifyCalculated) { slpLine.CalculateXData(); } selectedSlpLines.Add(slpLine); } else { _docMdf.WriteNow(errMsg); } } if (selectedSlpLines.Count == 0) { return; } var slopesWithSlopesegs = new List <SlopeLine>(); var slopesWithoutSlopesegs = new List <SlopeLine>(); foreach (var slp in selectedSlpLines) { if (slp.XData.Slopes.Count + slp.XData.Platforms.Count > 0) { slopesWithSlopesegs.Add(slp); } else { slopesWithoutSlopesegs.Add(slp); } } // var es = EditStateIdentifier.GetCurrentEditState(_docMdf); es.CurrentBTR.UpgradeOpen(); //var layer_Slope = Utils.GetOrCreateLayer(_docMdf, ProtectionConstants.LayerName_ProtectionMethod_Slope); //var layer_Platform = Utils.GetOrCreateLayer(_docMdf, ProtectionConstants.LayerName_ProtectionMethod_Platform); // _docMdf.acDataBase.Clayer = layer_Slope.ObjectId; // // 1. 对有子边坡的边坡对象进行操作:显示界面,以进行填挖方与防护设置 var listerForm = new SlopeSegLister(slopesWithSlopesegs); listerForm.ShowDialog(null); if (listerForm.ValueChanged) { var protLayers = ProtectionTags.MapProtectionLayers(_docMdf, slopesWithSlopesegs); foreach (var slp in slopesWithSlopesegs) { slp.Pline.UpgradeOpen(); SetSlopeUI(slp); slp.PrintProtectionMethod(es.CurrentBTR, protLayers); // slp.FlushXData(); slp.Pline.DowngradeOpen(); if (slp.XDataToBeCleared) { slp.ClearXData(); } } } // 2. 对没有子边坡的边坡对象进行操作 foreach (var slp in slopesWithoutSlopesegs) { slp.Pline.UpgradeOpen(); SetSlopeUI(slp); slp.FlushXData(); slp.Pline.DowngradeOpen(); } es.CurrentBTR.DowngradeOpen(); }