|
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+using GrxCAD.DatabaseServices;
|
|
|
2
|
+using GrxCAD.EditorInput;
|
|
|
3
|
+using GrxCAD.Geometry;
|
|
|
4
|
+using System;
|
|
|
5
|
+using System.Collections.Generic;
|
|
|
6
|
+using System.Linq;
|
|
|
7
|
+using System.Text;
|
|
|
8
|
+using System.Threading.Tasks;
|
|
|
9
|
+
|
|
|
10
|
+namespace HCTools
|
|
|
11
|
+{
|
|
|
12
|
+
|
|
|
13
|
+ // 存储交点和对应等高线的数据结构
|
|
|
14
|
+ class IntersectionResult
|
|
|
15
|
+ {
|
|
|
16
|
+ public Point3dCollection IntersectionPoint { get; set; }
|
|
|
17
|
+ public Polyline Contour { get; set; }
|
|
|
18
|
+
|
|
|
19
|
+ }
|
|
|
20
|
+ class ChPLContradiction1
|
|
|
21
|
+ {
|
|
|
22
|
+ public static int blc;//比例尺
|
|
|
23
|
+ public static string sqx;//首曲线
|
|
|
24
|
+ public static string jqx;//计曲线
|
|
|
25
|
+ public static int dgj;//计曲线
|
|
|
26
|
+ public static string elevationLayer;//高程点图层名
|
|
|
27
|
+ int looptimes = 5;//循环查找次数
|
|
|
28
|
+
|
|
|
29
|
+ public void Check()
|
|
|
30
|
+ {
|
|
|
31
|
+ Editor ed = GrxCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
|
|
|
32
|
+ Database db = GrxCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database;
|
|
|
33
|
+
|
|
|
34
|
+ var ptlist = GetPt(ed, db);
|
|
|
35
|
+ for (int i = 0; i < ptlist.Count; i++)
|
|
|
36
|
+ {
|
|
|
37
|
+ BlockReference bf = ptlist[i];
|
|
|
38
|
+ //为方便搜索操作,将待检查高程点设置为当前视图的中心点,视图高设置为600
|
|
|
39
|
+ SetWindow(ed, db, bf.Position.X, bf.Position.Y, 600, 600);
|
|
|
40
|
+ bool contradition = false;
|
|
|
41
|
+ for (int j = 0; j < looptimes; j++)
|
|
|
42
|
+ {
|
|
|
43
|
+ double searchlength = 50.0 * (looptimes + 1);
|
|
|
44
|
+ var searchpl_horizontal = SearchDGX(bf.Position, searchlength, ed, db, 0);
|
|
|
45
|
+ var searchpl_vertical = SearchDGX(bf.Position, searchlength, ed, db, 1);
|
|
|
46
|
+ List<Polyline> all_pl = new List<Polyline>();
|
|
|
47
|
+ all_pl.AddRange(searchpl_horizontal);
|
|
|
48
|
+ foreach (var item in searchpl_vertical)
|
|
|
49
|
+ {
|
|
|
50
|
+ if (all_pl.Contains(item))
|
|
|
51
|
+ continue;
|
|
|
52
|
+ else
|
|
|
53
|
+ all_pl.Add(item);
|
|
|
54
|
+ }
|
|
|
55
|
+ if (all_pl.Count < 2)
|
|
|
56
|
+ continue;
|
|
|
57
|
+ contradition = IfContradition(all_pl, bf.Position, searchlength);
|
|
|
58
|
+ if (!contradition)
|
|
|
59
|
+ break;
|
|
|
60
|
+ }
|
|
|
61
|
+ if (contradition)
|
|
|
62
|
+ {
|
|
|
63
|
+ MakeFlag(bf.Position, blc);
|
|
|
64
|
+
|
|
|
65
|
+ Point3d p1 = new Point3d(bf.Position.X - 4 * blc / 2000, bf.Position.Y - 4 * blc / 2000, 0);
|
|
|
66
|
+ Point3d p2 = new Point3d(bf.Position.X + 4 * blc / 2000, bf.Position.Y + 4 * blc / 2000, 0);
|
|
|
67
|
+ TypedValue[] typedvalue = new TypedValue[2];
|
|
|
68
|
+
|
|
|
69
|
+ typedvalue.SetValue(new TypedValue((int)DxfCode.Start, "Text"), 0);
|
|
|
70
|
+ typedvalue.SetValue(new TypedValue((int)DxfCode.LayerName, elevationLayer), 1);
|
|
|
71
|
+
|
|
|
72
|
+ SelectionFilter filter = new SelectionFilter(typedvalue);
|
|
|
73
|
+ PromptSelectionResult psr = ed.SelectCrossingWindow(p1, p2, filter);
|
|
|
74
|
+ List<ObjectId> objs = new List<ObjectId>();
|
|
|
75
|
+ if (psr.Status == PromptStatus.OK)
|
|
|
76
|
+ {
|
|
|
77
|
+ SelectionSet set = psr.Value;
|
|
|
78
|
+ objs = set.GetObjectIds().ToList();
|
|
|
79
|
+ }
|
|
|
80
|
+ using (Transaction tr = db.TransactionManager.StartTransaction())
|
|
|
81
|
+ {
|
|
|
82
|
+ if (objs.Count > 0)
|
|
|
83
|
+ {
|
|
|
84
|
+ for (int ii = 0; ii < objs.Count; ii++)
|
|
|
85
|
+ {
|
|
|
86
|
+ Entity ent = (Entity)tr.GetObject(objs[ii], OpenMode.ForWrite);
|
|
|
87
|
+ if (ent is DBText)
|
|
|
88
|
+ {
|
|
|
89
|
+ DBText t = (DBText)ent;
|
|
|
90
|
+ double T_Value = Convert.ToDouble(t.TextString);
|
|
|
91
|
+
|
|
|
92
|
+ if (T_Value == bf.Position.Z)
|
|
|
93
|
+ {
|
|
|
94
|
+ t.Layer = "点线矛盾高程点图层";
|
|
|
95
|
+
|
|
|
96
|
+ }
|
|
|
97
|
+ }
|
|
|
98
|
+ }
|
|
|
99
|
+ }
|
|
|
100
|
+
|
|
|
101
|
+ BlockReference blcref = (BlockReference)tr.GetObject(bf.ObjectId, OpenMode.ForWrite);
|
|
|
102
|
+ blcref.Layer = "点线矛盾高程点图层";
|
|
|
103
|
+ tr.Commit();
|
|
|
104
|
+ }
|
|
|
105
|
+ }
|
|
|
106
|
+ }
|
|
|
107
|
+ }
|
|
|
108
|
+
|
|
|
109
|
+ //获取所有高程点
|
|
|
110
|
+ private List<BlockReference> GetPt(Editor ed,Database db)
|
|
|
111
|
+ {
|
|
|
112
|
+ List<BlockReference> result = new List<BlockReference>();
|
|
|
113
|
+
|
|
|
114
|
+ TypedValue[] typedvalue = new TypedValue[1];
|
|
|
115
|
+ typedvalue.SetValue(new TypedValue((int)DxfCode.LayerName, elevationLayer), 0);
|
|
|
116
|
+ SelectionFilter selectionfilter = new SelectionFilter(typedvalue);
|
|
|
117
|
+ PromptSelectionResult psr = ed.SelectAll(selectionfilter);
|
|
|
118
|
+ if (psr.Status == PromptStatus.OK)
|
|
|
119
|
+ {
|
|
|
120
|
+ SelectionSet selectionset = psr.Value;
|
|
|
121
|
+ ObjectId[] obj = new ObjectId[selectionset.Count];
|
|
|
122
|
+ obj = selectionset.GetObjectIds();
|
|
|
123
|
+ for (int i = 0; i < obj.Length; i++)
|
|
|
124
|
+ {
|
|
|
125
|
+ using (Transaction tr = db.TransactionManager.StartTransaction())
|
|
|
126
|
+ {
|
|
|
127
|
+ ObjectId objid = obj[i];
|
|
|
128
|
+
|
|
|
129
|
+ //找到实体,取高程点的位置
|
|
|
130
|
+ Entity entity = (Entity)tr.GetObject(objid, OpenMode.ForWrite);
|
|
|
131
|
+
|
|
|
132
|
+ if (entity is BlockReference)
|
|
|
133
|
+ {
|
|
|
134
|
+ BlockReference bf = (BlockReference)entity;
|
|
|
135
|
+ result.Add(bf);
|
|
|
136
|
+ }
|
|
|
137
|
+ tr.Commit();
|
|
|
138
|
+ }
|
|
|
139
|
+ }
|
|
|
140
|
+ }
|
|
|
141
|
+ return result;
|
|
|
142
|
+ }
|
|
|
143
|
+
|
|
|
144
|
+ //设置当前视图
|
|
|
145
|
+ private void SetWindow(Editor ed, Database db,double x,double y,double width,double height)
|
|
|
146
|
+ {
|
|
|
147
|
+ using (Transaction tr = db.TransactionManager.StartTransaction())
|
|
|
148
|
+ {
|
|
|
149
|
+ ViewTableRecord currview = ed.GetCurrentView();
|
|
|
150
|
+ currview.CenterPoint = new Point2d(x, y);
|
|
|
151
|
+ currview.ViewDirection = new Vector3d(0, 0, 1);
|
|
|
152
|
+ currview.Width = width;
|
|
|
153
|
+ currview.Height = height;
|
|
|
154
|
+ ed.SetCurrentView(currview);
|
|
|
155
|
+ tr.Commit();
|
|
|
156
|
+ }
|
|
|
157
|
+ }
|
|
|
158
|
+
|
|
|
159
|
+ //按垂直或水平方向搜索高程点周围等高线
|
|
|
160
|
+ private List<Polyline> SearchDGX(Point3d pt,double length,Editor ed, Database db, int direction)
|
|
|
161
|
+ {
|
|
|
162
|
+ List<Polyline> result = new List<Polyline>();
|
|
|
163
|
+ Point3d startpt;
|
|
|
164
|
+ Point3d endpt;
|
|
|
165
|
+ if (direction == 0)
|
|
|
166
|
+ {
|
|
|
167
|
+ startpt = new Point3d(pt.X - length / 2, pt.Y, pt.Z);
|
|
|
168
|
+ endpt = new Point3d(pt.X + length / 2, pt.Y, pt.Z);
|
|
|
169
|
+ }
|
|
|
170
|
+ else
|
|
|
171
|
+ {
|
|
|
172
|
+ startpt = new Point3d(pt.X, pt.Y - length / 2, pt.Z);
|
|
|
173
|
+ endpt = new Point3d(pt.X, pt.Y + length / 2, pt.Z);
|
|
|
174
|
+ }
|
|
|
175
|
+ Point3dCollection ptcoll = new Point3dCollection();
|
|
|
176
|
+ ptcoll.Add(startpt);
|
|
|
177
|
+ ptcoll.Add(endpt);
|
|
|
178
|
+
|
|
|
179
|
+ TypedValue[] typedvalue = new TypedValue[1];
|
|
|
180
|
+ typedvalue.SetValue(new TypedValue((int)DxfCode.LayerName, sqx + "," + jqx), 0);
|
|
|
181
|
+ SelectionFilter selectionfilter = new SelectionFilter(typedvalue);
|
|
|
182
|
+ PromptSelectionResult psr = ed.SelectFence(ptcoll, selectionfilter);
|
|
|
183
|
+ if (psr.Status == PromptStatus.OK)
|
|
|
184
|
+ {
|
|
|
185
|
+ SelectionSet selectionset = psr.Value;
|
|
|
186
|
+ ObjectId[] obj = new ObjectId[selectionset.Count];
|
|
|
187
|
+ obj = selectionset.GetObjectIds();
|
|
|
188
|
+ for (int i = 0; i < obj.Length; i++)
|
|
|
189
|
+ {
|
|
|
190
|
+ ObjectId objid = obj[i];
|
|
|
191
|
+ using (Transaction tr = db.TransactionManager.StartTransaction())
|
|
|
192
|
+ {
|
|
|
193
|
+ Entity ent = (Entity)tr.GetObject(objid, OpenMode.ForRead);
|
|
|
194
|
+ if(ent is Polyline)
|
|
|
195
|
+ {
|
|
|
196
|
+ //找到实体,取出高程点的x,y,z
|
|
|
197
|
+ Polyline pl = (Polyline)ent;
|
|
|
198
|
+ result.Add(pl);
|
|
|
199
|
+ tr.Commit();
|
|
|
200
|
+ }
|
|
|
201
|
+ }
|
|
|
202
|
+ }
|
|
|
203
|
+ }
|
|
|
204
|
+ return result;
|
|
|
205
|
+ }
|
|
|
206
|
+
|
|
|
207
|
+ //检查是否有点线矛盾
|
|
|
208
|
+ private bool IfContradition(List<Polyline> pllist,Point3d pt,double length)
|
|
|
209
|
+ {
|
|
|
210
|
+ var result = new List<List<IntersectionResult>>();
|
|
|
211
|
+
|
|
|
212
|
+ // 计算平移向量(以pt为基准,移动至原点)
|
|
|
213
|
+ Vector3d translation = -pt.GetAsVector();
|
|
|
214
|
+ Matrix3d translateMatrix = Matrix3d.Displacement(translation);
|
|
|
215
|
+ var pt_moved = pt.TransformBy(translateMatrix);
|
|
|
216
|
+
|
|
|
217
|
+ Line searchline1 = new Line(new Point3d(pt_moved.X - length / 2, pt_moved.Y, pt_moved.Z), new Point3d(pt_moved.X + length / 2, pt_moved.Y, pt_moved.Z));
|
|
|
218
|
+ Line searchline2 = new Line(new Point3d(pt_moved.X, pt_moved.Y - length / 2, pt_moved.Z), new Point3d(pt_moved.X, pt_moved.Y + length / 2, pt_moved.Z));
|
|
|
219
|
+
|
|
|
220
|
+
|
|
|
221
|
+ var horizontal = new List<IntersectionResult>();
|
|
|
222
|
+ var vertical = new List<IntersectionResult>();
|
|
|
223
|
+
|
|
|
224
|
+ foreach (var item in pllist)
|
|
|
225
|
+ {
|
|
|
226
|
+ //创建临时副本用于移动等高线,以便进行无误差的相交判断
|
|
|
227
|
+ Polyline temppl = (Polyline)item.Clone();
|
|
|
228
|
+
|
|
|
229
|
+ //应用平移变换
|
|
|
230
|
+ temppl.TransformBy(translateMatrix);
|
|
|
231
|
+
|
|
|
232
|
+ Point3dCollection horizontal_pt = new Point3dCollection();
|
|
|
233
|
+ Point3dCollection vertical_pt = new Point3dCollection();
|
|
|
234
|
+ var plane = new Plane(Point3d.Origin, Vector3d.ZAxis);
|
|
|
235
|
+ temppl.IntersectWith(searchline1, Intersect.OnBothOperands, plane, horizontal_pt, IntPtr.Zero, IntPtr.Zero);
|
|
|
236
|
+ temppl.IntersectWith(searchline2, Intersect.OnBothOperands, plane, vertical_pt, IntPtr.Zero, IntPtr.Zero);
|
|
|
237
|
+
|
|
|
238
|
+ Matrix3d inverseMatrix = Matrix3d.Displacement(-translation);
|
|
|
239
|
+ Point3dCollection horizontal_pt_transformed = new Point3dCollection();
|
|
|
240
|
+ Point3dCollection vertical_pt_transformed = new Point3dCollection();
|
|
|
241
|
+ if (horizontal_pt.Count!=0)
|
|
|
242
|
+ {
|
|
|
243
|
+ foreach (Point3d ptitem in horizontal_pt)
|
|
|
244
|
+ horizontal_pt_transformed.Add(ptitem.TransformBy(inverseMatrix));
|
|
|
245
|
+ horizontal.Add(new IntersectionResult { IntersectionPoint = horizontal_pt_transformed, Contour = item });
|
|
|
246
|
+ }
|
|
|
247
|
+ if (vertical_pt.Count != 0)
|
|
|
248
|
+ {
|
|
|
249
|
+ foreach (Point3d ptitem in vertical_pt)
|
|
|
250
|
+ vertical_pt_transformed.Add(ptitem.TransformBy(inverseMatrix));
|
|
|
251
|
+ vertical.Add(new IntersectionResult { IntersectionPoint = vertical_pt_transformed, Contour = item });
|
|
|
252
|
+ }
|
|
|
253
|
+ }
|
|
|
254
|
+ //根据高程点值判断高程点两边应有的等高线高程值
|
|
|
255
|
+ var ele1 = Math.Floor(pt.Z / dgj) * dgj;
|
|
|
256
|
+ var ele2 = ele1 + dgj;
|
|
|
257
|
+ if (ele1 == pt.Z)
|
|
|
258
|
+ return true;
|
|
|
259
|
+ Database db = GrxCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database;
|
|
|
260
|
+ //搜索是否有相应高程的等高线
|
|
|
261
|
+ bool hastarget_horizontal = horizontal.Any(item => Math.Round(item.Contour.Elevation - ele1, db.Luprec) == 0) &&
|
|
|
262
|
+ horizontal.Any(item => Math.Round(item.Contour.Elevation - ele2, db.Luprec) == 0);
|
|
|
263
|
+ bool hastarget_vertical = vertical.Any(item => Math.Round(item.Contour.Elevation - ele1, db.Luprec) == 0)&&
|
|
|
264
|
+ vertical.Any(item => Math.Round(item.Contour.Elevation - ele2, db.Luprec) == 0);
|
|
|
265
|
+
|
|
|
266
|
+ //如果有,则判断高程点是否在两线之间,
|
|
|
267
|
+ //没有的话再判断高程点是否是根据等高线变化趋势变化
|
|
|
268
|
+ if (hastarget_horizontal)
|
|
|
269
|
+ {
|
|
|
270
|
+ var pl1 = horizontal.FindAll(item => Math.Round(item.Contour.Elevation - ele1, db.Luprec) == 0).ToList();
|
|
|
271
|
+ var pl2 = horizontal.FindAll(item => Math.Round(item.Contour.Elevation - ele2, db.Luprec) == 0).ToList();
|
|
|
272
|
+ for (int i = 0; i < pl1.Count; i++)
|
|
|
273
|
+ {
|
|
|
274
|
+ Vector3d vec1;
|
|
|
275
|
+ foreach (Point3d item1 in pl1[i].IntersectionPoint)
|
|
|
276
|
+ {
|
|
|
277
|
+ vec1 = (pt - item1).GetNormal();
|
|
|
278
|
+ for (int ii = 0; ii < pl2.Count; ii++)
|
|
|
279
|
+ {
|
|
|
280
|
+ foreach (Point3d item2 in pl2[ii].IntersectionPoint)
|
|
|
281
|
+ {
|
|
|
282
|
+ var dot = (pt - item2).GetNormal().DotProduct(vec1);
|
|
|
283
|
+ if (dot <= 0)
|
|
|
284
|
+ return false;
|
|
|
285
|
+ }
|
|
|
286
|
+ }
|
|
|
287
|
+ }
|
|
|
288
|
+ }
|
|
|
289
|
+ }
|
|
|
290
|
+ if (hastarget_vertical)
|
|
|
291
|
+ {
|
|
|
292
|
+ var pl1 = vertical.FindAll(item => Math.Round(item.Contour.Elevation - ele1, db.Luprec) == 0).ToList();
|
|
|
293
|
+ var pl2 = vertical.FindAll(item => Math.Round(item.Contour.Elevation - ele2, db.Luprec) == 0).ToList();
|
|
|
294
|
+ for (int i = 0; i < pl1.Count; i++)
|
|
|
295
|
+ {
|
|
|
296
|
+ Vector3d vec1;
|
|
|
297
|
+ foreach (Point3d item1 in pl1[i].IntersectionPoint)
|
|
|
298
|
+ {
|
|
|
299
|
+ vec1 = (pt - item1).GetNormal();
|
|
|
300
|
+ for (int ii = 0; ii < pl2.Count; ii++)
|
|
|
301
|
+ {
|
|
|
302
|
+ foreach (Point3d item2 in pl2[ii].IntersectionPoint)
|
|
|
303
|
+ {
|
|
|
304
|
+ var dot = (pt - item2).GetNormal().DotProduct(vec1);
|
|
|
305
|
+ if (dot <= 0)
|
|
|
306
|
+ return false;
|
|
|
307
|
+ }
|
|
|
308
|
+ }
|
|
|
309
|
+ }
|
|
|
310
|
+ }
|
|
|
311
|
+ }
|
|
|
312
|
+ else
|
|
|
313
|
+ {
|
|
|
314
|
+ //只有对应方向上的多段线数量足以判断方向才进行下一步
|
|
|
315
|
+ if (horizontal.Count >= 2)
|
|
|
316
|
+ {
|
|
|
317
|
+ List<Point3d> pts = new List<Point3d>();
|
|
|
318
|
+ foreach (var item in horizontal)
|
|
|
319
|
+ {
|
|
|
320
|
+ foreach (Point3d p in item.IntersectionPoint)
|
|
|
321
|
+ {
|
|
|
322
|
+ pts.Add(p);
|
|
|
323
|
+ }
|
|
|
324
|
+ }
|
|
|
325
|
+ var pts_sorted = pts.OrderBy(p => p.DistanceTo(pt));
|
|
|
326
|
+ Point3d point = new Point3d();
|
|
|
327
|
+ Polyline pl = new Polyline();
|
|
|
328
|
+ foreach (var item in pts_sorted)
|
|
|
329
|
+ {
|
|
|
330
|
+ if (point == new Point3d())
|
|
|
331
|
+ {
|
|
|
332
|
+ point = item;
|
|
|
333
|
+ pl = horizontal.Find(p => p.IntersectionPoint.Contains(item)).Contour;
|
|
|
334
|
+ }
|
|
|
335
|
+ else
|
|
|
336
|
+ {
|
|
|
337
|
+ //如果下一个点所在多段线不是这个点所在的多段线且高程不同,判断高程点变化方向是否一致
|
|
|
338
|
+ if (horizontal.Find(p => p.IntersectionPoint.Contains(item)).Contour != pl &&
|
|
|
339
|
+ horizontal.Find(p => p.IntersectionPoint.Contains(item)).Contour.Elevation != pl.Elevation)
|
|
|
340
|
+ {
|
|
|
341
|
+ var direction = point.Z - item.Z;
|
|
|
342
|
+ if (pt.Z - point.Z < 0 && direction < 0 ||
|
|
|
343
|
+ pt.Z - point.Z > 0 && direction > 0)
|
|
|
344
|
+ return false;
|
|
|
345
|
+ }
|
|
|
346
|
+ else
|
|
|
347
|
+ point = item;
|
|
|
348
|
+ }
|
|
|
349
|
+ }
|
|
|
350
|
+ }
|
|
|
351
|
+ if (vertical.Count >= 2)
|
|
|
352
|
+ {
|
|
|
353
|
+ List<Point3d> pts = new List<Point3d>();
|
|
|
354
|
+ foreach (var item in vertical)
|
|
|
355
|
+ {
|
|
|
356
|
+ foreach (Point3d p in item.IntersectionPoint)
|
|
|
357
|
+ {
|
|
|
358
|
+ pts.Add(p);
|
|
|
359
|
+ }
|
|
|
360
|
+ }
|
|
|
361
|
+ var pts_sorted = pts.OrderBy(p => p.DistanceTo(pt));
|
|
|
362
|
+ Point3d point = new Point3d();
|
|
|
363
|
+ Polyline pl = new Polyline();
|
|
|
364
|
+ foreach (var item in pts_sorted)
|
|
|
365
|
+ {
|
|
|
366
|
+ if (point == new Point3d())
|
|
|
367
|
+ {
|
|
|
368
|
+ point = item;
|
|
|
369
|
+ pl = vertical.Find(p => p.IntersectionPoint.Contains(item)).Contour;
|
|
|
370
|
+ }
|
|
|
371
|
+ else
|
|
|
372
|
+ {
|
|
|
373
|
+ if (vertical.Find(p => p.IntersectionPoint.Contains(item)).Contour != pl)
|
|
|
374
|
+ {
|
|
|
375
|
+ var direction = point.Z - item.Z;
|
|
|
376
|
+ if (pt.Z - point.Z < 0 && direction < 0 ||
|
|
|
377
|
+ pt.Z - point.Z > 0 && direction > 0)
|
|
|
378
|
+ return false;
|
|
|
379
|
+ }
|
|
|
380
|
+ else
|
|
|
381
|
+ point = item;
|
|
|
382
|
+ }
|
|
|
383
|
+ }
|
|
|
384
|
+ }
|
|
|
385
|
+ }
|
|
|
386
|
+ return true;
|
|
|
387
|
+ }
|
|
|
388
|
+
|
|
|
389
|
+ //标记错误点
|
|
|
390
|
+ private void MakeFlag(Point3d pt,int blc)
|
|
|
391
|
+ {
|
|
|
392
|
+ double flagradius = 4.0 * blc / 1000;//根据比例尺画圆标记半径
|
|
|
393
|
+
|
|
|
394
|
+ LayerControl layerscontrol = new LayerControl();
|
|
|
395
|
+ string layname = "点线矛盾标记图层";
|
|
|
396
|
+ if (layerscontrol.haslayername(layname) == false)
|
|
|
397
|
+ {
|
|
|
398
|
+ colorgb col = new colorgb(255, 0, 0);
|
|
|
399
|
+ layerscontrol.creatlayer(layname, col);
|
|
|
400
|
+ }
|
|
|
401
|
+ layname = "点线矛盾高程点图层";
|
|
|
402
|
+ if (layerscontrol.haslayername(layname) == false)
|
|
|
403
|
+ {
|
|
|
404
|
+ colorgb col = new colorgb(255, 255, 0);
|
|
|
405
|
+ layerscontrol.creatlayer(layname, col);
|
|
|
406
|
+ layerscontrol.movelayertofront(layname);
|
|
|
407
|
+ }
|
|
|
408
|
+
|
|
|
409
|
+ Database db = HostApplicationServices.WorkingDatabase;
|
|
|
410
|
+ //DocumentLock doclock = GrxCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
|
|
|
411
|
+ using (Transaction traction = db.TransactionManager.StartTransaction())
|
|
|
412
|
+ {
|
|
|
413
|
+ BlockTable blocktable= traction.GetObject(db.BlockTableId, OpenMode.ForWrite) as BlockTable;
|
|
|
414
|
+ BlockTableRecord blocktablerecord = traction.GetObject(blocktable[BlockTableRecord.ModelSpace],
|
|
|
415
|
+ OpenMode.ForWrite) as BlockTableRecord;
|
|
|
416
|
+ Circle circ = new Circle();
|
|
|
417
|
+ circ.Layer = "点线矛盾标记图层";
|
|
|
418
|
+
|
|
|
419
|
+ circ.Center = pt;
|
|
|
420
|
+ circ.Radius = flagradius;
|
|
|
421
|
+ circ.Normal = new Vector3d(0, 0, 1);
|
|
|
422
|
+ circ.SetDatabaseDefaults();
|
|
|
423
|
+ blocktablerecord.AppendEntity(circ);
|
|
|
424
|
+ traction.AddNewlyCreatedDBObject(circ, true);
|
|
|
425
|
+ traction.Commit();
|
|
|
426
|
+
|
|
|
427
|
+ traction.Dispose();
|
|
|
428
|
+ }
|
|
|
429
|
+ //doclock.Dispose();
|
|
|
430
|
+ }
|
|
|
431
|
+ }
|
|
|
432
|
+}
|