//找到复用梁 public List <string> GetItemAsync(string kval) { List <string> vs = new List <string>(); MxDrawSelectionSet select = new MxDrawSelectionSet(); MxDrawResbuf filter = new MxDrawResbuf(); filter.AddStringEx("TEXT,MTEXT", 5020); select.Select2(MCAD_McSelect.mcSelectionSetAll, null, null, null, filter); for (int i = 0; i < select.Count; i++) { MxDrawEntity entity = select.Item(i); if (entity == null) { continue; } if (entity.ObjectName == "McDbText") { MxDrawText tx = entity as MxDrawText; if (tx.TextString.Trim() != "" && kval.Contains(tx.TextString)) { vs.Add(tx.handle); } } } return(vs); }
//选择范围 private void T1007() { axMxDrawX1.DynWorldDraw += AxMxDrawX1_DynWorldDraw;//添加动态画框事件 axMxDrawX1.AddLayer("tkbox"); MxDrawPoint pt1 = axMxDrawX1.GetPoint(false, 0, 0, "开始坐标...") as MxDrawPoint; if (pt1 == null) { return; } MxDrawUiPrPoint scpt = new MxDrawUiPrPoint(); scpt.message = "终点坐标..."; scpt.basePoint = pt1; scpt.setUseBasePt(false); var spdata = scpt.InitUserDraw("SelectRangeBox"); axMxDrawX1.SetSysVarLong("ORTHOMODE", 0); spdata.SetPoint("BasePoint", pt1); if (scpt.go() != MCAD_McUiPrStatus.mcOk) { return; } spdata.Draw(); //放大 axMxDrawX1.ZoomWindow(pt1.x, pt1.y, spdata.DragPoint.x, spdata.DragPoint.y); PublicValue = new { Lx = pt1.x, Ly = pt1.y, Lz = pt1.z, Rx = spdata.DragPoint.x, Ry = spdata.DragPoint.y, Rz = spdata.DragPoint.z }; //删除选择框 MxDrawSelectionSet ss = new MxDrawSelectionSet(); MxDrawResbuf filter = new MxDrawResbuf(); filter.AddStringEx("tkbox", 8); ss.Select(MCAD_McSelect.mcSelectionSetAll, null, null, filter); for (int i = 0; i < ss.Count; i++) { axMxDrawX1.Erase(ss.Item(i).ObjectID); } //删掉画框的图层 MxDrawDatabase database = axMxDrawX1.GetDatabase() as MxDrawDatabase; IMxDrawLayerTableRecord layer = database.GetLayerTable().GetAt("tkbox", false); if (layer != null) { layer.Erase(); } return; }
//获取支座 public MxDrawPolyline GetSeatForRange(MxDrawPoint pt, MxDrawPoint spt) { double range1 = 2000, range2 = 300; MxDrawSelectionSet collect = new MxDrawSelectionSet(); MxDrawResbuf filter = new MxDrawResbuf(); MxDrawLayerTable layer = (Program.MainForm.axMxDrawX1.GetDatabase() as MxDrawDatabase).GetLayerTable(); MxDrawPoint start = new MxDrawPoint { x = pt.x + range1, y = pt.y + range1, z = pt.z }; MxDrawPoint end = new MxDrawPoint { x = pt.x - range1, y = pt.y - range1, z = pt.z }; //Program.MainForm.axMxDrawX1.DrawLine(start.x, start.y, start.x, start.y); //Program.MainForm.axMxDrawX1.DrawLine(start.x, start.y, start.x, end.y); //Program.MainForm.axMxDrawX1.DrawLine(start.x, end.y, end.x, end.y); //Program.MainForm.axMxDrawX1.DrawLine(end.x, end.y, end.x, start.y); //Program.MainForm.axMxDrawX1.DrawLine(end.x, start.y, start.x, start.y); collect.Select(MCAD_McSelect.mcSelectionSetCrossing, start, end, filter); MxDrawEntity entity; //MxDrawLayerTable layer = (Program.MainForm.axMxDrawX1.GetDatabase() as MxDrawDatabase).GetLayerTable(); //MxDrawLayerTableRecord dd; for (int i = 0; i < collect.Count; i++) { entity = collect.Item(i); if (entity == null) { continue; } if (entity.ObjectName == "McDbPolyline") { MxDrawPolyline polyline = entity as MxDrawPolyline; MxDrawLayerTableRecord dd = layer.GetAt(entity.Layer); if (dd.Color.colorIndex != 9) { MxDrawPoint st = polyline.GetStartPoint(); MxDrawPoint et = polyline.GetEndPoint(); if (st.x == et.x && st.y == et.y) { return(polyline); } } } } return(new MxDrawPolyline()); }
//获取梁线 public MxDrawLine GetLineForRange(MxDrawLine et) { MxDrawPoint pt = et.GetStartPoint(); MxDrawPoint ept = et.GetEndPoint(); MxDrawLayerTable layer = (Program.MainForm.axMxDrawX1.GetDatabase() as MxDrawDatabase).GetLayerTable(); MxDrawSelectionSet collect = new MxDrawSelectionSet(); MxDrawResbuf filter = new MxDrawResbuf(); MxDrawLine entity; MxDrawLine result = new MxDrawLine(); double distance = 100000000; collect.Select(MCAD_McSelect.mcSelectionSetAll, null, null, filter); for (int i = 0; i < collect.Count; i++) { entity = collect.Item(i) as MxDrawLine; if (entity == null) { continue; } MxDrawLayerTableRecord dd = layer.GetAt(entity.Layer); if (entity.ObjectName == "McDbLine" && entity.handle != et.handle && dd.Color.colorIndex != 1) { //double rs1 = MathSience.pointToLineDistance(entity.GetStartPoint(), entity.GetEndPoint(), pt.x, pt.y); //double rs2 = MathSience.pointToLineDistance(entity.GetStartPoint(), entity.GetEndPoint(), ept.x, ept.y); double rs1 = MathSience.DistanceForPointToABLine(pt.x, pt.y, entity.GetStartPoint(), entity.GetEndPoint()); double rs2 = MathSience.DistanceForPointToABLine(ept.x, ept.y, entity.GetStartPoint(), entity.GetEndPoint()); if (rs1 <= distance) { distance = rs1; result = entity; } if (rs2 <= distance) { distance = rs2; result = entity; } } } return(result); }
private void axMxDrawX1_MxKeyUp(object sender, AxMxDrawXLib._DMxDrawXEvents_MxKeyUpEvent e) { //ESC取消掉执行此功能 if (e.lVk == 27) { bar_state.state = false; } //shift切换选择 if (e.lVk == 16) { if (bar_state.id == 1001) { MxDrawSelectionSet mxDrawSelection = new MxDrawSelectionSet(); MxDrawResbuf filter = new MxDrawResbuf(); mxDrawSelection.CurrentSelect(filter); if (mxDrawSelection.Count > 0) { axMxDrawX1.AddCurrentSelect(mxDrawSelection.Item(objID).ObjectID, true, true); } } } }
private void AxMxDrawX1_MouseEvent1(object sender, _DMxDrawXEvents_MouseEventEvent e) { if (e.lType == 2 && (Control.ModifierKeys & Keys.Control) == Keys.Control) { MxDrawSelectionSet mxDrawSelection = new MxDrawSelectionSet(); MxDrawResbuf filter = new MxDrawResbuf(); filter.AddStringEx("HLT_BEAM_CLINE", 8); MxDrawPoint point = new MxDrawPoint { x = e.dX, y = e.dY, }; mxDrawSelection.SelectAtPoint(point, filter); if (mxDrawSelection.Count > 0) { axMxDrawX1.TwinkeEnt(mxDrawSelection.Item(0).ObjectID); onePeaceEdit.LineID = mxDrawSelection.Item(0).handle; } axMxDrawX1.MouseEvent -= AxMxDrawX1_MouseEvent1; } }
private void Delete_layer() { MxDrawSelectionSet scn = new MxDrawSelectionSet(); MxDrawResbuf filter = new MxDrawResbuf(); filter.AddStringEx("HLT_BEAM_CLINE", 8); scn.Select(MCAD_McSelect.mcSelectionSetWindow, null, null, filter); for (int i = 0; i < scn.Count; i++) { scn.Item(i).Erase(); } // 得到数据库对象. MxDrawDatabase database = (MxDrawDatabase)axMxDrawX1.GetDatabase(); // 得到层表. MxDrawLayerTable layerTable = database.GetLayerTable(); // 得到层。 MxDrawLayerTableRecord layer = layerTable.GetAt("HLT_BEAM_CLINE", false); if (layer != null) { layer.Erase(); } }
//鼠标点击事件 private void axMxDrawX1_MouseEvent(object sender, AxMxDrawXLib._DMxDrawXEvents_MouseEventEvent e) { /* * 事件类型,1鼠标移动,2是鼠标左键按下,3是鼠标右键按下,4是鼠标左键双击 * 5是鼠标左键释放 6是鼠标右键释放 7是鼠标中键按下 8是鼠标中键释放 * 9是鼠标中键双击 10是鼠标中键滚动 */ switch (e.lType) { case 4: //左键选择元素图层--所有元素 //if(bar_state.state==true&& bar_state.id == 1001) { MxDrawSelectionSet mxDrawSelection = new MxDrawSelectionSet(); MxDrawResbuf filter = new MxDrawResbuf(); MxDrawPoint point = new MxDrawPoint(); point.x = e.dX; point.y = e.dY; mxDrawSelection.SelectAtPoint(point, filter); if (mxDrawSelection.Count > 0) { MxDrawEntity entity = mxDrawSelection.Item(1); //MxDrawLayerTable layer = (axMxDrawX1.GetDatabase() as MxDrawDatabase).GetLayerTable(); //MxDrawLayerTableRecord dd = layer.GetAt(entity.Layer); if (entity.ObjectName == "McDbLine") { MessageBox.Show(JsonConvert.SerializeObject(new { handle = entity.handle, ID = entity.ObjectID, Line = entity.ObjectName, B = entity.LineType, pt1 = ((MxDrawLine)entity).GetStartPoint(), pt2 = ((MxDrawLine)entity).GetEndPoint(), //color=dd.Color.colorIndex })); } else { MessageBox.Show(JsonConvert.SerializeObject(new { handle = entity.handle, ID = entity.ObjectID, Line = entity.ObjectName, B = entity.LineType, rotate = ((MxDrawText)entity).Rotation //pt1 = ((MxDrawLine)entity).GetStartPoint(), //pt2 = ((MxDrawLine)entity).GetEndPoint(), //color=dd.Color.colorIndex })); } //double c=Models.MathSience.DistanceForPointToABLine(121324.953422, 33700.002475, ((MxDrawLine)entity).GetStartPoint(),((MxDrawLine)entity).GetEndPoint()); //double c1 = Algorithm.MathSience.GetAngle(new MxDrawPoint { x = 121324.95342187915, y = 54350.00279569807 }, ((MxDrawLine)entity).GetStartPoint(), ((MxDrawLine)entity).GetEndPoint()); double c1 = Algorithm.MathSience.GetLineK(((MxDrawLine)entity).GetStartPoint(), ((MxDrawLine)entity).GetEndPoint()); MessageBox.Show(c1.ToString()); //double c = Algorithm.MathSience.GetAngle2(((MxDrawLine)entity).GetStartPoint(), ((MxDrawLine)entity).GetEndPoint()); //MxDrawLine line = axMxDrawX1.HandleToObject("61FCB") as MxDrawLine; //PointF point1 = Algorithm.MathSience.point_intersection(line.GetStartPoint(), line.GetEndPoint(), ((MxDrawLine)entity).GetStartPoint(), ((MxDrawLine)entity).GetEndPoint()); } } break; } }
//选择集 private void AxMxDrawX1_MouseEvent(object sender, _DMxDrawXEvents_MouseEventEvent e) { MxDrawPoint start = new MxDrawPoint(), end = new MxDrawPoint(); if (PublicValue != null) { dynamic c = PublicValue; start.x = c.Lx; start.y = c.Ly; start.z = c.Lz; end.x = c.Rx; end.y = c.Ry; end.z = c.Rz; } { MxDrawSelectionSet mxDrawSelection; MxDrawResbuf filter; MxDrawPoint point; if (e.lType == 2 && (Control.ModifierKeys & Keys.Control) == Keys.Control) { mxDrawSelection = new MxDrawSelectionSet(); filter = new MxDrawResbuf(); point = new MxDrawPoint(); point.x = e.dX; point.y = e.dY; mxDrawSelection.SelectAtPoint(point, filter); //MessageBox.Show(mxDrawSelection.Count.ToString()); if (mxDrawSelection.Count > 0) { if (start.x != 0 && end.x != 0) { if (!MathSience.IsContains(point, start, end)) { return; } } //MessageBox.Show(mxDrawSelection.Item(0).handle.ToString()); axMxDrawX1.TwinkeEnt(mxDrawSelection.Item(0).ObjectID); if (BeamType == "change_line") { if (beam.beam.side_lines.Find(x => x == mxDrawSelection.Item(0).handle) == null) { beam.beam.side_lines.Add(mxDrawSelection.Item(0).handle); } else { axMxDrawX1.StopTwinkeEnt(mxDrawSelection.Item(0).ObjectID); beam.beam.side_lines.Remove(mxDrawSelection.Item(0).handle); } } if (BeamType == "change_dim") { if (beam.beam.dim_texts.Find(x => x == mxDrawSelection.Item(0).handle) == null) { beam.beam.dim_texts.Add(mxDrawSelection.Item(0).handle); } else { axMxDrawX1.StopTwinkeEnt(mxDrawSelection.Item(0).ObjectID); beam.beam.dim_texts.Remove(mxDrawSelection.Item(0).handle); } } if (BeamType == "change_seat") { if (beam.beam.seat_lines.Find(x => x == mxDrawSelection.Item(0).handle) == null) { beam.beam.seat_lines.Add(mxDrawSelection.Item(0).handle); } else { axMxDrawX1.StopTwinkeEnt(mxDrawSelection.Item(0).ObjectID); beam.beam.seat_lines.Remove(mxDrawSelection.Item(0).handle); } } } } else if (e.lType == 2 && (Control.ModifierKeys & Keys.Shift) == Keys.Shift) { //dynamic pt = PublicValue; //MxDrawPoint sp = new MxDrawPoint { x = pt.Lx, y = pt.Ly }; //MxDrawPoint ep = new MxDrawPoint { x = pt.Rx, y = pt.Ry }; mxDrawSelection = new MxDrawSelectionSet(); filter = new MxDrawResbuf(); point = new MxDrawPoint(); point.x = e.dX; point.y = e.dY; mxDrawSelection.SelectAtPoint(point, filter); if (mxDrawSelection.Count > 0) { MxDrawEntity entity = mxDrawSelection.Item(0); //MessageBox.Show(entity.Layer); filter = new MxDrawResbuf(); mxDrawSelection = new MxDrawSelectionSet(); filter.AddStringEx(entity.Layer, 8);// if (start.x == 0) { mxDrawSelection.Select(MCAD_McSelect.mcSelectionSetAll, null, null, filter);//获取此图层元素 } else { mxDrawSelection.Select(MCAD_McSelect.mcSelectionSetWindow, start, end, filter);//获取此图层元素 } for (int i = 0; i < mxDrawSelection.Count; i++) { axMxDrawX1.TwinkeEnt(mxDrawSelection.Item(i).ObjectID); if (BeamType == "change_line") { if (beam.beam.side_lines.Find(x => x == mxDrawSelection.Item(i).handle) == null) { beam.beam.side_lines.Add(mxDrawSelection.Item(i).handle); } else { axMxDrawX1.StopTwinkeEnt(mxDrawSelection.Item(i).ObjectID); beam.beam.side_lines.Remove(mxDrawSelection.Item(i).handle); } } if (BeamType == "change_dim") { if (beam.beam.dim_texts.Find(x => x == mxDrawSelection.Item(i).handle) == null) { beam.beam.dim_texts.Add(mxDrawSelection.Item(i).handle); } else { axMxDrawX1.StopTwinkeEnt(mxDrawSelection.Item(i).ObjectID); beam.beam.dim_texts.Remove(mxDrawSelection.Item(i).handle); } } if (BeamType == "change_seat") { if (beam.beam.seat_lines.Find(x => x == mxDrawSelection.Item(i).handle) == null) { beam.beam.seat_lines.Add(mxDrawSelection.Item(i).handle); } else { axMxDrawX1.StopTwinkeEnt(mxDrawSelection.Item(i).ObjectID); beam.beam.seat_lines.Remove(mxDrawSelection.Item(i).handle); } } //beam.beam.seat_lines.Add(mxDrawSelection.Item(i).handle); //选中元素 //axMxDrawX1.AddCurrentSelect(mxDrawSelection.Item(i).ObjectID, false, false); } } } //axMxDrawX1.SendStringToExecute(""); }; }
private void makeAutoImgBtn_Click(object sender, RoutedEventArgs e) { //先进行参数计算 //每一开深度,三开底部和煤层顶板的距离 double oneKai = 30; if (wanQuDaiTb.Text.Trim().Equals("")) { MessageBox.Show("未计算弯曲带高度,请修正再尝试井型设计"); return; } double twoKai = double.Parse(wanQuDaiTb.Text) + 20; int meiIndex = layers.Count - 1; for (; meiIndex >= 0; meiIndex--) { if (layers[meiIndex].yanXing.Equals("煤")) { break; } } if (meiIndex <= 0) { MessageBox.Show("岩层数据有误,请修正再尝试自动设计"); tabControl.SelectedItem = gridinputTabItem; return; } double threeKai = layers[meiIndex - 1].leiJiShenDu - 10; double threeToMei = 10; //局部固井的深度值 double jbgjShendu = double.Parse(wanQuDaiTb.Text); //各级套管外径;水泥环厚度 double snhHoudu = editZengYi.a1 - editZengYi.aw; double tgwj1, tgwj2, tgwj3; tgwj1 = keyLayers[0].tgwj; tgwj2 = keyLayers[wanQuDaiIndex].tgwj; tgwj3 = keyLayers[keyLayers.Count - 1].tgwj; //高位位置数量,破坏主因 string dangerStr = ""; int dangerCnt = 0; ERRORCODE errcode = computeSafe(keyLayers.Count); switch (errcode) { case ERRORCODE.计算成功: for (int i = 0; i < keyLayers.Count; i++) { if (keyLayers[i].jqaqxs < 1) { keyLayers[i].IsDangerous = true; dangerCnt++; dangerStr += "\\P" + dangerCnt + " 深度:" + keyLayers[i].ycsd.ToString("f3") + "m 剪切安全系数低,值为:" + keyLayers[i].jqaqxs.ToString("f3"); } else if(keyLayers[i].lsaqxs < 1) { keyLayers[i].IsDangerous = true; dangerCnt++; dangerStr += "\\P" + dangerCnt + " 深度:" + keyLayers[i].ycsd.ToString("f3") + "m 拉伸安全系数低,值为:" + keyLayers[i].lsaqxs.ToString("f3"); } else { keyLayers[i].IsDangerous = false; } } break; case ERRORCODE.计算异常: MessageBox.Show("因计算安全系数出错,未生成cad图,请检查数据合理性"); return; case ERRORCODE.没有关键层数据: MessageBox.Show("因没有关键层数据,未生成cad图"); return; } //显示cad tabControl.SelectedItem = autoDesignCadTabItem; cadViewer.OpenDwgFile("cads/三开-一全固二局固三" + AutoWjfs3 + ".dwg"); cadViewer.ZoomCenter(2500, 300); cadViewer.ZoomScale(1); //参数标注 MxDrawSelectionSet ss = new MxDrawSelectionSet(); IMxDrawResbuf spFilter = new MxDrawResbuf(); ss.Select2(MCAD_McSelect.mcSelectionSetAll, null, null, null, null); for (int j = 0; j < ss.Count; j++) { MxDrawEntity ent = ss.Item(j); if (ent is MxDrawMText) { MxDrawMText mText = (MxDrawMText)ent; string contents = mText.Contents; //MessageBox.Show(contents); //地面井名称 if(contents.Contains("地面井名称")) { mText.Contents = contents.Replace("地面井名称", "地面井名称:" + Path.GetFileNameWithoutExtension(FilePath)); } //描述 else if(contents.Contains("一开结构")) { mText.Contents = contents.Replace("一开结构", "一开结构\\P\\P" + AutoMiaoshu1); } else if(contents.Contains("二开结构")){ mText.Contents = contents.Replace("二开结构", "二开结构\\P\\P" + AutoMiaoshu2); } else if(contents.Contains("三开结构")){ mText.Contents = contents.Replace("三开结构", "三开结构\\P\\P" + AutoMiaoshu3); } //各级套管深度、局部固井深度、三开底部和煤层顶板的距离 else if (contents.Contains("一开深度")) { mText.Contents = contents.Replace("一开深度", oneKai.ToString("f3") + "m"); } else if (contents.Contains("二开深度")) { mText.Contents = contents.Replace("二开深度", twoKai.ToString("f3") + "m"); } else if (contents.Contains("三开深度")) { mText.Contents = contents.Replace("三开深度", threeKai.ToString("f3") + "m"); } else if (contents.Contains("局部固井深度")) { mText.Contents = contents.Replace("局部固井深度", jbgjShendu.ToString("f3") + "m"); } else if (contents.Contains("底部到顶板距离")) { mText.Contents = contents.Replace("底部到顶板距离", threeToMei.ToString("f3") + "m"); } //各级套管型号和参数 else if (contents.Contains("各级套管型号和参数")) { mText.Contents = contents.Replace("各级套管型号和参数", "各级套管型号和参数\\P\\P" + "一开型号:" + AutoTgxh1 + " 外径:" + tgwj1 + "mm" + "\\P" + "二开型号:" + AutoTgxh2 + " 外径:" + tgwj2 + "mm" + "\\P" + "三开型号:" + AutoTgxh3 + " 外径:" + tgwj3 + "mm" ); } //固井工艺、完井工艺、水泥环厚度 else if (contents.Contains("固井工艺、完井工艺、水泥环厚度")) { mText.Contents = contents.Replace("固井工艺、完井工艺、水泥环厚度", "固井工艺、完井工艺、水泥环厚度\\P\\P" + "一全固二局固三" + AutoWjfs3 + "\\P" + "水泥环厚度:" + snhHoudu + "m"); } //高危位置 else if (contents.Contains("高危位置")) { mText.Contents = contents.Replace("高危位置", "高危位置数量:" + dangerCnt + "\\P" + dangerStr); } } } cadViewer.ReDraw(); }
//获取相邻的梁线 public MxDrawLine GetMoreLine(MxDrawLine line) { int range = 600; MxDrawSelectionSet collect = new MxDrawSelectionSet(); MxDrawResbuf filter = new MxDrawResbuf(); MxDrawPoint start = line.GetStartPoint(); MxDrawPoint end = line.GetEndPoint(); MxDrawLayerTable layer = (Program.MainForm.axMxDrawX1.GetDatabase() as MxDrawDatabase).GetLayerTable(); collect.Select(MCAD_McSelect.mcSelectionSetCrossing, new MxDrawPoint { x = end.x + range, y = end.y + range, z = end.z }, new MxDrawPoint { x = end.x - range, y = end.y - range, z = end.z }, filter); //获取线判断角度<2 for (int i = 0; i < collect.Count; i++) { MxDrawLine entity = collect.Item(i) as MxDrawLine; if (entity == null) { continue; } if (entity.handle == line.handle) { continue; } if (entity.ObjectName == "McDbLine") { MxDrawLayerTableRecord cd = layer.GetAt(entity.Layer); if (cd.Color.colorIndex != 1) { double angleLine = MathSience.GetAngle(line.EndPoint, entity.StartPoint, entity.EndPoint); if (angleLine < 2) { double angle = MathSience.GetAngle2(line.GetStartPoint(), line.GetEndPoint()); double angle2 = MathSience.GetAngle2(entity.GetStartPoint(), entity.GetEndPoint()); if ((angle < 3 && angle > -2) || Math.Abs(Math.Round(angle)) == 180)//左右 { if (angle2 < 3 && angle2 > -2) { if (MathSience.GetDistance(entity.StartPoint.x, entity.StartPoint.y, entity.EndPoint.x, entity.EndPoint.y) > 100) { return(entity); } } } if ((angle > 80 && angle < 95) || (angle < -80 && angle > -95))//上下 { if ((angle2 > 80 && angle2 < 95) || (angle2 < -80 && angle2 > -95)) { if (MathSience.GetDistance(entity.StartPoint.x, entity.StartPoint.y, entity.EndPoint.x, entity.EndPoint.y) > 100) { return(entity); } } } } } } } return(new MxDrawLine()); }
//获取平行线 public MxDrawLine GetparallelLine(MxDrawLine line) { double range = 600, range2 = 600; MxDrawPoint start = line.GetStartPoint(); MxDrawPoint end = line.GetEndPoint(); MxDrawSelectionSet select = new MxDrawSelectionSet(); MxDrawResbuf filter = new MxDrawResbuf(); MxDrawLayerTable layer = (Program.MainForm.axMxDrawX1.GetDatabase() as MxDrawDatabase).GetLayerTable(); double angle = MathSience.GetAngle2(start, end); if (angle < 3 && angle > -2) { range = 0; } else { range2 = 0; } select.Select(MCAD_McSelect.mcSelectionSetCrossing, new MxDrawPoint { x = start.x - range, y = start.y - range2, z = start.z }, new MxDrawPoint { x = end.x + range, y = end.y + range2, z = end.z }, filter); //Program.MainForm.axMxDrawX1.DrawLine(end.x - range, end.y - range2, end.x - range, end.y+range2); //Program.MainForm.axMxDrawX1.DrawLine(end.x - range, end.y + range2, end.x + range, end.y + range2); //Program.MainForm.axMxDrawX1.DrawLine(end.x + range, end.y + range2, end.x + range, end.y - range2); //Program.MainForm.axMxDrawX1.DrawLine(end.x + range, end.y - range2, end.x - range, end.y - range2); for (int i = 0; i < select.Count; i++) { MxDrawLine entity = select.Item(i) as MxDrawLine; if (entity == null) { continue; } if (select.Item(i).ObjectName == "McDbLine") { MxDrawLayerTableRecord dd = layer.GetAt(entity.Layer); if (line.handle != entity.handle && dd.Color.colorIndex != 1) { if (MathSience.parallel(entity.GetStartPoint(), entity.GetEndPoint(), line.GetStartPoint(), line.GetEndPoint())) { PointF point = MathSience.point_intersection(line.GetStartPoint(), line.GetEndPoint(), entity.GetStartPoint(), entity.GetEndPoint()); //if (point.X==0&&point.Y==0) { var c1 = entity.GetStartPoint(); var c2 = entity.GetEndPoint(); //if (MathSience.GetPointIsInLine(point, c1, c2, 2)) { return(entity); } } } } } } return(new MxDrawLine()); }