public static void GetShapeInfo() { var id = Interaction.GetEntity("Select:"); var sp = id.ToCADShape(true); //add by qclei 2020-04-29 判断是否是封闭的图形 //bool bl = PulicGadget.ifColseShape(sp); //if (bl) { string name = PulicGadget.getShapeName(sp); if (name != "") { sp.Name = name; } var xml = sp.ToXml(); Gui.TextReport("ShapeInfo", xml, 700, 500); } }
/// <summary> /// 手动获取多个“多边型”图形 /// </summary> public static void GetAllShapeByManual() { ShapesDefine shape = new ShapesDefine(); int iCount = 1; while (true) { string sel = string.Format("Select {0} :", iCount.ToString()); var id = Interaction.GetEntity(sel); if (id.Handle.Value != 0) { var sp = id.ToCADShape(true); //add by qclei 2020-04-29 判断是否是封闭的图形 //bool bl = PulicGadget.ifColseShape(sp); //if (bl) { string name = PulicGadget.getShapeName(sp); if (name != "") { sp.Name = name; } shape.addShape(sp); iCount++; } } else { break; } } if (shape.shapelist.Count() > 0) { string xml = shape.toXml(); Gui.TextReport("ShapeInfos", xml, 700, 500); } }
public static void GetInitInfo() { DateTime start = DateTime.Now; string txt = Interaction.GetString("输入园区名称"); if (string.IsNullOrEmpty(txt)) { txt = "园区"; } TopoInfo floor = GetFloorInfo(); InitInfo initInfo = CreateInitInfo(floor, txt); DateTime end = DateTime.Now; TimeSpan t = end - start; string xml = XmlSerializeHelper.GetXmlText(initInfo); Gui.TextReport(floor.Name + "|" + t, xml, 700, 500); }
public static void ShowLayerName() { double height = 10; string[] range = { "By entities", "By layers" }; int result = Gui.GetOption("Choose one way", range); if (result == -1) { return; } ObjectId[] ids; if (result == 0) { ids = Interaction.GetSelection("\nSelect entities"); ids.QWhere(x => !x.Layer.Contains("_Label")).QSelect(x => x.Layer).Distinct().Select(x => string.Format("{0}_Label", x)).ToList().ForEach(x => DbHelper.GetLayerId(x)); } else { var layers = DbHelper.GetAllLayerNames().Where(x => !x.Contains("_Label")).ToArray(); string layer = Gui.GetChoice("Select a layer", layers); ids = QuickSelection.SelectAll().QWhere(x => x.Layer == layer).ToArray(); DbHelper.GetLayerId(string.Format("{0}_Label", layer)); } var texts = new List <MText>(); ids.QForEach <Entity>(ent => { string layerName = ent.Layer; if (!layerName.Contains("_Label")) { Point3d center = ent.GetCenter(); MText text = NoDraw.MText(layerName, height, center, 0, true); text.Layer = string.Format("{0}_Label", layerName); texts.Add(text); } }); texts.ToArray().AddToCurrentSpace(); }
public static void LoadSelection() { string name = Gui.GetChoice("Which selection to load?", CustomDictionary.GetEntryNames("Selections").ToArray()); if (name == string.Empty) { return; } string dictValue = CustomDictionary.GetValue("Selections", name); var handles = dictValue.Split('|').Select(x => new Handle(Convert.ToInt64(x))).ToList(); List <ObjectId> ids = new List <ObjectId>(); handles.ForEach(x => { ObjectId id = ObjectId.Null; if (HostApplicationServices.WorkingDatabase.TryGetObjectId(x, out id)) { ids.Add(id); } }); Interaction.SetPickSet(ids.ToArray()); }
public static void LoadPoints() { string txt = Gui.InputBox("输入坐标"); double size = Interaction.GetValue("点大小", 2); double height = Interaction.GetValue("文字高度", 2); string key = Interaction.GetString("搜索", ""); 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 = parts[0]; double x = parts[2].ToDouble(); double y = parts[3].ToDouble(); double z = parts[4].ToDouble(); if (string.IsNullOrEmpty(key) || name == key) { Point3d point = new Point3d(x, y, z); Draw.Point(point); if (size > 0) { Draw.Circle(point, size); } if (height > 0) { Draw.Text(name, height, point); } } } }
public static void TextReport() { Gui.TextReport("title", "content", 200, 300, false); }
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 = types["MText"]; } CADAnchorList result = new CADAnchorList(); 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); } } } result.Anchors.Sort(); for (int i = 0; i < result.Anchors.Count; i++) { result.Anchors[i].Num = i + 1; } var txt = result.ToXml(); Gui.TextReport("Anchors", txt, 700, 500); } catch (System.Exception ex) { Gui.TextReport("Exception", ex.ToString(), 700, 500); } }