//支座与L1最远交点共点梁线 public MxDrawLine GetXpoint(MxDrawPoint pts, MxDrawPoint pte, MxDrawPolyline seat) { MxDrawPoints pty = new MxDrawPoints(); MxDrawSelectionSet collect = new MxDrawSelectionSet(); for (int i = 0; i < seat.NumVerts; i++) { MxDrawPoint temp1 = seat.GetPointAt(i); temp1.x = Math.Round(temp1.x, 6); temp1.y = Math.Round(temp1.y, 6); double angle = MathSience.GetAngle2(pts, pte); if ((angle < 3 && angle > -2) || Math.Round(Math.Abs(angle)) == 180)//左右 { if (Math.Round(pts.x, 6) != temp1.x && Math.Round(pte.x, 6) != temp1.x) { pty.Add2(temp1); } } if ((angle > 80 && angle < 95) || (angle < -80 && angle > -95))//上下 { if (Math.Round(pts.y, 6) != temp1.y && Math.Round(pte.y, 6) != temp1.y) { pty.Add2(temp1); } } } if (pty.Count > 1) { PointF ptx = MathSience.point_intersection(pts, pte, pty.Item(0), pty.Item(1)); collect.AllSelect(); for (int i = 0; i < collect.Count; i++) { MxDrawLine line = collect.Item(i) as MxDrawLine; if (line == null) { continue; } if (line.ObjectName == "McDbLine") { MxDrawPoint t1 = line.StartPoint; MxDrawPoint t2 = line.EndPoint; MxDrawPoint tp = new MxDrawPoint { x = ptx.X, y = ptx.Y }; if (Math.Abs(Math.Round(t1.x) - ptx.X) < 1.5 && Math.Abs(Math.Round(t1.y) - ptx.Y) < 1.5) { return(line); } else if (Math.Abs(Math.Round(t2.x) - ptx.X) < 1.5 && Math.Abs(Math.Round(t2.y) - ptx.Y) < 1.5) { return(line); } } } } return(new MxDrawLine()); }
//获取相邻的梁线 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()); }