|
|
@@ -22,6 +22,7 @@ namespace HCTools
|
|
22
|
22
|
InitializeComponent();
|
|
23
|
23
|
}
|
|
24
|
24
|
|
|
|
25
|
+ int nodirection = 0;
|
|
25
|
26
|
private void JQXLabel_grid_Load(object sender, EventArgs e)
|
|
26
|
27
|
{
|
|
27
|
28
|
//自动填充下拉框
|
|
|
@@ -89,7 +90,7 @@ namespace HCTools
|
|
89
|
90
|
return;
|
|
90
|
91
|
}
|
|
91
|
92
|
jqxLabelbyGrid();
|
|
92
|
|
- MessageBox.Show("标注完成。");
|
|
|
93
|
+ MessageBox.Show("标注完成。\n有"+nodirection.ToString()+ "处无法确定方向,移动到“无法确定方向”图层");
|
|
93
|
94
|
this.Close();
|
|
94
|
95
|
}
|
|
95
|
96
|
|
|
|
@@ -136,6 +137,10 @@ namespace HCTools
|
|
136
|
137
|
MessageBox.Show("未找到图框!");
|
|
137
|
138
|
return;
|
|
138
|
139
|
}
|
|
|
140
|
+ //创建标记字体
|
|
|
141
|
+ CreateSheetMap cs = new CreateSheetMap();
|
|
|
142
|
+ cs.createTextStyle();
|
|
|
143
|
+ ObjectId HZ = cs.gettextstyleID("HZ");
|
|
139
|
144
|
//遍历图框顶点列表,按顶点范围搜索等高线
|
|
140
|
145
|
for (int i = 0; i < tkpts.Count; i++)
|
|
141
|
146
|
{
|
|
|
@@ -163,40 +168,43 @@ namespace HCTools
|
|
163
|
168
|
SelectionSet ss = psr_pl.Value;
|
|
164
|
169
|
ObjectId[] plids = ss.GetObjectIds();
|
|
165
|
170
|
|
|
166
|
|
- List<Polyline> pllist = new List<Polyline>();
|
|
167
|
|
- for (int ii = 0; ii < plids.Length; ii++)
|
|
|
171
|
+ List<Polyline> pllist = new List<Polyline>(); using (Transaction tr = db.TransactionManager.StartTransaction())
|
|
168
|
172
|
{
|
|
169
|
|
- using (Transaction tr = db.TransactionManager.StartTransaction())
|
|
|
173
|
+ for (int ii = 0; ii < plids.Length; ii++)
|
|
170
|
174
|
{
|
|
|
175
|
+
|
|
171
|
176
|
Polyline pl = tr.GetObject(plids[ii], OpenMode.ForRead) as Polyline;
|
|
172
|
177
|
pllist.Add(pl);
|
|
173
|
|
- tr.Commit();
|
|
174
|
178
|
}
|
|
|
179
|
+ tr.Commit();
|
|
175
|
180
|
}
|
|
176
|
181
|
|
|
177
|
182
|
//绘制图框
|
|
178
|
183
|
Polyline tk1 = new Polyline();
|
|
179
|
184
|
double width = tkpts[i][1].X - tkpts[i][0].X;
|
|
180
|
185
|
double height = tkpts[i][1].Y - tkpts[i][0].Y;
|
|
181
|
|
- tk1.AddVertexAt(0, new Point2d(tkpts[i][0].X, tkpts[i][0].Y), 0, 0, 0);
|
|
|
186
|
+ tk1.AddVertexAt(0, new Point2d(tkpts[i][0].X, width), 0, 0, 0);
|
|
182
|
187
|
tk1.AddVertexAt(1, new Point2d(tkpts[i][0].X + width, tkpts[i][0].Y), 0, 0, 0);
|
|
183
|
188
|
tk1.AddVertexAt(2, new Point2d(tkpts[i][1].X, tkpts[i][1].Y), 0, 0, 0);
|
|
184
|
189
|
tk1.AddVertexAt(3, new Point2d(tkpts[i][0].X, tkpts[i][0].Y + height), 0, 0, 0);
|
|
185
|
190
|
tk1.Closed = true;
|
|
186
|
191
|
|
|
187
|
|
- var result = getPll(pllist,tk1);
|
|
188
|
|
- if (result.Count > 1)
|
|
189
|
|
- {
|
|
190
|
|
- Polyline merged = mergePl(result,tk1);
|
|
191
|
|
- makeMark(merged, db, tk1, blc);
|
|
192
|
|
- }
|
|
193
|
|
- else
|
|
194
|
|
- makeMark(result[0], db, tk1, blc);
|
|
|
192
|
+ Point3d centralpt = new Point3d(tkpts[i][0].X + width / 2, tkpts[i][0].Y + height / 2, 0);
|
|
|
193
|
+ var result = getPll(pllist,tk1, centralpt);
|
|
|
194
|
+ //if (result.Count > 1)
|
|
|
195
|
+ //{
|
|
|
196
|
+ //Polyline merged = mergePl(result,tk1);
|
|
|
197
|
+ //makeMark(merged, db, tk1, blc,centralpt);
|
|
|
198
|
+ makeMark(result, db, blc,centralpt,HZ);
|
|
|
199
|
+ //}
|
|
|
200
|
+ //else
|
|
|
201
|
+ //makeMark(result[0], db, tk1, blc, centralpt);
|
|
|
202
|
+ pllist.Clear();
|
|
195
|
203
|
}
|
|
196
|
204
|
}
|
|
197
|
205
|
}
|
|
198
|
206
|
|
|
199
|
|
- private List<Polyline> getPll(List<Polyline> pllist,Polyline tk)
|
|
|
207
|
+ private Polyline getPll(List<Polyline> pllist,Polyline tk,Point3d central)
|
|
200
|
208
|
{
|
|
201
|
209
|
var jqxlist = pllist.Where(pline => pline.Layer == comboBox_jqx.Text).ToList();
|
|
202
|
210
|
var plllist_sorted = pllist.OrderBy(pline => pline.Elevation).ToList();
|
|
|
@@ -208,149 +216,270 @@ namespace HCTools
|
|
208
|
216
|
var sortedEle = jqxlist_groupbyele.Keys.OrderBy(e => e).ToList();
|
|
209
|
217
|
|
|
210
|
218
|
//获取图框内的多段线
|
|
211
|
|
- var plinside = new List<Polyline>();
|
|
212
|
|
- foreach (var item in jqxlist_groupbyele)
|
|
213
|
|
- {
|
|
214
|
|
- foreach (var pl in item.Value)
|
|
215
|
|
- {
|
|
216
|
|
- var pls = GetPolylineInsideFrame(pl, tk);
|
|
217
|
|
- foreach (var l in pls)
|
|
218
|
|
- {
|
|
219
|
|
- plinside.Add(l);
|
|
220
|
|
- }
|
|
221
|
|
- }
|
|
222
|
|
- }
|
|
|
219
|
+ //var plinside = new List<Polyline>();
|
|
|
220
|
+ //foreach (var item in jqxlist_groupbyele)
|
|
|
221
|
+ //{
|
|
|
222
|
+ // foreach (var pl in item.Value)
|
|
|
223
|
+ // {
|
|
|
224
|
+ // var pls = GetPolylineInsideFrame(pl, tk);
|
|
|
225
|
+ // foreach (var l in pls)
|
|
|
226
|
+ // {
|
|
|
227
|
+ // plinside.Add(l);
|
|
|
228
|
+ // }
|
|
|
229
|
+ // }
|
|
|
230
|
+ //}
|
|
223
|
231
|
//选择其中最长的高程组作为用于标记的高程线
|
|
224
|
|
- var plinside_groupbyele = plinside.GroupBy(pline => pline.Elevation)
|
|
225
|
|
- .ToDictionary(group => group.Key, group => group.ToList());
|
|
226
|
|
- var result = plinside_groupbyele.OrderByDescending(g => g.Value.Sum(p => p.Length)).FirstOrDefault();
|
|
227
|
|
- return result.Value;
|
|
|
232
|
+ //var plinside_groupbyele = plinside.GroupBy(pline => pline.Elevation)
|
|
|
233
|
+ // .ToDictionary(group => group.Key, group => group.ToList());
|
|
|
234
|
+ //var result = plinside_groupbyele.OrderByDescending(g => g.Value.Sum(p => p.Length)).FirstOrDefault();
|
|
|
235
|
+ Polyline labelpll = jqxlist.OrderBy(c => c.GetClosestPointTo(new Point3d(central.X,central.Y,c.Elevation), new Vector3d(0, 0, 1), false)
|
|
|
236
|
+ .DistanceTo(new Point3d(central.X, central.Y, c.Elevation))).First();
|
|
|
237
|
+ jqxlist.Clear();
|
|
|
238
|
+ return labelpll;
|
|
228
|
239
|
}
|
|
229
|
240
|
else
|
|
230
|
241
|
return null;
|
|
231
|
242
|
}
|
|
232
|
243
|
|
|
233
|
|
- private Polyline mergePl(List<Polyline> plllist, Polyline tk)
|
|
|
244
|
+ #region
|
|
|
245
|
+ //private Polyline mergePl(List<Polyline> plllist, Polyline tk)
|
|
|
246
|
+ //{
|
|
|
247
|
+ // List<Polyline> interse = new List<Polyline>();
|
|
|
248
|
+ // List<Polyline> result = new List<Polyline>(plllist);
|
|
|
249
|
+ // for (int i = 0; i < plllist.Count - 1; i++)
|
|
|
250
|
+ // {
|
|
|
251
|
+ // Point3d start1 = plllist[i].GetPoint3dAt(0);
|
|
|
252
|
+ // Point3d end1 = plllist[i].GetPoint3dAt(plllist[i].NumberOfVertices - 1);
|
|
|
253
|
+ // for (int j = i + 1; j < plllist.Count; j++)
|
|
|
254
|
+ // {
|
|
|
255
|
+ // Point3d start2 = plllist[j].GetPoint3dAt(0);
|
|
|
256
|
+ // Point3d end2 = plllist[j].GetPoint3dAt(plllist[j].NumberOfVertices - 1);
|
|
|
257
|
+ // if (start1 == start2 || start1 == end2 || end1 == start2 || end1 == end2)
|
|
|
258
|
+ // {
|
|
|
259
|
+ // interse.Add(plllist[i]);
|
|
|
260
|
+ // interse.Add(plllist[j]);
|
|
|
261
|
+ // if (result.Contains(plllist[i])) result.Remove(plllist[i]);
|
|
|
262
|
+ // if (result.Contains(plllist[j])) result.Remove(plllist[j]);
|
|
|
263
|
+ // }
|
|
|
264
|
+ // }
|
|
|
265
|
+ // }
|
|
|
266
|
+ // if (interse.Count > 0)
|
|
|
267
|
+ // {
|
|
|
268
|
+ // // 转换为NTS线串
|
|
|
269
|
+ // var lineStrings = new List<Geometry>();
|
|
|
270
|
+ // foreach (var pl in interse)
|
|
|
271
|
+ // {
|
|
|
272
|
+ // var lineString1 = ConvertPolylineToNtsGeometry(pl);
|
|
|
273
|
+ // lineStrings.Add(lineString1);
|
|
|
274
|
+ // }
|
|
|
275
|
+ // // 使用线合并器
|
|
|
276
|
+ // var merger = new LineMerger();
|
|
|
277
|
+ // merger.Add(lineStrings);
|
|
|
278
|
+
|
|
|
279
|
+ // // 获取合并结果
|
|
|
280
|
+ // var mergedCollection = merger.GetMergedLineStrings();
|
|
|
281
|
+
|
|
|
282
|
+ // // 转换回AutoCAD多段线
|
|
|
283
|
+ // foreach (var geometry in mergedCollection)
|
|
|
284
|
+ // {
|
|
|
285
|
+ // if (geometry is LineString mergedLineString)
|
|
|
286
|
+ // {
|
|
|
287
|
+ // var mergedPolyline = ConvertNtsLineStringToPolyline(mergedLineString);
|
|
|
288
|
+ // if (mergedPolyline != null)
|
|
|
289
|
+ // {
|
|
|
290
|
+ // mergedPolyline.Elevation = plllist[0].Elevation;
|
|
|
291
|
+ // result.Add(mergedPolyline);
|
|
|
292
|
+ // }
|
|
|
293
|
+ // }
|
|
|
294
|
+ // }
|
|
|
295
|
+ // }
|
|
|
296
|
+ // var plinside = new List<Polyline>();
|
|
|
297
|
+ // foreach (var item in result)
|
|
|
298
|
+ // {
|
|
|
299
|
+ // var pls = GetPolylineInsideFrame(item, tk);
|
|
|
300
|
+ // foreach (var l in pls)
|
|
|
301
|
+ // {
|
|
|
302
|
+ // plinside.Add(l);
|
|
|
303
|
+ // }
|
|
|
304
|
+ // }
|
|
|
305
|
+ // return plinside.OrderByDescending(g => g.Length).First();
|
|
|
306
|
+ //}
|
|
|
307
|
+ #endregion
|
|
|
308
|
+
|
|
|
309
|
+ private void makeMark(Polyline pll,Database db, int blc,Point3d central, ObjectId HZ)
|
|
234
|
310
|
{
|
|
235
|
|
- List<Polyline> interse = new List<Polyline>();
|
|
236
|
|
- List<Polyline> result = new List<Polyline>(plllist);
|
|
237
|
|
- for (int i = 0; i < plllist.Count - 1; i++)
|
|
|
311
|
+ Editor ed = GrxCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
|
|
|
312
|
+ //var pllInside = GetPolylineInsideFrame(pll, tk);
|
|
|
313
|
+ Polyline labelpll = pll;
|
|
|
314
|
+ //Point3d label_pos = labelpll.GetPointAtDist(labelpll.Length / 2);
|
|
|
315
|
+
|
|
|
316
|
+ Point3d label_pos = labelpll.GetClosestPointTo(central, new Vector3d(0, 0, 1), false);
|
|
|
317
|
+ if (labelpll.StartPoint.X > labelpll.EndPoint.X)
|
|
|
318
|
+ labelpll.ReverseCurve();
|
|
|
319
|
+ //计算放置注记处的方向
|
|
|
320
|
+ Vector3d tangent = labelpll.GetFirstDerivative(labelpll.GetParameterAtPoint(label_pos));
|
|
|
321
|
+ double angle = tangent.GetAngleTo(Vector3d.XAxis);
|
|
|
322
|
+ //调整角度范围(0到2Π)
|
|
|
323
|
+ if (tangent.Y < 0)
|
|
|
324
|
+ angle = 2 * Math.PI - angle;
|
|
|
325
|
+ //法线向量
|
|
|
326
|
+ Vector3d normal = new Vector3d(-tangent.Y, tangent.X, 0);
|
|
|
327
|
+ //单位化
|
|
|
328
|
+ normal = normal.GetNormal();
|
|
|
329
|
+
|
|
|
330
|
+ List<Polyline> pllist = new List<Polyline>();
|
|
|
331
|
+ var angle1 = angle;
|
|
|
332
|
+ var angle2 = angle + Math.PI;
|
|
|
333
|
+ int flag = 0;
|
|
|
334
|
+ //以标注所在位置点为基点做基于该点的法线射线进行搜索
|
|
|
335
|
+ Point3d startPoint = label_pos;
|
|
|
336
|
+ Point3d endPoint = label_pos + normal * 200;
|
|
|
337
|
+ Point3dCollection ptcoll = new Point3dCollection() { startPoint, endPoint };
|
|
|
338
|
+
|
|
|
339
|
+ TypedValue[] typedvalue_pl = new TypedValue[2];
|
|
|
340
|
+ typedvalue_pl.SetValue(new TypedValue((int)DxfCode.LayerName, comboBox_jqx.Text+",8110"), 0);
|
|
|
341
|
+ typedvalue_pl.SetValue(new TypedValue((int)DxfCode.Start, "LWPOLYLINE"), 1);
|
|
|
342
|
+ SelectionFilter selectionfilter_pl = new SelectionFilter(typedvalue_pl);
|
|
|
343
|
+ PromptSelectionResult psr_pl = ed.SelectFence(ptcoll, selectionfilter_pl);
|
|
|
344
|
+ if (psr_pl.Status == PromptStatus.OK)
|
|
238
|
345
|
{
|
|
239
|
|
- Point3d start1 = plllist[i].GetPoint3dAt(0);
|
|
240
|
|
- Point3d end1 = plllist[i].GetPoint3dAt(plllist[i].NumberOfVertices - 1);
|
|
241
|
|
- for (int j = i + 1; j < plllist.Count; j++)
|
|
|
346
|
+ SelectionSet ss = psr_pl.Value;
|
|
|
347
|
+ ObjectId[] plids = ss.GetObjectIds();
|
|
|
348
|
+ using (Transaction tr = db.TransactionManager.StartTransaction())
|
|
242
|
349
|
{
|
|
243
|
|
- Point3d start2 = plllist[j].GetPoint3dAt(0);
|
|
244
|
|
- Point3d end2 = plllist[j].GetPoint3dAt(plllist[j].NumberOfVertices - 1);
|
|
245
|
|
- if (start1 == start2 || start1 == end2 || end1 == start2 || end1 == end2)
|
|
|
350
|
+ for (int ii = 0; ii < plids.Length; ii++)
|
|
246
|
351
|
{
|
|
247
|
|
- interse.Add(plllist[i]);
|
|
248
|
|
- interse.Add(plllist[j]);
|
|
249
|
|
- if (result.Contains(plllist[i])) result.Remove(plllist[i]);
|
|
250
|
|
- if (result.Contains(plllist[j])) result.Remove(plllist[j]);
|
|
|
352
|
+
|
|
|
353
|
+ Polyline dgx = tr.GetObject(plids[ii], OpenMode.ForRead) as Polyline;
|
|
|
354
|
+ if (dgx.Elevation != pll.Elevation)
|
|
|
355
|
+ pllist.Add(dgx);
|
|
251
|
356
|
}
|
|
|
357
|
+ tr.Commit();
|
|
252
|
358
|
}
|
|
253
|
359
|
}
|
|
254
|
|
- if (interse.Count > 0)
|
|
|
360
|
+ if (pllist.Count == 0 || psr_pl.Status != PromptStatus.OK)
|
|
255
|
361
|
{
|
|
256
|
|
- // 转换为NTS线串
|
|
257
|
|
- var lineStrings = new List<Geometry>();
|
|
258
|
|
- foreach (var pl in interse)
|
|
|
362
|
+ flag = 1;
|
|
|
363
|
+ endPoint = label_pos - normal * 200;
|
|
|
364
|
+ ptcoll = new Point3dCollection() { startPoint, endPoint };
|
|
|
365
|
+ PromptSelectionResult psr_pl1 = ed.SelectFence(ptcoll, selectionfilter_pl);
|
|
|
366
|
+ if (psr_pl1.Status == PromptStatus.OK)
|
|
259
|
367
|
{
|
|
260
|
|
- var lineString1 = ConvertPolylineToNtsGeometry(pl);
|
|
261
|
|
- lineStrings.Add(lineString1);
|
|
262
|
|
- }
|
|
263
|
|
- // 使用线合并器
|
|
264
|
|
- var merger = new LineMerger();
|
|
265
|
|
- merger.Add(lineStrings);
|
|
266
|
|
-
|
|
267
|
|
- // 获取合并结果
|
|
268
|
|
- var mergedCollection = merger.GetMergedLineStrings();
|
|
269
|
|
-
|
|
270
|
|
- // 转换回AutoCAD多段线
|
|
271
|
|
- foreach (var geometry in mergedCollection)
|
|
272
|
|
- {
|
|
273
|
|
- if (geometry is LineString mergedLineString)
|
|
|
368
|
+ SelectionSet ss = psr_pl1.Value;
|
|
|
369
|
+ ObjectId[] plids = ss.GetObjectIds();
|
|
|
370
|
+ using (Transaction tr = db.TransactionManager.StartTransaction())
|
|
274
|
371
|
{
|
|
275
|
|
- var mergedPolyline = ConvertNtsLineStringToPolyline(mergedLineString);
|
|
276
|
|
- if (mergedPolyline != null)
|
|
|
372
|
+ for (int ii = 0; ii < plids.Length; ii++)
|
|
277
|
373
|
{
|
|
278
|
|
- mergedPolyline.Elevation = plllist[0].Elevation;
|
|
279
|
|
- result.Add(mergedPolyline);
|
|
|
374
|
+
|
|
|
375
|
+ Polyline dgx = tr.GetObject(plids[ii], OpenMode.ForRead) as Polyline;
|
|
|
376
|
+ if (dgx.Elevation != pll.Elevation)
|
|
|
377
|
+ pllist.Add(dgx);
|
|
280
|
378
|
}
|
|
|
379
|
+ tr.Commit();
|
|
281
|
380
|
}
|
|
282
|
381
|
}
|
|
|
382
|
+ psr_pl1 = null;
|
|
283
|
383
|
}
|
|
284
|
|
- var plinside = new List<Polyline>();
|
|
285
|
|
- foreach (var item in result)
|
|
|
384
|
+ if (pllist.Count != 0)
|
|
286
|
385
|
{
|
|
287
|
|
- var pls = GetPolylineInsideFrame(item, tk);
|
|
288
|
|
- foreach (var l in pls)
|
|
289
|
|
- {
|
|
290
|
|
- plinside.Add(l);
|
|
291
|
|
- }
|
|
292
|
|
- }
|
|
293
|
|
- return plinside.OrderByDescending(g => g.Length).First();
|
|
294
|
|
- }
|
|
|
386
|
+ Polyline closest = null;
|
|
|
387
|
+ double minDistance = double.MaxValue;
|
|
295
|
388
|
|
|
296
|
|
- private void makeMark(Polyline pll,Database db, Polyline tk, int blc)
|
|
297
|
|
- {
|
|
298
|
|
- var pllInside = GetPolylineInsideFrame(pll, tk);
|
|
299
|
|
- Polyline labelpll = pllInside.OrderByDescending(c => c.Length).First();
|
|
300
|
|
- Point3d label_pos = labelpll.GetPointAtDist(labelpll.Length / 2);
|
|
301
|
|
- if (labelpll.StartPoint.X > labelpll.EndPoint.X)
|
|
302
|
|
- labelpll.ReverseCurve();
|
|
303
|
|
- //计算放置注记处的方向
|
|
304
|
|
- Vector3d tangent = labelpll.GetFirstDerivative(labelpll.GetParameterAtPoint(label_pos));
|
|
305
|
|
- double angle = tangent.GetAngleTo(Vector3d.XAxis);
|
|
306
|
|
- //调整角度范围(0到2Π)
|
|
307
|
|
- if (tangent.Y < 0)
|
|
308
|
|
- angle = 2 * Math.PI - angle;
|
|
|
389
|
+ foreach (Polyline dgx in pllist)
|
|
|
390
|
+ {
|
|
|
391
|
+ // 直接计算距离,不使用中间Point3d对象
|
|
|
392
|
+ Point3d closestPoint = dgx.GetClosestPointTo(label_pos, new Vector3d(0, 0, 1), false);
|
|
309
|
393
|
|
|
310
|
|
- // 定义不允许的角度范围:90°到270°(向下方向)
|
|
311
|
|
- double lowerBound = Math.PI / 2; // 90°
|
|
312
|
|
- double upperBound = 3 * Math.PI / 2; // 270°
|
|
|
394
|
+ // 避免创建新的Point3d对象
|
|
|
395
|
+ double distance = Math.Sqrt(
|
|
|
396
|
+ Math.Pow(closestPoint.X - label_pos.X, 2) +
|
|
|
397
|
+ Math.Pow(closestPoint.Y - label_pos.Y, 2) +
|
|
|
398
|
+ Math.Pow(dgx.Elevation - label_pos.Z, 2)
|
|
|
399
|
+ );
|
|
313
|
400
|
|
|
314
|
|
- // 如果角度在向下范围内,进行调整
|
|
315
|
|
- if (angle > lowerBound && angle < upperBound)
|
|
316
|
|
- {
|
|
317
|
|
- // 翻转180度,使文字朝上
|
|
318
|
|
- angle = angle + Math.PI;
|
|
|
401
|
+ if (distance < minDistance)
|
|
|
402
|
+ {
|
|
|
403
|
+ minDistance = distance;
|
|
|
404
|
+ closest = dgx;
|
|
|
405
|
+ }
|
|
|
406
|
+ }
|
|
|
407
|
+ if (closest.Elevation < pll.Elevation && flag == 0 || closest.Elevation > pll.Elevation && flag == 1)
|
|
|
408
|
+ angle = angle2;
|
|
|
409
|
+ closest.Dispose();
|
|
|
410
|
+ //1:2000字高4,以此为基础计算其他比例尺的字高
|
|
|
411
|
+ double labelheight = 4;
|
|
|
412
|
+ if (blc == 500)
|
|
|
413
|
+ labelheight = labelheight * ((double)500 / 2000);
|
|
|
414
|
+ if (blc == 1000)
|
|
|
415
|
+ labelheight = labelheight * ((double)1000 / 2000);
|
|
|
416
|
+ if (blc == 5000)
|
|
|
417
|
+ labelheight = labelheight * ((double)5000 / 2000);
|
|
|
418
|
+ if (blc == 10000)
|
|
|
419
|
+ labelheight = labelheight * ((double)10000 / 2000);
|
|
|
420
|
+
|
|
|
421
|
+ string ele = pll.Elevation.ToString();
|
|
|
422
|
+ using (Transaction tr = db.TransactionManager.StartTransaction())
|
|
|
423
|
+ {
|
|
|
424
|
+ BlockTable bt = tr.GetObject(db.BlockTableId, OpenMode.ForWrite) as BlockTable;
|
|
|
425
|
+ BlockTableRecord btr = tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
|
|
|
426
|
+ DBText ele_txt = new DBText();
|
|
|
427
|
+ ele_txt.Height = labelheight;
|
|
|
428
|
+ ele_txt.TextString = ele;
|
|
|
429
|
+ ele_txt.TextStyleId = HZ;
|
|
|
430
|
+ ele_txt.HorizontalMode = TextHorizontalMode.TextMid;
|
|
|
431
|
+ ele_txt.Position = label_pos;
|
|
|
432
|
+ ele_txt.AlignmentPoint = label_pos;
|
|
|
433
|
+ ele_txt.Rotation = angle;
|
|
|
434
|
+ ele_txt.Layer = comboBox_bz.Text;
|
|
|
435
|
+ btr.AppendEntity(ele_txt);
|
|
|
436
|
+ tr.AddNewlyCreatedDBObject(ele_txt, true);
|
|
|
437
|
+ tr.Commit();
|
|
|
438
|
+ }
|
|
319
|
439
|
}
|
|
320
|
|
-
|
|
321
|
|
- //创建标记字体
|
|
322
|
|
- CreateSheetMap cs = new CreateSheetMap();
|
|
323
|
|
- cs.createTextStyle();
|
|
324
|
|
- ObjectId HZ = cs.gettextstyleID("HZ");
|
|
325
|
|
- //1:2000字高4,以此为基础计算其他比例尺的字高
|
|
326
|
|
- double labelheight = 4;
|
|
327
|
|
- if (blc == 500)
|
|
328
|
|
- labelheight = labelheight * ((double)500 / 2000);
|
|
329
|
|
- if (blc == 1000)
|
|
330
|
|
- labelheight = labelheight * ((double)1000 / 2000);
|
|
331
|
|
- if (blc == 5000)
|
|
332
|
|
- labelheight = labelheight * ((double)5000 / 2000);
|
|
333
|
|
- if (blc == 10000)
|
|
334
|
|
- labelheight = labelheight * ((double)10000 / 2000);
|
|
335
|
|
-
|
|
336
|
|
- string ele = pll.Elevation.ToString();
|
|
337
|
|
- using (Transaction tr = db.TransactionManager.StartTransaction())
|
|
|
440
|
+ else
|
|
338
|
441
|
{
|
|
339
|
|
- BlockTable bt = tr.GetObject(db.BlockTableId, OpenMode.ForWrite) as BlockTable;
|
|
340
|
|
- BlockTableRecord btr = tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
|
|
341
|
|
- DBText ele_txt = new DBText();
|
|
342
|
|
- ele_txt.Height = labelheight;
|
|
343
|
|
- ele_txt.TextString = ele;
|
|
344
|
|
- ele_txt.TextStyleId = HZ;
|
|
345
|
|
- ele_txt.HorizontalMode = TextHorizontalMode.TextMid;
|
|
346
|
|
- ele_txt.Position = label_pos;
|
|
347
|
|
- ele_txt.AlignmentPoint = label_pos;
|
|
348
|
|
- ele_txt.Rotation = angle;
|
|
349
|
|
- ele_txt.Layer = comboBox_bz.Text;
|
|
350
|
|
- btr.AppendEntity(ele_txt);
|
|
351
|
|
- tr.AddNewlyCreatedDBObject(ele_txt, true);
|
|
352
|
|
- tr.Commit();
|
|
|
442
|
+ nodirection = nodirection + 1;
|
|
|
443
|
+ LayerControl layerscontrol = new LayerControl();
|
|
|
444
|
+ string layname = "无法判断方向";
|
|
|
445
|
+ if (layerscontrol.haslayername(layname) == false)
|
|
|
446
|
+ {
|
|
|
447
|
+ colorgb col = new colorgb(255, 0, 0);
|
|
|
448
|
+ layerscontrol.creatlayer(layname, col);
|
|
|
449
|
+ }
|
|
|
450
|
+ //1:2000字高4,以此为基础计算其他比例尺的字高
|
|
|
451
|
+ double labelheight = 4;
|
|
|
452
|
+ if (blc == 500)
|
|
|
453
|
+ labelheight = labelheight * ((double)500 / 2000);
|
|
|
454
|
+ if (blc == 1000)
|
|
|
455
|
+ labelheight = labelheight * ((double)1000 / 2000);
|
|
|
456
|
+ if (blc == 5000)
|
|
|
457
|
+ labelheight = labelheight * ((double)5000 / 2000);
|
|
|
458
|
+ if (blc == 10000)
|
|
|
459
|
+ labelheight = labelheight * ((double)10000 / 2000);
|
|
|
460
|
+
|
|
|
461
|
+ string ele = pll.Elevation.ToString();
|
|
|
462
|
+ using (Transaction tr = db.TransactionManager.StartTransaction())
|
|
|
463
|
+ {
|
|
|
464
|
+ BlockTable bt = tr.GetObject(db.BlockTableId, OpenMode.ForWrite) as BlockTable;
|
|
|
465
|
+ BlockTableRecord btr = tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
|
|
|
466
|
+ DBText ele_txt = new DBText();
|
|
|
467
|
+ ele_txt.Height = labelheight;
|
|
|
468
|
+ ele_txt.TextString = ele;
|
|
|
469
|
+ ele_txt.TextStyleId = HZ;
|
|
|
470
|
+ ele_txt.HorizontalMode = TextHorizontalMode.TextMid;
|
|
|
471
|
+ ele_txt.Position = label_pos;
|
|
|
472
|
+ ele_txt.AlignmentPoint = label_pos;
|
|
|
473
|
+ ele_txt.Rotation = angle;
|
|
|
474
|
+ ele_txt.Layer = "无法判断方向";
|
|
|
475
|
+ btr.AppendEntity(ele_txt);
|
|
|
476
|
+ tr.AddNewlyCreatedDBObject(ele_txt, true);
|
|
|
477
|
+ tr.Commit();
|
|
|
478
|
+ }
|
|
|
479
|
+
|
|
353
|
480
|
}
|
|
|
481
|
+ pllist.Clear();
|
|
|
482
|
+ psr_pl = null;
|
|
354
|
483
|
#region
|
|
355
|
484
|
//Polyline templine = pllist[0].Clone() as Polyline;
|
|
356
|
485
|
|
|
|
@@ -417,18 +546,20 @@ namespace HCTools
|
|
417
|
546
|
insidePolylines.Add(polyline);
|
|
418
|
547
|
}
|
|
419
|
548
|
}
|
|
420
|
|
- else if (intersection is GeometryCollection collection)
|
|
421
|
|
- {
|
|
422
|
|
- // 几何集合
|
|
423
|
|
- for (int i = 0; i < collection.NumGeometries; i++)
|
|
424
|
|
- {
|
|
425
|
|
- LineString segment = collection.GetGeometryN(i) as LineString;
|
|
426
|
|
- var polyline = ConvertNtsLineStringToPolyline(segment);
|
|
427
|
|
- polyline.Elevation = sourcePolyline.Elevation;
|
|
428
|
|
- insidePolylines.Add(polyline);
|
|
429
|
|
- }
|
|
430
|
|
- }
|
|
|
549
|
+ //else if (intersection is GeometryCollection collection)
|
|
|
550
|
+ //{
|
|
|
551
|
+ // // 几何集合
|
|
|
552
|
+ // for (int i = 0; i < collection.NumGeometries; i++)
|
|
|
553
|
+ // {
|
|
|
554
|
+ // LineString segment = collection.GetGeometryN(i) as LineString;
|
|
|
555
|
+ // var polyline = ConvertNtsLineStringToPolyline(segment);
|
|
|
556
|
+ // polyline.Elevation = sourcePolyline.Elevation;
|
|
|
557
|
+ // insidePolylines.Add(polyline);
|
|
|
558
|
+ // }
|
|
|
559
|
+ //}
|
|
431
|
560
|
}
|
|
|
561
|
+ ntsFrame = null;
|
|
|
562
|
+ ntsSource = null;
|
|
432
|
563
|
return insidePolylines;
|
|
433
|
564
|
}
|
|
434
|
565
|
|