public void TestPolygon() { int n; while (true) { double d = Interaction.GetValue("\nNumber of edges"); if (double.IsNaN(d)) { return; } n = (int)d; if (n > 2) { break; } } Point3d center = Interaction.GetPoint("\nCenter"); Draw.Circle(center, 5); Point3d end = Interaction.GetPoint("\nOne vertex"); Draw.Circle(end, 5); Draw.Polygon(n, center, end); }
/// <summary> /// 获取用户交互创建的Polyline /// </summary> /// <param name="message">提示</param> /// <returns>多段线</returns> public static Polyline GetPromptPolyline(string message) // newly 20130806 { var point = Interaction.GetPoint(message); if (point.IsNull()) { return(null); } var poly = NoDraw.Pline(new[] { point }); var prev = point; var tempIds = new List <ObjectId>(); while (true) { point = Interaction.GetLineEndPoint(message, prev); if (point.IsNull()) { break; } tempIds.Add(Draw.Line(prev, point)); poly.AddVertexAt(poly.NumberOfVertices, point.ToPoint2d(), 0, 0, 0); prev = point; } tempIds.QForEach(x => x.Erase()); return(poly); }
public static void GetPoint2() { var p = Interaction.GetPoint("Point"); Interaction.WriteLine("P1(Original):" + p.ToString()); MyTool.ShowWCSAndUCS(p); }
public static void GetText() { var p1 = Interaction.GetPoint("坐标1"); var p2 = Interaction.GetPoint("坐标2"); string name = ""; string txt = ""; txt += string.Format("p1:{0},p2:{1}\nobjs:\n", p1, p2); ObjectId[] objs = Interaction.GetCrossingSelection(p1, p2); CADShapeList sps = new CADShapeList(); for (int i = 0; i < objs.Length; i++) { ObjectId item = objs[i]; var sp = item.ToCADShape(true); sps.Add(sp); txt += string.Format("{0}\n", sp); } sps.SortByXY();//按坐标排序 foreach (CADShape sp in sps) { if (sp.Text == "AC") { continue;; } name += sp.Text; } MyTool.TextReport("名称:" + name, txt, 700, 500); }
public static void GetColumnPointsEx() { try { CADAreaList areaList = new CADAreaList(); var zero = Interaction.GetPoint("ZeroPoint"); string[] keys = { "0:左下", "1:右下", "2:右上", "3:左上" }; string p1 = zero.ToString(); string p2 = zero.ToUCS().ToString(); string p3 = zero.ToWCS().ToString(); Interaction.WriteLine(string.Format("\n zero [{0},{1},{2}]", p1, p2, p3)); var key = Interaction.GetKeywords("\nChoose1 Zero Type ", keys); if (string.IsNullOrEmpty(key)) { return; } //var key = Interaction.GetKeywords("\nChoose1 Zero Type ", keys); var columns = Interaction.GetEntitysByLayers("COLUMN"); var area = columns.ToCADArea(zero.ToCADPoint(true), key, true, true); area.Name = "主厂房0m层"; areaList.Add(area); var txt = areaList.ToXml(); MyTool.TextReport("Points", txt, 700, 500); } catch (System.Exception ex) { MyTool.TextReport("Exception", ex.ToString(), 700, 500); } }
public void TestDimension() { Point3d a = Interaction.GetPoint("\nPoint 1"); Point3d b = Interaction.GetPoint("\nPoint 2"); Point3d c = Interaction.GetPoint("\nPoint of label"); Draw.Dimlin(a, b, c); }
public static void GetLineOfPoint() { var p = Interaction.GetPoint("GetLineOfPoint"); Interaction.WriteLine(p.ToString()); var p2 = Interaction.GetLineEndPoint("otherPoint", p); Interaction.WriteLine(p2.ToString()); }
public static void AddCircle() { var p = Interaction.GetPoint("Point"); var radius = Interaction.GetString("Radius"); var cid = Draw.Circle(p.ToWCS(), radius.ToInt()); var zeroSp = cid.ToCADShape(true); Interaction.Write(zeroSp.GetPoint().ToString()); }
public void TestSelection() { Point3d point = Interaction.GetPoint("\nPoint"); double value = Interaction.GetDistance("\nSize"); Vector3d size = new Vector3d(value, value, 0); ObjectId[] ids = Interaction.GetWindowSelection(point - size, point + size); Interaction.WriteLine("{0} entities selected.", ids.Count()); }
public void TestRegion() { ObjectId id = Interaction.GetEntity("\nEntity"); Draw.Region(id); Point3d point = Interaction.GetPoint("\nPick one point"); Draw.Boundary(point, BoundaryType.Region); }
public static void LoadPoints() { try { string txt = Gui.InputBox("输入基站坐标"); Point3d zero = Interaction.GetPoint("ZeroPoint"); double size = Interaction.GetValue("点(基站)大小", 1000); double height = Interaction.GetValue("文字高度", 1000); //string key = Interaction.GetString("搜索", ""); string key = ""; string[] lines = txt.Split('\n'); for (int i = 0; i < lines.Length; i++) { string line = lines[i].Trim(); if (string.IsNullOrEmpty(line)) { continue; } string[] parts = line.Split(','); string name = ""; double x = 0, y = 0, z = 0; if (parts.Length == 5) { name = parts[0]; x = parts[2].ToDouble(); y = parts[3].ToDouble(); z = parts[4].ToDouble(); } if (parts.Length == 4) { name = parts[0]; x = parts[1].ToDouble(); y = parts[2].ToDouble(); z = parts[3].ToDouble(); } if (string.IsNullOrEmpty(key) || name == key) { Point3d point = new Point3d(x + zero.X, y + zero.Y, z + zero.Z); Draw.Point(point); if (size > 0) { Draw.Circle(point, size); } if (height > 0) { Draw.Text(name, height, point); } } } } catch (System.Exception ex) { MyTool.TextReport("Exception", ex.ToString(), 700, 500); } }
public static void GetPoint1() { var p = Interaction.GetPoint("Point"); var p2 = p.ToWCS(); var p3 = p2.ToUCS(); string txt = string.Format("P1(Original):{0}\nP2(WCS世界坐标):{1}\nP3(UCS局部坐标):{2}", p, p2, p3); Gui.TextReport("PT", txt, 700, 500); }
public static void ShowPoints() { var p1 = Interaction.GetPoint("坐标1"); var p2 = Interaction.GetPoint("坐标2"); Interaction.WriteLine(string.Format("({0} {1})", p1, p2)); PointInfo pi1 = GetRoomsCommand.GetPointInfo(p1); PointInfo pi2 = GetRoomsCommand.GetPointInfo(p2); Interaction.WriteLine(string.Format("({0} {1})", pi1, pi2)); }
public void TestEllipse() { Point3d center = Interaction.GetPoint("\nCenter"); Draw.Circle(center, 5); Point3d endX = Interaction.GetPoint("\nEnd of one axis"); Draw.Circle(endX, 5); double radiusY = Interaction.GetValue("\nRadius of another axis"); Draw.Ellipse(center, endX, radiusY); }
public void TestArc2() { Point3d start = Interaction.GetPoint("\nStart"); Draw.Circle(start, 5); Point3d center = Interaction.GetPoint("\nCenter"); Draw.Circle(center, 5); double angle = Interaction.GetValue("\nAngle"); Draw.ArcSCA(start, center, angle); }
public static void GetLinesOfPoint() { var p = Interaction.GetPoint("GetLineOfPoint"); //Interaction.GetEntity() //Interaction. Interaction.GetEntitysByLayers(); var ids = QuickSelection.SelectAll(); foreach (ObjectId id in ids) { } }
public void TestArc() { Point3d point1 = Interaction.GetPoint("\nStart"); Draw.Circle(point1, 5); Point3d point2 = Interaction.GetPoint("\nMid"); Draw.Circle(point2, 5); Point3d point3 = Interaction.GetPoint("\nEnd"); Draw.Circle(point3, 5); Draw.Arc3P(point1, point2, point3); }
public void TestGraph() { GraphOption opt = new GraphOption { xDelta = 20, yDelta = 0.5, yRatio = 0.5, SampleCount = 500 }; GraphPlotter gp = new GraphPlotter(opt); gp.Plot(Math.Sin, new Interv(5, 102)); gp.Plot(x => Math.Cos(x) + 1, new Interv(10, 90), 3); ObjectId graph = gp.GetGraphBlock(); BlockReference br = new BlockReference(Point3d.Origin, graph); Point3d first = Interaction.GetPoint("\nSpecify extent point 1"); Interaction.InsertScalingEntity(br, first, "\nSpecify extent point 2"); }
public void TestSpline() { List <Point3d> points = new List <Point3d>(); while (true) { Point3d point = Interaction.GetPoint("\nSpecify a point"); if (point.IsNull()) { break; } points.Add(point); Draw.Circle(point, 5); } Draw.SplineCV(points.ToArray(), true); }
public static void GetPoint1() { var p = Interaction.GetPoint("Point"); var p2 = p.ToWCS(); var p3 = p2.ToUCS(); string txt = string.Format("P1(Original):{0}\nP2(WCS世界坐标):{1}\nP3(UCS局部坐标):{2}\n", p, p2, p3); var zero = new Point3d(0, 0, 0); var zero_WCS = zero.ToWCS(); var zero_UCS = zero.ToUCS(); txt += string.Format("------\nP1(Original):{0}\nP2(WCS世界坐标):{1}\nP3(UCS局部坐标):{2}", (p - zero), (p2 - zero_WCS), (p3 - zero_UCS)); MyTool.TextReport("PT", txt, 700, 500); }
public static void GetColumnPointsEx() { CADAreaList areaList = new CADAreaList(); var zero = Interaction.GetPoint("ZeroPoint"); string[] keys = { "0:左下", "1:右下", "2:右上", "3:左上" }; var key = Interaction.GetKeywords("\nChoose Zero Type", keys); var columns = Interaction.GetEntitysByLayers("COLUMN"); var area = columns.ToCADArea(zero, key); area.Name = "主厂房0m层"; areaList.Add(area); var txt = areaList.ToXml(); Gui.TextReport("Points", txt, 700, 500); }
private static TopoInfo GetFloor() { string txt = Interaction.GetString("输入楼层名称"); if (string.IsNullOrEmpty(txt)) { txt = "楼层1"; } var p1 = Interaction.GetPoint("楼层坐标1"); PointInfo pi1 = GetPointInfo(p1); var p2 = Interaction.GetPoint("楼层坐标2"); PointInfo pi2 = GetPointInfo(p2); TopoInfo topoInfo = GetTopoInfo(txt, AreaTypes.楼层, pi1, pi2); Interaction.WriteLine(string.Format("{0} {1} {2}\n", pi1, pi2, txt)); //Interaction.WriteLine(""); return(topoInfo); }
public static void PolyLanding() { ObjectId[] ids = QuickSelection.SelectAll("*LINE,ARC").ToArray(); List <ObjectId> landingLineIds = new List <ObjectId>(); while (true) { Point3d p = Interaction.GetPoint("\nSpecify a point"); if (p.IsNull()) { break; } Point3d[] landings = ids.QSelect(x => (x as Curve).GetClosestPointTo(p, false)).ToArray(); double minDist = landings.Min(x => x.DistanceTo(p)); Point3d landing = landings.First(x => x.DistanceTo(p) == minDist); Interaction.WriteLine("Shortest landing distance of point ({0:0.00},{1:0.00}) is {2:0.00}。", p.X, p.Y, minDist); ObjectId landingLineId = Draw.Line(p, landing); landingLineIds.Add(landingLineId); } landingLineIds.QForEach(x => x.Erase()); }
private static TopoInfo GetFloorEx() { string txt = Interaction.GetString("输入楼层名称"); if (string.IsNullOrEmpty(txt)) { txt = "楼层1"; } int pCout = 0; List <PointInfo> pis = new List <PointInfo>(); while (true) { pCout++; var p1 = Interaction.GetPoint("楼层坐标" + pCout); if (double.IsNaN(p1.X)) { if (pis.Count >= 2) { break; //出口 } else { continue; } } PointInfo pi1 = GetPointInfo(p1); pis.Add(pi1); } //var p2 = Interaction.GetPoint("楼层坐标2"); //PointInfo pi2 = GetPointInfo(p2); TopoInfo topoInfo = GetTopoInfo(txt, AreaTypes.楼层, pis); Interaction.WriteLine(string.Format("{0} {1} {2}\n", pis.First(), pis.Last(), txt)); //Interaction.WriteLine(""); return(topoInfo); }
private static TopoInfo GetRoom() { roomCount++; var p1 = Interaction.GetPoint("房间坐标1"); if (double.IsNaN(p1.X)) { return(null); //这里是出口 } var p2 = Interaction.GetPoint("房间坐标2"); if (double.IsNaN(p2.X)) { return(null); //这里是出口 } string room = GetText(p1, p2); if (string.IsNullOrEmpty(room)) { room = Interaction.GetString("输入房间名称"); if (string.IsNullOrEmpty(room)) { room = "房间_" + roomCount; } } PointInfo pi1 = GetPointInfo(p1); PointInfo pi2 = GetPointInfo(p2); TopoInfo topoInfo = GetTopoInfo(room, AreaTypes.机房, pi1, pi2); Interaction.WriteLine(string.Format("{0} {1} {2}", pi1, pi2, room)); Interaction.WriteLine(""); //string xml = XmlSerializeHelper.GetXmlText(topoInfo); //Gui.TextReport("房间:" + txt, xml, 700, 500); return(topoInfo); }
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); }
public void TestHatch3() { Point3d seed = Interaction.GetPoint("\nPick one point"); Draw.Hatch("SOLID", seed); }
public void TestBoundary() { Point3d point = Interaction.GetPoint("\nPick one point"); Draw.Boundary(point, BoundaryType.Polyline); }
public static void GetAnchors() { try { var zero = Interaction.GetPoint("选择原点"); //string[] keys = { "1F", "2F", "3F", "4F" }; //var key = Interaction.GetKeywords("\n选择楼层", keys); var anchorObjects = Interaction.GetEntitysByLayers("-人员定位"); CADShapeList sps = new CADShapeList(); for (int i = 0; i < anchorObjects.Length; i++) { ObjectId item = anchorObjects[i]; var sp = item.ToCADShape(true); sps.Add(sp); Interaction.WriteLine(string.Format("{0}({1}/{2})", sp, i + 1, anchorObjects.Length)); } var types = sps.GetTypesEx(); string typesText = ""; foreach (var item in types) { typesText += item.Key + ","; } Interaction.Write("Types:" + typesText); //var circleList = types["Circle"]; //var zeroCircle = circleList[0]; //var zeroP = zeroCircle.GetPoint(); var pZero = zero.ToCADPoint(false);//获取的坐标原本就是用户坐标系的 foreach (CADShape sp in sps) { sp.SetZero(pZero); } CADShapeList anchorList = new CADShapeList(); if (types.ContainsKey("BlockReference")) { anchorList = types["BlockReference"]; } CADShapeList textList = new CADShapeList(); if (types.ContainsKey("MText")) { textList.AddRange(types["MText"]); } if (types.ContainsKey("DBText")) { textList.AddRange(types["DBText"]); } CADAnchorList result = new CADAnchorList(); List <string> names = new List <string>(); CADShapeList usedText = new CADShapeList(); string repeatNames = ""; for (int i = 0; i < anchorList.Count; i++) { var anchor = anchorList[i]; var text = textList.FindCloset(anchor); if (text != null) { //if (text.Text.Contains(key)) { anchor.Text = text.Text; anchor.Name = text.Text; result.Anchors.Add(anchor); if (!names.Contains(anchor.Name)) { names.Add(anchor.Name); } else { repeatNames += anchor.Name + ";"; } usedText.Add(text); } } } string noUseNames = ""; foreach (var item in textList) { if (!usedText.Contains(item)) { noUseNames += item.Text + ";"; } } result.Anchors.Sort(); for (int i = 0; i < result.Anchors.Count; i++) { result.Anchors[i].Num = i + 1; } if (repeatNames != "") { MyTool.TextReport("重复基站", repeatNames, 700, 500); } if (noUseNames != "") { MyTool.TextReport("遗漏基站", noUseNames, 700, 500); } var txt = result.ToXml(); MyTool.TextReport("Anchors", txt, 700, 500); } catch (System.Exception ex) { MyTool.TextReport("Exception", ex.ToString(), 700, 500); } }