public static ObjectId Arrow(Point3d end, Point3d head, ArrowOption opt) { var body = Draw.Line(end, head); body.QOpenForWrite <Entity>(line => line.ColorIndex = opt.ColorIndex); var arrow = Modify.Group(new[] { body }); if (opt.HeadStyle == ArrowHeadStyle.ClockHand) { var dir = head - end; dir = dir.GetNormal(); var nor = new Vector3d(dir.Y, -dir.X, 0); var headBase = head - opt.HeadLength * dir; var left = headBase - opt.HeadWidth / 2 * nor; var right = headBase + opt.HeadWidth / 2 * nor; var leftLine = Draw.Line(head, left); var rightLine = Draw.Line(head, right); leftLine.QOpenForWrite <Entity>(line => line.ColorIndex = opt.ColorIndex); rightLine.QOpenForWrite <Entity>(line => line.ColorIndex = opt.ColorIndex); Modify.AppendToGroup(arrow, new[] { leftLine, rightLine }); } return(arrow); }
public static ObjectId Arrow(Point3d end, Point3d head, ArrowOption opt) { ObjectId body = Draw.Line(end, head); body.QOpenForWrite <Entity>(x => x.ColorIndex = opt.ColorIndex); ObjectId arrow = Modify.Group(new ObjectId[] { body }); if (opt.HeadStyle == ArrowHeadStyle.ClockHand) { Vector3d dir = head - end; dir = dir.GetNormal(); Vector3d nor = new Vector3d(dir.Y, -dir.X, 0); Point3d headBase = head - opt.HeadLength * dir; Point3d left = headBase - opt.HeadWidth / 2 * nor; Point3d right = headBase + opt.HeadWidth / 2 * nor; ObjectId l = Draw.Line(head, left); ObjectId r = Draw.Line(head, right); l.QOpenForWrite <Entity>(x => x.ColorIndex = opt.ColorIndex); r.QOpenForWrite <Entity>(x => x.ColorIndex = opt.ColorIndex); Modify.AppendToGroup(arrow, new ObjectId[] { l, r }); } return(arrow); }
private static TopoInfo GetRoomEx() { roomCount++; int pCout = 0; List <Point3d> ps = new List <Point3d>(); List <PointInfo> pis = new List <PointInfo>(); double pMinX = double.MaxValue; double pMinY = double.MaxValue; double pMaxX = double.MinValue; double pMaxY = double.MinValue; int ibegin = 0; Point3d lineBegin = new Point3d(); while (true) { pCout++; var p1 = Interaction.GetPoint("房间坐标" + pCout); if (double.IsNaN(p1.X)) { if (pis.Count >= 2) { break; //出口 } else { continue; } } ps.Add(p1); PointInfo pi1 = GetPointInfo(p1); if (ibegin == 0) { lineBegin = p1; ibegin = 1; } else { var leftLine = Draw.Line(lineBegin, p1); lineBegin = p1; // leftLine.SetLayer("aaa"); leftLine.QOpenForWrite <Entity>(line => line.ColorIndex = 3); var arrow = Modify.Group(new[] { leftLine }); } pis.Add(pi1); if (p1.X < pMinX) { pMinX = p1.X; } if (p1.Y < pMinY) { pMinY = p1.Y; } if (p1.Y > pMaxY) { pMaxY = p1.Y; } if (p1.X > pMaxX) { pMaxX = p1.X; } } Point3d pMin = Point3d.Origin; Point3d pMax = Point3d.Origin; if (pis.Count == 2) { pMin = ps[0]; pMax = ps[1]; } else { pMin = new Point3d(pMinX, pMinY, 0); pMax = new Point3d(pMaxX, pMaxY, 0); } string room = GetText(pMin, pMax); if (string.IsNullOrEmpty(room)) { room = Interaction.GetString("输入房间名称"); if (string.IsNullOrEmpty(room)) { room = "房间_" + roomCount; } } TopoInfo topoInfo = GetTopoInfo(room, AreaTypes.机房, pis); Interaction.WriteLine(string.Format("{0} {1} {2}", pis.First(), pis.Last(), room)); Interaction.WriteLine(""); //string xml = XmlSerializeHelper.GetXmlText(topoInfo); //Gui.TextReport("房间:" + txt, xml, 700, 500); return(topoInfo); }