浏览代码

新增autocad工具,修改hctool

qyx 1周前
父节点
当前提交
7c48f00f2c
共有 100 个文件被更改,包括 22993 次插入0 次删除
  1. 二进制
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/.vs/CADTools/v16/.suo
  2. 25
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools.sln
  3. 55
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/App.config
  4. 158
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/AttributeForm.Designer.cs
  5. 274
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/AttributeForm.cs
  6. 123
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/AttributeForm.resx
  7. 263
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/Attributeget.cs
  8. 401
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/CADTools.csproj
  9. 10
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/CADTools.csproj.user
  10. 3081
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/CMCgis_Basicfunction.cs
  11. 689
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/ChPLConstradiction1.cs
  12. 1100
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/ChPLContradiction.cs
  13. 169
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/Chaginfos.Designer.cs
  14. 350
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/Chaginfos.cs
  15. 120
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/Chaginfos.resx
  16. 95
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/CheckContourLine.cs
  17. 147
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/CheckL.Designer.cs
  18. 101
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/CheckL.cs
  19. 120
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/CheckL.resx
  20. 417
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/CheckPLOverlay.cs
  21. 154
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/Conn.Designer.cs
  22. 115
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/Conn.cs
  23. 120
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/Conn.resx
  24. 483
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/Connect.cs
  25. 175
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/ContourLineFix.cs
  26. 156
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/CutDgx.Designer.cs
  27. 96
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/CutDgx.cs
  28. 120
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/CutDgx.resx
  29. 135
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/CutDgxByTK.Designer.cs
  30. 272
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/CutDgxByTK.cs
  31. 120
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/CutDgxByTK.resx
  32. 131
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/DGXGeneral.Designer.cs
  33. 76
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/DGXGeneral.cs
  34. 120
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/DGXGeneral.resx
  35. 193
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/DGXGeneralization.cs
  36. 150
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/DeleteElept.Designer.cs
  37. 93
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/DeleteElept.cs
  38. 120
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/DeleteElept.resx
  39. 160
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/DeletePts.cs
  40. 162
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/DgxAnnck.cs
  41. 170
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/DgxAnno.Designer.cs
  42. 101
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/DgxAnno.cs
  43. 120
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/DgxAnno.resx
  44. 512
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/DgxCrossrvrd.cs
  45. 639
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/Dgxinters.cs
  46. 617
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/Dgxthrorvrd.cs
  47. 198
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/Dgxthrorvrd_Form.Designer.cs
  48. 108
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/Dgxthrorvrd_Form.cs
  49. 120
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/Dgxthrorvrd_Form.resx
  50. 295
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/ElePtCheck.cs
  51. 124
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/EleRd.Designer.cs
  52. 85
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/EleRd.cs
  53. 120
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/EleRd.resx
  54. 71
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/EleRound.cs
  55. 161
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/EleptDenck.cs
  56. 170
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/EleptDensity.Designer.cs
  57. 100
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/EleptDensity.cs
  58. 120
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/EleptDensity.resx
  59. 639
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/FeatureOverlap.cs
  60. 3
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/FodyWeavers.xml
  61. 111
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/FodyWeavers.xsd
  62. 136
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/GCDdelete_Form.Designer.cs
  63. 177
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/GCDdelete_Form.cs
  64. 120
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/GCDdelete_Form.resx
  65. 126
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/Hierak.Designer.cs
  66. 87
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/Hierak.cs
  67. 120
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/Hierak.resx
  68. 91
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/Hierarchy.cs
  69. 229
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/InsertDOM.cs
  70. 159
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/InsertDOMs_to_one.Designer.cs
  71. 453
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/InsertDOMs_to_one.cs
  72. 120
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/InsertDOMs_to_one.resx
  73. 132
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/InstDOM.Designer.cs
  74. 45
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/InstDOM.cs
  75. 120
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/InstDOM.resx
  76. 679
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/Inters.cs
  77. 222
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/JQXLabel_grid.Designer.cs
  78. 993
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/JQXLabel_grid.cs
  79. 120
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/JQXLabel_grid.resx
  80. 248
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/LayerChange.cs
  81. 248
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/Layerchange_Form.Designer.cs
  82. 175
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/Layerchange_Form.cs
  83. 120
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/Layerchange_Form.resx
  84. 684
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/MainClass.cs
  85. 168
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/Menus.cs
  86. 167
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/MergeDwg.Designer.cs
  87. 156
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/MergeDwg.cs
  88. 120
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/MergeDwg.resx
  89. 109
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/ModifyTFH.Designer.cs
  90. 146
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/ModifyTFH.cs
  91. 120
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/ModifyTFH.resx
  92. 186
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/PLError_Overlay.Designer.cs
  93. 177
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/PLError_Overlay.cs
  94. 120
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/PLError_Overlay.resx
  95. 114
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/PicPts.Designer.cs
  96. 43
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/PicPts.cs
  97. 120
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/PicPts.resx
  98. 174
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/PickupPoint.cs
  99. 36
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/Properties/AssemblyInfo.cs
  100. 0
    0
      加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/Properties/Resources.Designer.cs

二进制
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/.vs/CADTools/v16/.suo 查看文件


+ 25
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools.sln 查看文件

@@ -0,0 +1,25 @@
1
+
2
+Microsoft Visual Studio Solution File, Format Version 12.00
3
+# Visual Studio Version 16
4
+VisualStudioVersion = 16.0.33130.400
5
+MinimumVisualStudioVersion = 10.0.40219.1
6
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CADTools", "CADTools\CADTools.csproj", "{3EA75AE9-D4B2-415A-8646-756159376FFF}"
7
+EndProject
8
+Global
9
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
10
+		Debug|Any CPU = Debug|Any CPU
11
+		Release|Any CPU = Release|Any CPU
12
+	EndGlobalSection
13
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
14
+		{3EA75AE9-D4B2-415A-8646-756159376FFF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15
+		{3EA75AE9-D4B2-415A-8646-756159376FFF}.Debug|Any CPU.Build.0 = Debug|Any CPU
16
+		{3EA75AE9-D4B2-415A-8646-756159376FFF}.Release|Any CPU.ActiveCfg = Release|Any CPU
17
+		{3EA75AE9-D4B2-415A-8646-756159376FFF}.Release|Any CPU.Build.0 = Release|Any CPU
18
+	EndGlobalSection
19
+	GlobalSection(SolutionProperties) = preSolution
20
+		HideSolutionNode = FALSE
21
+	EndGlobalSection
22
+	GlobalSection(ExtensibilityGlobals) = postSolution
23
+		SolutionGuid = {B3E5967B-E40D-428E-B2D1-5299A48F01CD}
24
+	EndGlobalSection
25
+EndGlobal

+ 55
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/App.config 查看文件

@@ -0,0 +1,55 @@
1
+<?xml version="1.0" encoding="utf-8" ?>
2
+<configuration>
3
+    <configSections>
4
+        <sectionGroup name="userSettings" type="System.Configuration.UserSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" >
5
+            <section name="CADTools.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" allowExeDefinition="MachineToLocalUser" requirePermission="false" />
6
+        </sectionGroup>
7
+    </configSections>
8
+    <startup> 
9
+        <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
10
+    </startup>
11
+    <userSettings>
12
+        <CADTools.Properties.Settings>
13
+            <setting name="TFName" serializeAs="String">
14
+                <value />
15
+            </setting>
16
+            <setting name="Note2" serializeAs="String">
17
+                <value>2000国家大地坐标系,1985国家高程基准,等高距为1m。
18
+GB/T20257.1-2007 国家基本比例尺地图图式 第一部分
19
+1:500 1:1000 1:2000 地形图图式
20
+xxxx年xx月测制
21
+</value>
22
+            </setting>
23
+            <setting name="CTY" serializeAs="String">
24
+                <value>测图员 </value>
25
+            </setting>
26
+            <setting name="JCY" serializeAs="String">
27
+                <value>检查员 </value>
28
+            </setting>
29
+            <setting name="TDY" serializeAs="String">
30
+                <value>土调员 </value>
31
+            </setting>
32
+            <setting name="SDY" serializeAs="String">
33
+                <value>数调员 </value>
34
+            </setting>
35
+            <setting name="FCY" serializeAs="String">
36
+                <value>复查员 </value>
37
+            </setting>
38
+            <setting name="DH" serializeAs="String">
39
+                <value>0</value>
40
+            </setting>
41
+            <setting name="svpath" serializeAs="String">
42
+                <value />
43
+            </setting>
44
+            <setting name="secret" serializeAs="String">
45
+                <value />
46
+            </setting>
47
+            <setting name="Company" serializeAs="String">
48
+                <value>四川中水成勘院测绘工程有限责任公司</value>
49
+            </setting>
50
+            <setting name="dgj" serializeAs="String">
51
+                <value>1</value>
52
+            </setting>
53
+        </CADTools.Properties.Settings>
54
+    </userSettings>
55
+</configuration>

+ 158
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/AttributeForm.Designer.cs 查看文件

@@ -0,0 +1,158 @@
1
+
2
+namespace CADTools
3
+{
4
+    partial class AttributeForm
5
+    {
6
+        /// <summary>
7
+        /// Required designer variable.
8
+        /// </summary>
9
+        private System.ComponentModel.IContainer components = null;
10
+
11
+        /// <summary>
12
+        /// Clean up any resources being used.
13
+        /// </summary>
14
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
15
+        protected override void Dispose(bool disposing)
16
+        {
17
+            if (disposing && (components != null))
18
+            {
19
+                components.Dispose();
20
+            }
21
+            base.Dispose(disposing);
22
+        }
23
+
24
+        #region Windows Form Designer generated code
25
+
26
+        /// <summary>
27
+        /// Required method for Designer support - do not modify
28
+        /// the contents of this method with the code editor.
29
+        /// </summary>
30
+        private void InitializeComponent()
31
+        {
32
+            this.components = new System.ComponentModel.Container();
33
+            this.dataGridView_Info = new System.Windows.Forms.DataGridView();
34
+            this.contextMenuStrip1 = new System.Windows.Forms.ContextMenuStrip(this.components);
35
+            this.缩放至ToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
36
+            this.splitContainer1 = new System.Windows.Forms.SplitContainer();
37
+            this.button_cancelshow = new System.Windows.Forms.Button();
38
+            this.button_show = new System.Windows.Forms.Button();
39
+            this.button1 = new System.Windows.Forms.Button();
40
+            ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Info)).BeginInit();
41
+            this.contextMenuStrip1.SuspendLayout();
42
+            ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).BeginInit();
43
+            this.splitContainer1.Panel1.SuspendLayout();
44
+            this.splitContainer1.Panel2.SuspendLayout();
45
+            this.splitContainer1.SuspendLayout();
46
+            this.SuspendLayout();
47
+            // 
48
+            // dataGridView_Info
49
+            // 
50
+            this.dataGridView_Info.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
51
+            this.dataGridView_Info.ContextMenuStrip = this.contextMenuStrip1;
52
+            this.dataGridView_Info.Dock = System.Windows.Forms.DockStyle.Fill;
53
+            this.dataGridView_Info.Location = new System.Drawing.Point(0, 0);
54
+            this.dataGridView_Info.Name = "dataGridView_Info";
55
+            this.dataGridView_Info.RowHeadersWidth = 51;
56
+            this.dataGridView_Info.RowTemplate.Height = 27;
57
+            this.dataGridView_Info.Size = new System.Drawing.Size(1010, 451);
58
+            this.dataGridView_Info.TabIndex = 0;
59
+            this.dataGridView_Info.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView_Info_CellClick);
60
+            this.dataGridView_Info.RowHeaderMouseClick += new System.Windows.Forms.DataGridViewCellMouseEventHandler(this.dataGridView_Info_RowHeaderMouseClick);
61
+            this.dataGridView_Info.SortCompare += new System.Windows.Forms.DataGridViewSortCompareEventHandler(this.dataGridView_Info_SortCompare);
62
+            // 
63
+            // contextMenuStrip1
64
+            // 
65
+            this.contextMenuStrip1.ImageScalingSize = new System.Drawing.Size(20, 20);
66
+            this.contextMenuStrip1.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
67
+            this.缩放至ToolStripMenuItem});
68
+            this.contextMenuStrip1.Name = "contextMenuStrip1";
69
+            this.contextMenuStrip1.Size = new System.Drawing.Size(124, 28);
70
+            // 
71
+            // 缩放至ToolStripMenuItem
72
+            // 
73
+            this.缩放至ToolStripMenuItem.Name = "缩放至ToolStripMenuItem";
74
+            this.缩放至ToolStripMenuItem.Size = new System.Drawing.Size(123, 24);
75
+            this.缩放至ToolStripMenuItem.Text = "缩放至";
76
+            this.缩放至ToolStripMenuItem.Click += new System.EventHandler(this.缩放至ToolStripMenuItem_Click);
77
+            // 
78
+            // splitContainer1
79
+            // 
80
+            this.splitContainer1.Dock = System.Windows.Forms.DockStyle.Fill;
81
+            this.splitContainer1.Location = new System.Drawing.Point(0, 0);
82
+            this.splitContainer1.Name = "splitContainer1";
83
+            this.splitContainer1.Orientation = System.Windows.Forms.Orientation.Horizontal;
84
+            // 
85
+            // splitContainer1.Panel1
86
+            // 
87
+            this.splitContainer1.Panel1.Controls.Add(this.dataGridView_Info);
88
+            // 
89
+            // splitContainer1.Panel2
90
+            // 
91
+            this.splitContainer1.Panel2.Controls.Add(this.button_cancelshow);
92
+            this.splitContainer1.Panel2.Controls.Add(this.button_show);
93
+            this.splitContainer1.Panel2.Controls.Add(this.button1);
94
+            this.splitContainer1.Size = new System.Drawing.Size(1010, 499);
95
+            this.splitContainer1.SplitterDistance = 451;
96
+            this.splitContainer1.TabIndex = 1;
97
+            // 
98
+            // button_cancelshow
99
+            // 
100
+            this.button_cancelshow.Location = new System.Drawing.Point(788, 5);
101
+            this.button_cancelshow.Name = "button_cancelshow";
102
+            this.button_cancelshow.Size = new System.Drawing.Size(107, 33);
103
+            this.button_cancelshow.TabIndex = 2;
104
+            this.button_cancelshow.Text = "取消显示选中";
105
+            this.button_cancelshow.UseVisualStyleBackColor = true;
106
+            this.button_cancelshow.Click += new System.EventHandler(this.button_cancelshow_Click);
107
+            // 
108
+            // button_show
109
+            // 
110
+            this.button_show.Location = new System.Drawing.Point(685, 5);
111
+            this.button_show.Name = "button_show";
112
+            this.button_show.Size = new System.Drawing.Size(80, 33);
113
+            this.button_show.TabIndex = 1;
114
+            this.button_show.Text = "显示选中";
115
+            this.button_show.UseVisualStyleBackColor = true;
116
+            this.button_show.Click += new System.EventHandler(this.button_show_Click);
117
+            // 
118
+            // button1
119
+            // 
120
+            this.button1.Location = new System.Drawing.Point(924, 5);
121
+            this.button1.Name = "button1";
122
+            this.button1.Size = new System.Drawing.Size(75, 33);
123
+            this.button1.TabIndex = 0;
124
+            this.button1.Text = "导 出";
125
+            this.button1.UseVisualStyleBackColor = true;
126
+            this.button1.Click += new System.EventHandler(this.button1_Click);
127
+            // 
128
+            // AttributeForm
129
+            // 
130
+            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
131
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
132
+            this.ClientSize = new System.Drawing.Size(1010, 499);
133
+            this.Controls.Add(this.splitContainer1);
134
+            this.Name = "AttributeForm";
135
+            this.Text = "属性表";
136
+            this.FormClosed += new System.Windows.Forms.FormClosedEventHandler(this.AttributeForm_FormClosed);
137
+            this.Load += new System.EventHandler(this.AttributeForm_Load);
138
+            ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Info)).EndInit();
139
+            this.contextMenuStrip1.ResumeLayout(false);
140
+            this.splitContainer1.Panel1.ResumeLayout(false);
141
+            this.splitContainer1.Panel2.ResumeLayout(false);
142
+            ((System.ComponentModel.ISupportInitialize)(this.splitContainer1)).EndInit();
143
+            this.splitContainer1.ResumeLayout(false);
144
+            this.ResumeLayout(false);
145
+
146
+        }
147
+
148
+        #endregion
149
+
150
+        private System.Windows.Forms.DataGridView dataGridView_Info;
151
+        private System.Windows.Forms.ContextMenuStrip contextMenuStrip1;
152
+        private System.Windows.Forms.ToolStripMenuItem 缩放至ToolStripMenuItem;
153
+        private System.Windows.Forms.SplitContainer splitContainer1;
154
+        private System.Windows.Forms.Button button1;
155
+        private System.Windows.Forms.Button button_cancelshow;
156
+        private System.Windows.Forms.Button button_show;
157
+    }
158
+}

+ 274
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/AttributeForm.cs 查看文件

@@ -0,0 +1,274 @@
1
+using Autodesk.AutoCAD.ApplicationServices;
2
+using Autodesk.AutoCAD.DatabaseServices;
3
+using Autodesk.AutoCAD.EditorInput;
4
+using Autodesk.AutoCAD.Geometry;
5
+using System;
6
+using System.Collections.Generic;
7
+using System.ComponentModel;
8
+using System.Data;
9
+using System.Drawing;
10
+using System.IO;
11
+using System.Linq;
12
+using System.Text;
13
+using System.Threading.Tasks;
14
+using System.Windows.Forms;
15
+
16
+namespace CADTools
17
+{
18
+    public partial class AttributeForm : Form
19
+    {
20
+        private List<List<string>> info_all = new List<List<string>>();//obj信息
21
+        private List<ObjectId> objid_all = new List<ObjectId>();
22
+        public AttributeForm()
23
+        {
24
+            InitializeComponent();
25
+        }
26
+
27
+        public void GetInfo(List<List<string>> info_all, List<ObjectId> objid_all)
28
+        {
29
+            this.info_all = info_all;
30
+            this.objid_all = objid_all;
31
+
32
+        }
33
+
34
+        private void AttributeForm_Load(object sender, EventArgs e)
35
+        {
36
+            this.dataGridView_Info.ColumnCount = 9;
37
+
38
+            this.dataGridView_Info.Columns[0].HeaderText = "ID";
39
+            this.dataGridView_Info.Columns[1].HeaderText = "名称";
40
+            this.dataGridView_Info.Columns[2].HeaderText = "图层";
41
+            this.dataGridView_Info.Columns[3].HeaderText = "类型";
42
+            this.dataGridView_Info.Columns[4].HeaderText = "X";
43
+            this.dataGridView_Info.Columns[5].HeaderText = "Y";
44
+            this.dataGridView_Info.Columns[6].HeaderText = "Z";
45
+            this.dataGridView_Info.Columns[7].HeaderText = "长度(m)";
46
+            this.dataGridView_Info.Columns[8].HeaderText = "面积(m²)";
47
+
48
+            this.dataGridView_Info.AllowUserToAddRows = false;
49
+            this.dataGridView_Info.AllowUserToResizeRows = false;
50
+            this.dataGridView_Info.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.Fill;
51
+            this.dataGridView_Info.ColumnHeadersDefaultCellStyle.Alignment = DataGridViewContentAlignment.MiddleCenter;
52
+            //this.dataGridView_Info.RowHeadersVisible = false;
53
+            this.dataGridView_Info.ReadOnly = true;
54
+
55
+            for (int i = 0; i < info_all.Count; i++)
56
+            {
57
+                dataGridView_Info.Rows.Add();
58
+            }
59
+            for (int i = 0; i < this.dataGridView_Info.Rows.Count; i++)
60
+            {
61
+                this.dataGridView_Info[0, i].Value = info_all[i][0];
62
+                this.dataGridView_Info[1, i].Value = info_all[i][1];
63
+                this.dataGridView_Info[2, i].Value = info_all[i][2];
64
+                this.dataGridView_Info[3, i].Value = info_all[i][3];
65
+                this.dataGridView_Info[4, i].Value = info_all[i][4];
66
+                this.dataGridView_Info[5, i].Value = info_all[i][5];
67
+                this.dataGridView_Info[6, i].Value = info_all[i][6];
68
+                this.dataGridView_Info[7, i].Value = info_all[i][7];
69
+                this.dataGridView_Info[8, i].Value = info_all[i][8];
70
+            }
71
+        }
72
+
73
+        private void dataGridView_Info_SortCompare(object sender, DataGridViewSortCompareEventArgs e)
74
+        {
75
+            int column = e.Column.Index;
76
+            int row1 = e.RowIndex1;
77
+            int row2 = e.RowIndex2;
78
+            if (column == 0|| column == 4 || column == 5 || column == 6)
79
+            {
80
+                double value1 = Convert.ToDouble(e.CellValue1.ToString().Replace("_", ""));
81
+                double value2 = Convert.ToDouble(e.CellValue2.ToString().Replace("_", ""));
82
+                if (value1 > value2)
83
+                    e.SortResult = 1;
84
+                else if (value2 == value1)
85
+                    e.SortResult = 0;
86
+                else e.SortResult = -1;
87
+                e.Handled = true;
88
+            }
89
+        }
90
+
91
+        private void 缩放至ToolStripMenuItem_Click(object sender, EventArgs e)
92
+        {
93
+            DataGridViewRow row = this.dataGridView_Info.CurrentRow;
94
+            ObjectId id = objid_all[Convert.ToInt32(row.Cells[0].Value) - 1];
95
+            Entity current_entity = BasicFunction.GetDBObject(id);
96
+            current_entity.Highlight();//高亮显示实体 
97
+
98
+            //缩放至实体
99
+            ZoomToExtent(current_entity.GeometricExtents);
100
+        }
101
+
102
+        /// <summary>
103
+        /// 缩放至指定范围
104
+        /// </summary>
105
+        /// <param name="extent"></param>
106
+        public static void ZoomToExtent(Extents3d extent)
107
+        {
108
+            try
109
+            {
110
+                Point3d pMin = extent.MinPoint;
111
+                Point3d pMax = extent.MaxPoint;
112
+                //获取当前文档及数据库
113
+                Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
114
+                Database acCurDb = acDoc.Database;
115
+
116
+                // 启动事务
117
+                using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
118
+                {
119
+                    using (ViewTableRecord acView = acDoc.Editor.GetCurrentView())
120
+                    {
121
+                        //设置视图的高
122
+                        acView.Height = Math.Abs(pMin.Y - pMax.Y);
123
+                        //设置视图的宽
124
+                        acView.Width = Math.Abs(pMin.X - pMax.X);
125
+                        // 设置视图中心
126
+                        acView.CenterPoint = new Point2d((pMin.X + pMax.X) / 2, (pMin.Y + pMax.Y) / 2);
127
+                        // 更新当前视图
128
+                        acDoc.Editor.SetCurrentView(acView);
129
+                    }
130
+                    // 提交更改
131
+                    acTrans.Commit();
132
+                }
133
+            }
134
+            catch (Exception)
135
+            {
136
+
137
+                throw;
138
+            }
139
+        }
140
+
141
+        private void button1_Click(object sender, EventArgs e)
142
+        {
143
+            SaveFileDialog saveFileDialog = new SaveFileDialog();
144
+            saveFileDialog.Filter = "Text Files|*.txt";
145
+            saveFileDialog.Title = "保存txt文件";
146
+            saveFileDialog.FileName = "导出数据.txt";
147
+
148
+            if (saveFileDialog.ShowDialog() == DialogResult.OK)
149
+            {
150
+                // 使用 StreamWriter 写入文件
151
+                using (StreamWriter writer = new StreamWriter(saveFileDialog.FileName, false, Encoding.UTF8))
152
+                {
153
+                    // 写入列标题
154
+                    for (int i = 0; i < dataGridView_Info.Columns.Count; i++)
155
+                    {
156
+                        writer.Write(dataGridView_Info.Columns[i].HeaderText);
157
+                        if (i < dataGridView_Info.Columns.Count - 1)
158
+                        {
159
+                            writer.Write("\t");
160
+                        }
161
+                    }
162
+                    writer.WriteLine();
163
+
164
+                    // 写入数据
165
+                    //判断是否有被选中数据,有的话导出选中的
166
+                    int flag = 0;
167
+                    foreach (DataGridViewRow row in dataGridView_Info.Rows)
168
+                    {
169
+                        if (row.Selected == true)
170
+                            flag = 1;
171
+                    }
172
+                    if (flag == 0)
173
+                    {
174
+                        for (int i = 0; i < dataGridView_Info.Rows.Count; i++)
175
+                        {
176
+                            for (int j = 0; j < dataGridView_Info.Columns.Count; j++)
177
+                            {
178
+                                writer.Write(dataGridView_Info.Rows[i].Cells[j].Value.ToString());
179
+                                if (j < dataGridView_Info.Columns.Count - 1)
180
+                                {
181
+                                    writer.Write("\t");
182
+                                }
183
+                            }
184
+                            writer.WriteLine();
185
+                        }
186
+                    }
187
+                    else if (flag == 1)
188
+                    {
189
+                        for (int i = 0; i < dataGridView_Info.Rows.Count; i++)
190
+                        {
191
+                            if (dataGridView_Info.Rows[i].Selected == true)
192
+                            {
193
+                                for (int j = 0; j < dataGridView_Info.Columns.Count; j++)
194
+                                {
195
+                                    writer.Write(dataGridView_Info.Rows[i].Cells[j].Value.ToString());
196
+                                    if (j < dataGridView_Info.Columns.Count - 1)
197
+                                    {
198
+                                        writer.Write("\t");
199
+                                    }
200
+                                }
201
+                                writer.WriteLine();
202
+                            }
203
+                        }
204
+                    }
205
+                }
206
+
207
+                MessageBox.Show("数据导出成功!", "成功", MessageBoxButtons.OK, MessageBoxIcon.Information);
208
+            }
209
+        }
210
+
211
+        private void button_show_Click(object sender, EventArgs e)
212
+        {
213
+            Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
214
+            Editor ed = doc.Editor;
215
+            PromptSelectionResult selectionResult = ed.SelectImplied();
216
+            if (selectionResult.Status == PromptStatus.OK)
217
+            {
218
+                SelectionSet selectionSet = selectionResult.Value;
219
+                using (Transaction trans = doc.TransactionManager.StartTransaction())
220
+                {
221
+                    foreach (SelectedObject selectedObject in selectionSet)
222
+                    {
223
+                        ObjectId objectId = selectedObject.ObjectId;
224
+                        this.dataGridView_Info.Rows[objid_all.IndexOf(objectId)].Selected = true;
225
+                    }
226
+                    trans.Commit();
227
+                }
228
+                foreach (DataGridViewRow row in dataGridView_Info.Rows)
229
+                {
230
+                    row.Visible = row.Selected;
231
+                }
232
+            }
233
+        }
234
+
235
+            private void button_cancelshow_Click(object sender, EventArgs e)
236
+        {
237
+            foreach (DataGridViewRow row in dataGridView_Info.Rows)
238
+            {
239
+                row.Visible = true;
240
+            }
241
+        }
242
+
243
+        private void AttributeForm_FormClosed(object sender, FormClosedEventArgs e)
244
+        {
245
+            info_all.Clear();
246
+            objid_all.Clear();
247
+        }
248
+
249
+        private void dataGridView_Info_RowHeaderMouseClick(object sender, DataGridViewCellMouseEventArgs e)
250
+        {
251
+            Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
252
+            Editor ed = doc.Editor;
253
+            List<ObjectId> ids = new List<ObjectId>(); 
254
+            for(int i =0; i<this.dataGridView_Info.Rows.Count;i++)
255
+            {
256
+                if (this.dataGridView_Info.Rows[i].Selected == true)
257
+                {
258
+                    ids.Add(objid_all[i]);
259
+                }
260
+            }
261
+            ObjectId[] objid = ids.ToArray();
262
+            ed.SetImpliedSelection(objid);
263
+        }
264
+
265
+        private void dataGridView_Info_CellClick(object sender, DataGridViewCellEventArgs e)
266
+        {
267
+            Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
268
+            Editor ed = doc.Editor;
269
+            List<ObjectId> ids = new List<ObjectId>();
270
+            ObjectId[] objid = ids.ToArray();
271
+            ed.SetImpliedSelection(objid);
272
+        }
273
+    }
274
+}

+ 123
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/AttributeForm.resx 查看文件

@@ -0,0 +1,123 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<root>
3
+  <!-- 
4
+    Microsoft ResX Schema 
5
+    
6
+    Version 2.0
7
+    
8
+    The primary goals of this format is to allow a simple XML format 
9
+    that is mostly human readable. The generation and parsing of the 
10
+    various data types are done through the TypeConverter classes 
11
+    associated with the data types.
12
+    
13
+    Example:
14
+    
15
+    ... ado.net/XML headers & schema ...
16
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
17
+    <resheader name="version">2.0</resheader>
18
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
19
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
20
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
21
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
22
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
24
+    </data>
25
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
26
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
27
+        <comment>This is a comment</comment>
28
+    </data>
29
+                
30
+    There are any number of "resheader" rows that contain simple 
31
+    name/value pairs.
32
+    
33
+    Each data row contains a name, and value. The row also contains a 
34
+    type or mimetype. Type corresponds to a .NET class that support 
35
+    text/value conversion through the TypeConverter architecture. 
36
+    Classes that don't support this are serialized and stored with the 
37
+    mimetype set.
38
+    
39
+    The mimetype is used for serialized objects, and tells the 
40
+    ResXResourceReader how to depersist the object. This is currently not 
41
+    extensible. For a given mimetype the value must be set accordingly:
42
+    
43
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
44
+    that the ResXResourceWriter will generate, however the reader can 
45
+    read any of the formats listed below.
46
+    
47
+    mimetype: application/x-microsoft.net.object.binary.base64
48
+    value   : The object must be serialized with 
49
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
50
+            : and then encoded with base64 encoding.
51
+    
52
+    mimetype: application/x-microsoft.net.object.soap.base64
53
+    value   : The object must be serialized with 
54
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
55
+            : and then encoded with base64 encoding.
56
+
57
+    mimetype: application/x-microsoft.net.object.bytearray.base64
58
+    value   : The object must be serialized into a byte array 
59
+            : using a System.ComponentModel.TypeConverter
60
+            : and then encoded with base64 encoding.
61
+    -->
62
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
64
+    <xsd:element name="root" msdata:IsDataSet="true">
65
+      <xsd:complexType>
66
+        <xsd:choice maxOccurs="unbounded">
67
+          <xsd:element name="metadata">
68
+            <xsd:complexType>
69
+              <xsd:sequence>
70
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
71
+              </xsd:sequence>
72
+              <xsd:attribute name="name" use="required" type="xsd:string" />
73
+              <xsd:attribute name="type" type="xsd:string" />
74
+              <xsd:attribute name="mimetype" type="xsd:string" />
75
+              <xsd:attribute ref="xml:space" />
76
+            </xsd:complexType>
77
+          </xsd:element>
78
+          <xsd:element name="assembly">
79
+            <xsd:complexType>
80
+              <xsd:attribute name="alias" type="xsd:string" />
81
+              <xsd:attribute name="name" type="xsd:string" />
82
+            </xsd:complexType>
83
+          </xsd:element>
84
+          <xsd:element name="data">
85
+            <xsd:complexType>
86
+              <xsd:sequence>
87
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
88
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
89
+              </xsd:sequence>
90
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
91
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
92
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
93
+              <xsd:attribute ref="xml:space" />
94
+            </xsd:complexType>
95
+          </xsd:element>
96
+          <xsd:element name="resheader">
97
+            <xsd:complexType>
98
+              <xsd:sequence>
99
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
100
+              </xsd:sequence>
101
+              <xsd:attribute name="name" type="xsd:string" use="required" />
102
+            </xsd:complexType>
103
+          </xsd:element>
104
+        </xsd:choice>
105
+      </xsd:complexType>
106
+    </xsd:element>
107
+  </xsd:schema>
108
+  <resheader name="resmimetype">
109
+    <value>text/microsoft-resx</value>
110
+  </resheader>
111
+  <resheader name="version">
112
+    <value>2.0</value>
113
+  </resheader>
114
+  <resheader name="reader">
115
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116
+  </resheader>
117
+  <resheader name="writer">
118
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119
+  </resheader>
120
+  <metadata name="contextMenuStrip1.TrayLocation" type="System.Drawing.Point, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a">
121
+    <value>17, 17</value>
122
+  </metadata>
123
+</root>

+ 263
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/Attributeget.cs 查看文件

@@ -0,0 +1,263 @@
1
+using Autodesk.AutoCAD.ApplicationServices;
2
+using Autodesk.AutoCAD.DatabaseServices;
3
+using Autodesk.AutoCAD.EditorInput;
4
+using System;
5
+using System.Collections.Generic;
6
+using System.Linq;
7
+using System.Text;
8
+using System.Threading.Tasks;
9
+
10
+namespace CADTools
11
+{
12
+    class Attributeget
13
+    {
14
+        private static List<ObjectId> objid_all = new List<ObjectId>();
15
+        public void attribt()
16
+        {
17
+            //存放所有图层名
18
+            List<string> alllayername = new List<string>();
19
+            List<List<string>> info_all = new List<List<string>>();
20
+
21
+            Database db = HostApplicationServices.WorkingDatabase;
22
+            Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
23
+
24
+            using (Transaction trans = db.TransactionManager.StartTransaction())
25
+            {
26
+                LayerTable layertable = trans.GetObject(db.LayerTableId, OpenMode.ForRead) as LayerTable;
27
+                foreach (ObjectId objid in layertable)
28
+                {
29
+                    LayerTableRecord layertablerecord = trans.GetObject(objid, OpenMode.ForRead) as LayerTableRecord;
30
+                    alllayername.Add(layertablerecord.Name);
31
+                }
32
+                alllayername.Sort();
33
+                trans.Commit();
34
+            }
35
+
36
+            int num = 0;
37
+            for (int i = 0; i < alllayername.Count; i++)
38
+            {
39
+                List<List<string>> info = Getlyobjinfo(alllayername[i], num);
40
+                num = num + info.Count;
41
+                for (int j = 0; j < info.Count; j++)
42
+                {
43
+                    string id = info[j][0];
44
+                    string name = info[j][1];
45
+                    string type = info[j][2];
46
+                    string X = info[j][3];
47
+                    string Y = info[j][4];
48
+                    string Z = info[j][5];
49
+                    string lenth = info[j][6];
50
+                    string area = info[j][7];
51
+                    List<string> temp = new List<string>();
52
+                    temp.Add(id);
53
+                    temp.Add(name);
54
+                    temp.Add(alllayername[i]);
55
+                    temp.Add(type);
56
+                    temp.Add(X);
57
+                    temp.Add(Y);
58
+                    temp.Add(Z);
59
+                    temp.Add(lenth);
60
+                    temp.Add(area);
61
+                    info_all.Add(temp);
62
+                }
63
+            }
64
+
65
+            AttributeForm Frm = new AttributeForm();
66
+            Frm.GetInfo(info_all,objid_all);
67
+            Frm.Show();
68
+        }
69
+
70
+        private static List<List<string>> Getlyobjinfo(string layername, int num)
71
+        {
72
+            List<List<string>> info = new List<List<string>>();//图层中obj信息
73
+
74
+            Database database = HostApplicationServices.WorkingDatabase;
75
+            using (Transaction traction = database.TransactionManager.StartTransaction())
76
+            {
77
+                // 获得当前文档的编辑器  
78
+                Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
79
+                // 创建一个 TypedValue 数组,用于定义过滤条件
80
+                TypedValue[] typedvalue = new TypedValue[1];
81
+                typedvalue.SetValue(new TypedValue((int)DxfCode.LayerName, layername), 0);
82
+                // 赋值过滤条件给 SelectionFilter 对象
83
+                SelectionFilter selectionfilter = new SelectionFilter(typedvalue);
84
+                // 要求在图形区域中手动选择对象
85
+                PromptSelectionResult psr = editor.SelectAll(selectionfilter);
86
+
87
+                if (psr.Status == PromptStatus.OK)
88
+                {
89
+                    SelectionSet selectionset = psr.Value;
90
+                    ObjectId[] obj = new ObjectId[selectionset.Count];
91
+                    obj = selectionset.GetObjectIds();
92
+
93
+                    for (int i = 0; i < obj.Length; i++)
94
+                    {
95
+                        //获取实体
96
+                        ObjectId objid = obj[i];
97
+                        Entity entity = (Entity)traction.GetObject(objid, OpenMode.ForRead);
98
+                        objid_all.Add(objid);
99
+
100
+                        if (entity is Polyline)
101
+                        {
102
+                            num++;
103
+                            Polyline pll = (Polyline)entity;
104
+                            string name = "无";
105
+                            string type = "多段线";
106
+                            double X = pll.StartPoint.X;
107
+                            double Y = pll.StartPoint.Y;
108
+                            double Z = pll.Elevation;
109
+                            double length = pll.Length;
110
+                            string area;
111
+                            if(pll.Closed)
112
+                            {
113
+                                area = pll.Area.ToString("0.000");
114
+                            }
115
+                            else
116
+                            {
117
+                                area = "无";
118
+                            }
119
+                            List<string> temp = new List<string>();
120
+                            temp.Add(num.ToString());
121
+                            temp.Add(name);
122
+                            temp.Add(type);
123
+                            temp.Add(X.ToString("0.000"));
124
+                            temp.Add(Y.ToString("0.000"));
125
+                            temp.Add(Z.ToString("0.000"));
126
+                            temp.Add(length.ToString("0.000"));
127
+                            temp.Add(area);
128
+                            info.Add(temp);
129
+                        }
130
+                        if (entity is Polyline2d)
131
+                        {
132
+                            num++;
133
+                            Polyline2d pll = (Polyline2d)entity;
134
+                            string name = "无";
135
+                            string type = "二维多段线";
136
+                            double X = pll.StartPoint.X;
137
+                            double Y = pll.StartPoint.Y;
138
+                            double Z = pll.Elevation;
139
+                            double length = pll.Length;
140
+                            string area;
141
+                            if (pll.Closed)
142
+                            {
143
+                                area = pll.Area.ToString("0.000");
144
+                            }
145
+                            else
146
+                            {
147
+                                area = "无";
148
+                            }
149
+                            List<string> temp = new List<string>();
150
+                            temp.Add(num.ToString());
151
+                            temp.Add(name);
152
+                            temp.Add(type);
153
+                            temp.Add(X.ToString("0.000"));
154
+                            temp.Add(Y.ToString("0.000"));
155
+                            temp.Add(Z.ToString("0.000"));
156
+                            temp.Add(length.ToString("0.000"));
157
+                            temp.Add(area);
158
+                            info.Add(temp);
159
+                        }
160
+                        else if (entity is Line)
161
+                        {
162
+                            num++;
163
+                            Line line = (Line)entity;
164
+                            string name = "无";
165
+                            string type = "直线";
166
+                            double X = line.StartPoint.X;
167
+                            double Y = line.StartPoint.Y;
168
+                            double Z = line.StartPoint.Z;
169
+                            double length = line.Length;
170
+                            string area;
171
+                            if (line.Closed)
172
+                            {
173
+                                area = line.Area.ToString("0.000");
174
+                            }
175
+                            else
176
+                            {
177
+                                area = "无";
178
+                            }
179
+                            List<string> temp = new List<string>();
180
+                            temp.Add(num.ToString());
181
+                            temp.Add(name);
182
+                            temp.Add(type);
183
+                            temp.Add(X.ToString("0.000"));
184
+                            temp.Add(Y.ToString("0.000"));
185
+                            temp.Add(Z.ToString("0.000"));
186
+                            temp.Add(length.ToString("0.000"));
187
+                            temp.Add(area);
188
+                            info.Add(temp);
189
+                        }
190
+                        else if (entity is DBText)
191
+                        {
192
+                            num++;
193
+                            DBText txt = (DBText)entity;
194
+                            string name = txt.TextString;
195
+                            string type = "文字";
196
+                            double X = txt.Position.X;
197
+                            double Y = txt.Position.Y;
198
+                            double Z = txt.Position.Z;
199
+                            string length = "无";
200
+                            string area = "无";
201
+                            List<string> temp = new List<string>();
202
+                            temp.Add(num.ToString());
203
+                            temp.Add(name);
204
+                            temp.Add(type);
205
+                            temp.Add(X.ToString("0.000"));
206
+                            temp.Add(Y.ToString("0.000"));
207
+                            temp.Add(Z.ToString("0.000"));
208
+                            temp.Add(length);
209
+                            temp.Add(area);
210
+                            info.Add(temp);
211
+                        }
212
+                        else if (entity is BlockReference)
213
+                        {
214
+                            num++;
215
+                            BlockReference blk = (BlockReference)entity;
216
+                            string name = blk.Name;
217
+                            string type = "块参照";
218
+                            double X = blk.Position.X;
219
+                            double Y = blk.Position.Y;
220
+                            double Z = blk.Position.Z;
221
+                            string length = "无";
222
+                            string area = "无";
223
+                            List<string> temp = new List<string>();
224
+                            temp.Add(num.ToString());
225
+                            temp.Add(name);
226
+                            temp.Add(type);
227
+                            temp.Add(X.ToString("0.000"));
228
+                            temp.Add(Y.ToString("0.000"));
229
+                            temp.Add(Z.ToString("0.000"));
230
+                            temp.Add(length);
231
+                            temp.Add(area);
232
+                            info.Add(temp);
233
+                        }
234
+                        else if(entity is Hatch)
235
+                        {
236
+                            num++;
237
+                            Hatch hc = (Hatch)entity;
238
+                            string name = hc.PatternName;
239
+                            string type = "图案填充";
240
+                            double X = hc.Origin.X;
241
+                            double Y = hc.Origin.Y;
242
+                            double Z = 0;
243
+                            string length = "无";
244
+                            string area = hc.Area.ToString();
245
+                            List<string> temp = new List<string>();
246
+                            temp.Add(num.ToString());
247
+                            temp.Add(name);
248
+                            temp.Add(type);
249
+                            temp.Add(X.ToString("0.000"));
250
+                            temp.Add(Y.ToString("0.000"));
251
+                            temp.Add(Z.ToString("0.000"));
252
+                            temp.Add(length);
253
+                            temp.Add(area);
254
+                            info.Add(temp);
255
+                        }
256
+                    }
257
+                }
258
+                traction.Commit();
259
+            }
260
+            return info;
261
+        }
262
+    }
263
+}

+ 401
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/CADTools.csproj 查看文件

@@ -0,0 +1,401 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
+  <Import Project="..\packages\Costura.Fody.3.3.3\build\Costura.Fody.props" Condition="Exists('..\packages\Costura.Fody.3.3.3\build\Costura.Fody.props')" />
4
+  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
5
+  <PropertyGroup>
6
+    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
7
+    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
8
+    <ProjectGuid>{3EA75AE9-D4B2-415A-8646-756159376FFF}</ProjectGuid>
9
+    <OutputType>Library</OutputType>
10
+    <RootNamespace>CADTools</RootNamespace>
11
+    <AssemblyName>CADTools</AssemblyName>
12
+    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
13
+    <FileAlignment>512</FileAlignment>
14
+    <Deterministic>true</Deterministic>
15
+    <NuGetPackageImportStamp>
16
+    </NuGetPackageImportStamp>
17
+  </PropertyGroup>
18
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
19
+    <PlatformTarget>AnyCPU</PlatformTarget>
20
+    <DebugSymbols>true</DebugSymbols>
21
+    <DebugType>full</DebugType>
22
+    <Optimize>false</Optimize>
23
+    <OutputPath>bin\Debug\</OutputPath>
24
+    <DefineConstants>DEBUG;TRACE</DefineConstants>
25
+    <ErrorReport>prompt</ErrorReport>
26
+    <WarningLevel>4</WarningLevel>
27
+  </PropertyGroup>
28
+  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
29
+    <PlatformTarget>AnyCPU</PlatformTarget>
30
+    <DebugType>pdbonly</DebugType>
31
+    <Optimize>true</Optimize>
32
+    <OutputPath>bin\Release\</OutputPath>
33
+    <DefineConstants>TRACE</DefineConstants>
34
+    <ErrorReport>prompt</ErrorReport>
35
+    <WarningLevel>4</WarningLevel>
36
+  </PropertyGroup>
37
+  <PropertyGroup />
38
+  <PropertyGroup>
39
+    <StartupObject />
40
+  </PropertyGroup>
41
+  <ItemGroup>
42
+    <Reference Include="accoremgd">
43
+      <HintPath>E:\autocad2016\AutoCAD 2016\accoremgd.dll</HintPath>
44
+      <Private>False</Private>
45
+    </Reference>
46
+    <Reference Include="AcCui">
47
+      <HintPath>E:\autocad2016\AutoCAD 2016\AcCui.dll</HintPath>
48
+      <Private>False</Private>
49
+    </Reference>
50
+    <Reference Include="acdbmgd">
51
+      <HintPath>E:\autocad2016\AutoCAD 2016\acdbmgd.dll</HintPath>
52
+      <Private>False</Private>
53
+    </Reference>
54
+    <Reference Include="acmgd">
55
+      <HintPath>E:\autocad2016\AutoCAD 2016\acmgd.dll</HintPath>
56
+      <Private>False</Private>
57
+    </Reference>
58
+    <Reference Include="Autodesk.AutoCAD.Interop">
59
+      <HintPath>E:\autocad2016\AutoCAD 2016\Autodesk.AutoCAD.Interop.dll</HintPath>
60
+      <EmbedInteropTypes>True</EmbedInteropTypes>
61
+    </Reference>
62
+    <Reference Include="Costura, Version=3.3.3.0, Culture=neutral, PublicKeyToken=9919ef960d84173d, processorArchitecture=MSIL">
63
+      <HintPath>..\packages\Costura.Fody.3.3.3\lib\net40\Costura.dll</HintPath>
64
+    </Reference>
65
+    <Reference Include="GeoAPI, Version=1.7.5.0, Culture=neutral, PublicKeyToken=a1a0da7def465678, processorArchitecture=MSIL">
66
+      <HintPath>..\packages\GeoAPI.Core.1.7.5\lib\net45\GeoAPI.dll</HintPath>
67
+    </Reference>
68
+    <Reference Include="GeoAPI.CoordinateSystems, Version=1.7.5.0, Culture=neutral, PublicKeyToken=a1a0da7def465678, processorArchitecture=MSIL">
69
+      <HintPath>..\packages\GeoAPI.CoordinateSystems.1.7.5\lib\net45\GeoAPI.CoordinateSystems.dll</HintPath>
70
+    </Reference>
71
+    <Reference Include="NetTopologySuite, Version=1.15.3.0, Culture=neutral, PublicKeyToken=f580a05016ebada1, processorArchitecture=MSIL">
72
+      <HintPath>..\packages\NetTopologySuite.Core.1.15.3\lib\net45\NetTopologySuite.dll</HintPath>
73
+    </Reference>
74
+    <Reference Include="NetTopologySuite.CoordinateSystems, Version=1.15.3.0, Culture=neutral, PublicKeyToken=f580a05016ebada1, processorArchitecture=MSIL">
75
+      <HintPath>..\packages\NetTopologySuite.CoordinateSystems.1.15.3\lib\net45\NetTopologySuite.CoordinateSystems.dll</HintPath>
76
+    </Reference>
77
+    <Reference Include="PresentationCore" />
78
+    <Reference Include="System" />
79
+    <Reference Include="System.Core" />
80
+    <Reference Include="System.Management" />
81
+    <Reference Include="System.Xml.Linq" />
82
+    <Reference Include="System.Data.DataSetExtensions" />
83
+    <Reference Include="Microsoft.CSharp" />
84
+    <Reference Include="System.Data" />
85
+    <Reference Include="System.Deployment" />
86
+    <Reference Include="System.Drawing" />
87
+    <Reference Include="System.Net.Http" />
88
+    <Reference Include="System.Windows.Forms" />
89
+    <Reference Include="System.Xml" />
90
+  </ItemGroup>
91
+  <ItemGroup>
92
+    <Compile Include="AttributeForm.cs">
93
+      <SubType>Form</SubType>
94
+    </Compile>
95
+    <Compile Include="AttributeForm.Designer.cs">
96
+      <DependentUpon>AttributeForm.cs</DependentUpon>
97
+    </Compile>
98
+    <Compile Include="Attributeget.cs" />
99
+    <Compile Include="Chaginfos.cs">
100
+      <SubType>Form</SubType>
101
+    </Compile>
102
+    <Compile Include="Chaginfos.Designer.cs">
103
+      <DependentUpon>Chaginfos.cs</DependentUpon>
104
+    </Compile>
105
+    <Compile Include="CheckContourLine.cs" />
106
+    <Compile Include="CheckL.cs">
107
+      <SubType>Form</SubType>
108
+    </Compile>
109
+    <Compile Include="CheckL.Designer.cs">
110
+      <DependentUpon>CheckL.cs</DependentUpon>
111
+    </Compile>
112
+    <Compile Include="CheckPLOverlay.cs" />
113
+    <Compile Include="ChPLConstradiction1.cs" />
114
+    <Compile Include="ChPLContradiction.cs" />
115
+    <Compile Include="CutDgxByTK.cs">
116
+      <SubType>Form</SubType>
117
+    </Compile>
118
+    <Compile Include="CutDgxByTK.Designer.cs">
119
+      <DependentUpon>CutDgxByTK.cs</DependentUpon>
120
+    </Compile>
121
+    <Compile Include="cutdgx_method.cs" />
122
+    <Compile Include="CMCgis_Basicfunction.cs" />
123
+    <Compile Include="Conn.cs">
124
+      <SubType>Form</SubType>
125
+    </Compile>
126
+    <Compile Include="Conn.Designer.cs">
127
+      <DependentUpon>Conn.cs</DependentUpon>
128
+    </Compile>
129
+    <Compile Include="Connect.cs" />
130
+    <Compile Include="ContourLineFix.cs" />
131
+    <Compile Include="DeleteElept.cs">
132
+      <SubType>Form</SubType>
133
+    </Compile>
134
+    <Compile Include="DeleteElept.Designer.cs">
135
+      <DependentUpon>DeleteElept.cs</DependentUpon>
136
+    </Compile>
137
+    <Compile Include="DeletePts.cs" />
138
+    <Compile Include="DgxAnnck.cs" />
139
+    <Compile Include="DgxAnno.cs">
140
+      <SubType>Form</SubType>
141
+    </Compile>
142
+    <Compile Include="DgxAnno.Designer.cs">
143
+      <DependentUpon>DgxAnno.cs</DependentUpon>
144
+    </Compile>
145
+    <Compile Include="DgxCrossrvrd.cs" />
146
+    <Compile Include="DGXGeneral.cs">
147
+      <SubType>Form</SubType>
148
+    </Compile>
149
+    <Compile Include="DGXGeneral.Designer.cs">
150
+      <DependentUpon>DGXGeneral.cs</DependentUpon>
151
+    </Compile>
152
+    <Compile Include="DGXGeneralization.cs" />
153
+    <Compile Include="Dgxinters.cs" />
154
+    <Compile Include="Dgxthrorvrd.cs" />
155
+    <Compile Include="Dgxthrorvrd_Form.cs">
156
+      <SubType>Form</SubType>
157
+    </Compile>
158
+    <Compile Include="Dgxthrorvrd_Form.Designer.cs">
159
+      <DependentUpon>Dgxthrorvrd_Form.cs</DependentUpon>
160
+    </Compile>
161
+    <Compile Include="ElePtCheck.cs" />
162
+    <Compile Include="EleptDenck.cs" />
163
+    <Compile Include="EleptDensity.cs">
164
+      <SubType>Form</SubType>
165
+    </Compile>
166
+    <Compile Include="EleptDensity.Designer.cs">
167
+      <DependentUpon>EleptDensity.cs</DependentUpon>
168
+    </Compile>
169
+    <Compile Include="EleRd.cs">
170
+      <SubType>Form</SubType>
171
+    </Compile>
172
+    <Compile Include="EleRd.Designer.cs">
173
+      <DependentUpon>EleRd.cs</DependentUpon>
174
+    </Compile>
175
+    <Compile Include="EleRound.cs" />
176
+    <Compile Include="FeatureOverlap.cs" />
177
+    <Compile Include="CutDgx.cs">
178
+      <SubType>Form</SubType>
179
+    </Compile>
180
+    <Compile Include="CutDgx.Designer.cs">
181
+      <DependentUpon>CutDgx.cs</DependentUpon>
182
+    </Compile>
183
+    <Compile Include="GCDdelete_Form.cs">
184
+      <SubType>Form</SubType>
185
+    </Compile>
186
+    <Compile Include="GCDdelete_Form.Designer.cs">
187
+      <DependentUpon>GCDdelete_Form.cs</DependentUpon>
188
+    </Compile>
189
+    <Compile Include="Hierak.cs">
190
+      <SubType>Form</SubType>
191
+    </Compile>
192
+    <Compile Include="Hierak.Designer.cs">
193
+      <DependentUpon>Hierak.cs</DependentUpon>
194
+    </Compile>
195
+    <Compile Include="Hierarchy.cs" />
196
+    <Compile Include="InsertDOM.cs" />
197
+    <Compile Include="InsertDOMs_to_one.cs">
198
+      <SubType>Form</SubType>
199
+    </Compile>
200
+    <Compile Include="InsertDOMs_to_one.Designer.cs">
201
+      <DependentUpon>InsertDOMs_to_one.cs</DependentUpon>
202
+    </Compile>
203
+    <Compile Include="InstDOM.cs">
204
+      <SubType>Form</SubType>
205
+    </Compile>
206
+    <Compile Include="InstDOM.Designer.cs">
207
+      <DependentUpon>InstDOM.cs</DependentUpon>
208
+    </Compile>
209
+    <Compile Include="Inters.cs" />
210
+    <Compile Include="JQXLabel_grid.cs">
211
+      <SubType>Form</SubType>
212
+    </Compile>
213
+    <Compile Include="JQXLabel_grid.Designer.cs">
214
+      <DependentUpon>JQXLabel_grid.cs</DependentUpon>
215
+    </Compile>
216
+    <Compile Include="LayerChange.cs" />
217
+    <Compile Include="Layerchange_Form.cs">
218
+      <SubType>Form</SubType>
219
+    </Compile>
220
+    <Compile Include="Layerchange_Form.Designer.cs">
221
+      <DependentUpon>Layerchange_Form.cs</DependentUpon>
222
+    </Compile>
223
+    <Compile Include="MainClass.cs" />
224
+    <Compile Include="Menus.cs" />
225
+    <Compile Include="MergeDwg.cs">
226
+      <SubType>Form</SubType>
227
+    </Compile>
228
+    <Compile Include="MergeDwg.Designer.cs">
229
+      <DependentUpon>MergeDwg.cs</DependentUpon>
230
+    </Compile>
231
+    <Compile Include="ModifyTFH.cs">
232
+      <SubType>Form</SubType>
233
+    </Compile>
234
+    <Compile Include="ModifyTFH.Designer.cs">
235
+      <DependentUpon>ModifyTFH.cs</DependentUpon>
236
+    </Compile>
237
+    <Compile Include="PickupPoint.cs" />
238
+    <Compile Include="PicPts.cs">
239
+      <SubType>Form</SubType>
240
+    </Compile>
241
+    <Compile Include="PicPts.Designer.cs">
242
+      <DependentUpon>PicPts.cs</DependentUpon>
243
+    </Compile>
244
+    <Compile Include="PLError_Overlay.cs">
245
+      <SubType>Form</SubType>
246
+    </Compile>
247
+    <Compile Include="PLError_Overlay.Designer.cs">
248
+      <DependentUpon>PLError_Overlay.cs</DependentUpon>
249
+    </Compile>
250
+    <Compile Include="Properties\AssemblyInfo.cs" />
251
+    <Compile Include="PtCheck.cs">
252
+      <SubType>Form</SubType>
253
+    </Compile>
254
+    <Compile Include="PtCheck.Designer.cs">
255
+      <DependentUpon>PtCheck.cs</DependentUpon>
256
+    </Compile>
257
+    <Compile Include="PtLinecontradiction.cs">
258
+      <SubType>Form</SubType>
259
+    </Compile>
260
+    <Compile Include="PtLinecontradiction.Designer.cs">
261
+      <DependentUpon>PtLinecontradiction.cs</DependentUpon>
262
+    </Compile>
263
+    <Compile Include="Scale.cs">
264
+      <SubType>Form</SubType>
265
+    </Compile>
266
+    <Compile Include="Scale.Designer.cs">
267
+      <DependentUpon>Scale.cs</DependentUpon>
268
+    </Compile>
269
+    <Compile Include="SlopeL.cs">
270
+      <SubType>Form</SubType>
271
+    </Compile>
272
+    <Compile Include="SlopeL.Designer.cs">
273
+      <DependentUpon>SlopeL.cs</DependentUpon>
274
+    </Compile>
275
+    <Compile Include="SlopeLine.cs" />
276
+    <Compile Include="TKInfo.cs">
277
+      <SubType>Form</SubType>
278
+    </Compile>
279
+    <Compile Include="TKInfo.Designer.cs">
280
+      <DependentUpon>TKInfo.cs</DependentUpon>
281
+    </Compile>
282
+    <EmbeddedResource Include="AttributeForm.resx">
283
+      <DependentUpon>AttributeForm.cs</DependentUpon>
284
+    </EmbeddedResource>
285
+    <EmbeddedResource Include="Chaginfos.resx">
286
+      <DependentUpon>Chaginfos.cs</DependentUpon>
287
+    </EmbeddedResource>
288
+    <EmbeddedResource Include="CheckL.resx">
289
+      <DependentUpon>CheckL.cs</DependentUpon>
290
+    </EmbeddedResource>
291
+    <EmbeddedResource Include="Conn.resx">
292
+      <DependentUpon>Conn.cs</DependentUpon>
293
+    </EmbeddedResource>
294
+    <EmbeddedResource Include="CutDgxByTK.resx">
295
+      <DependentUpon>CutDgxByTK.cs</DependentUpon>
296
+    </EmbeddedResource>
297
+    <EmbeddedResource Include="DeleteElept.resx">
298
+      <DependentUpon>DeleteElept.cs</DependentUpon>
299
+    </EmbeddedResource>
300
+    <EmbeddedResource Include="DgxAnno.resx">
301
+      <DependentUpon>DgxAnno.cs</DependentUpon>
302
+    </EmbeddedResource>
303
+    <EmbeddedResource Include="DGXGeneral.resx">
304
+      <DependentUpon>DGXGeneral.cs</DependentUpon>
305
+    </EmbeddedResource>
306
+    <EmbeddedResource Include="Dgxthrorvrd_Form.resx">
307
+      <DependentUpon>Dgxthrorvrd_Form.cs</DependentUpon>
308
+    </EmbeddedResource>
309
+    <EmbeddedResource Include="EleptDensity.resx">
310
+      <DependentUpon>EleptDensity.cs</DependentUpon>
311
+    </EmbeddedResource>
312
+    <EmbeddedResource Include="EleRd.resx">
313
+      <DependentUpon>EleRd.cs</DependentUpon>
314
+    </EmbeddedResource>
315
+    <EmbeddedResource Include="CutDgx.resx">
316
+      <DependentUpon>CutDgx.cs</DependentUpon>
317
+    </EmbeddedResource>
318
+    <EmbeddedResource Include="GCDdelete_Form.resx">
319
+      <DependentUpon>GCDdelete_Form.cs</DependentUpon>
320
+    </EmbeddedResource>
321
+    <EmbeddedResource Include="Hierak.resx">
322
+      <DependentUpon>Hierak.cs</DependentUpon>
323
+    </EmbeddedResource>
324
+    <EmbeddedResource Include="InsertDOMs_to_one.resx">
325
+      <DependentUpon>InsertDOMs_to_one.cs</DependentUpon>
326
+    </EmbeddedResource>
327
+    <EmbeddedResource Include="InstDOM.resx">
328
+      <DependentUpon>InstDOM.cs</DependentUpon>
329
+    </EmbeddedResource>
330
+    <EmbeddedResource Include="JQXLabel_grid.resx">
331
+      <DependentUpon>JQXLabel_grid.cs</DependentUpon>
332
+    </EmbeddedResource>
333
+    <EmbeddedResource Include="Layerchange_Form.resx">
334
+      <DependentUpon>Layerchange_Form.cs</DependentUpon>
335
+    </EmbeddedResource>
336
+    <EmbeddedResource Include="MergeDwg.resx">
337
+      <DependentUpon>MergeDwg.cs</DependentUpon>
338
+    </EmbeddedResource>
339
+    <EmbeddedResource Include="ModifyTFH.resx">
340
+      <DependentUpon>ModifyTFH.cs</DependentUpon>
341
+    </EmbeddedResource>
342
+    <EmbeddedResource Include="PicPts.resx">
343
+      <DependentUpon>PicPts.cs</DependentUpon>
344
+    </EmbeddedResource>
345
+    <EmbeddedResource Include="PLError_Overlay.resx">
346
+      <DependentUpon>PLError_Overlay.cs</DependentUpon>
347
+    </EmbeddedResource>
348
+    <EmbeddedResource Include="Properties\Resources.resx">
349
+      <Generator>ResXFileCodeGenerator</Generator>
350
+      <LastGenOutput>Resources.Designer.cs</LastGenOutput>
351
+      <SubType>Designer</SubType>
352
+    </EmbeddedResource>
353
+    <Compile Include="Properties\Resources.Designer.cs">
354
+      <AutoGen>True</AutoGen>
355
+      <DependentUpon>Resources.resx</DependentUpon>
356
+    </Compile>
357
+    <EmbeddedResource Include="PtCheck.resx">
358
+      <DependentUpon>PtCheck.cs</DependentUpon>
359
+    </EmbeddedResource>
360
+    <EmbeddedResource Include="PtLinecontradiction.resx">
361
+      <DependentUpon>PtLinecontradiction.cs</DependentUpon>
362
+    </EmbeddedResource>
363
+    <EmbeddedResource Include="Scale.resx">
364
+      <DependentUpon>Scale.cs</DependentUpon>
365
+    </EmbeddedResource>
366
+    <EmbeddedResource Include="SlopeL.resx">
367
+      <DependentUpon>SlopeL.cs</DependentUpon>
368
+    </EmbeddedResource>
369
+    <EmbeddedResource Include="TKInfo.resx">
370
+      <DependentUpon>TKInfo.cs</DependentUpon>
371
+    </EmbeddedResource>
372
+    <None Include="FodyWeavers.xsd">
373
+      <SubType>Designer</SubType>
374
+    </None>
375
+    <None Include="packages.config" />
376
+    <None Include="Properties\Settings.settings">
377
+      <Generator>SettingsSingleFileGenerator</Generator>
378
+      <LastGenOutput>Settings.Designer.cs</LastGenOutput>
379
+    </None>
380
+    <Compile Include="Properties\Settings.Designer.cs">
381
+      <AutoGen>True</AutoGen>
382
+      <DependentUpon>Settings.settings</DependentUpon>
383
+      <DesignTimeSharedInput>True</DesignTimeSharedInput>
384
+    </Compile>
385
+  </ItemGroup>
386
+  <ItemGroup>
387
+    <None Include="App.config" />
388
+  </ItemGroup>
389
+  <ItemGroup>
390
+    <Content Include="FodyWeavers.xml" />
391
+  </ItemGroup>
392
+  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
393
+  <Import Project="..\packages\Fody.4.0.2\build\Fody.targets" Condition="Exists('..\packages\Fody.4.0.2\build\Fody.targets')" />
394
+  <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
395
+    <PropertyGroup>
396
+      <ErrorText>这台计算机上缺少此项目引用的 NuGet 程序包。使用“NuGet 程序包还原”可下载这些程序包。有关更多信息,请参见 http://go.microsoft.com/fwlink/?LinkID=322105。缺少的文件是 {0}。</ErrorText>
397
+    </PropertyGroup>
398
+    <Error Condition="!Exists('..\packages\Fody.4.0.2\build\Fody.targets')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Fody.4.0.2\build\Fody.targets'))" />
399
+    <Error Condition="!Exists('..\packages\Costura.Fody.3.3.3\build\Costura.Fody.props')" Text="$([System.String]::Format('$(ErrorText)', '..\packages\Costura.Fody.3.3.3\build\Costura.Fody.props'))" />
400
+  </Target>
401
+</Project>

+ 10
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/CADTools.csproj.user 查看文件

@@ -0,0 +1,10 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<Project ToolsVersion="Current" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
+  <PropertyGroup>
4
+    <ProjectView>ShowAllFiles</ProjectView>
5
+  </PropertyGroup>
6
+  <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
7
+    <StartAction>Program</StartAction>
8
+    <StartProgram>E:\autocad2016\AutoCAD 2016\acad.exe</StartProgram>
9
+  </PropertyGroup>
10
+</Project>

+ 3081
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/CMCgis_Basicfunction.cs
文件差异内容过多而无法显示
查看文件


+ 689
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/ChPLConstradiction1.cs 查看文件

@@ -0,0 +1,689 @@
1
+using Autodesk.AutoCAD.ApplicationServices;
2
+using Autodesk.AutoCAD.DatabaseServices;
3
+using Autodesk.AutoCAD.EditorInput;
4
+using Autodesk.AutoCAD.Geometry;
5
+using System;
6
+using System.Collections.Generic;
7
+using System.Diagnostics;
8
+using System.Linq;
9
+using System.Text;
10
+using System.Threading.Tasks;
11
+
12
+namespace CADTools
13
+{
14
+
15
+    // 存储交点和对应等高线的数据结构
16
+    class IntersectionResult
17
+    {
18
+        public List<Point3d> IntersectionPoint { get; set; }
19
+        public Polyline Contour { get; set; }
20
+
21
+    }
22
+    class ChPLContradiction1
23
+    {
24
+        public static int blc;//比例尺
25
+        public static string sqx;//首曲线
26
+        public static string jqx;//计曲线
27
+        public static double dgj;//计曲线
28
+        public static string elevationLayer;//高程点图层名
29
+        public static int num = 0;//点线矛盾点数量
30
+        int looptimes = 5;//循环查找次数
31
+
32
+
33
+        public void Check()
34
+        {
35
+            Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
36
+            Database db = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database;
37
+            num = 0;
38
+
39
+            var ptlist = GetPt(ed, db);
40
+            for (int i = 0; i < ptlist.Count; i++)
41
+            {
42
+                BlockReference bf = ptlist[i];
43
+                //为方便搜索操作,将待检查高程点设置为当前视图的中心点,视图高设置为600
44
+                SetWindow(ed, db, bf.Position.X, bf.Position.Y, 600, 600);
45
+                bool contradition = true;
46
+                for (int j = 0; j < looptimes; j++)
47
+                {
48
+                    double searchlength = 100.0 * (j + 1);
49
+                    var searchpl_horizontal = SearchDGX(bf.Position, searchlength, ed, db, 0);
50
+                    var searchpl_vertical = SearchDGX(bf.Position, searchlength, ed, db, 1);
51
+                    List<Polyline> all_pl = new List<Polyline>();
52
+                    all_pl.AddRange(searchpl_horizontal);
53
+                    foreach (var item in searchpl_vertical)
54
+                    {
55
+                        if (all_pl.Contains(item))
56
+                            continue;
57
+                        else
58
+                            all_pl.Add(item);
59
+                    }
60
+                    if (all_pl.Count < 2)
61
+                        continue;
62
+                    contradition = IfContradition(all_pl, bf.Position, searchlength);
63
+                    if (!contradition)
64
+                        break;
65
+                }
66
+                if (contradition)
67
+                {
68
+                    num++;
69
+                    MakeFlag(bf.Position, blc);
70
+
71
+                    Point3d p1 = new Point3d(bf.Position.X - 4 * blc / 2000, bf.Position.Y - 4 * blc / 2000, 0);
72
+                    Point3d p2 = new Point3d(bf.Position.X + 4 * blc / 2000, bf.Position.Y + 4 * blc / 2000, 0);
73
+                    TypedValue[] typedvalue = new TypedValue[2];
74
+
75
+                    typedvalue.SetValue(new TypedValue((int)DxfCode.Start, "Text"), 0);
76
+                    typedvalue.SetValue(new TypedValue((int)DxfCode.LayerName, elevationLayer), 1);
77
+
78
+                    SelectionFilter filter = new SelectionFilter(typedvalue);
79
+                    PromptSelectionResult psr = ed.SelectCrossingWindow(p1, p2, filter);
80
+                    List<ObjectId> objs = new List<ObjectId>();
81
+                    if (psr.Status == PromptStatus.OK)
82
+                    {
83
+                        SelectionSet set = psr.Value;
84
+                        objs = set.GetObjectIds().ToList();
85
+                    }
86
+                    DocumentLock doclock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
87
+                    using (Transaction tr = db.TransactionManager.StartTransaction())
88
+                    {
89
+                        if (objs.Count > 0)
90
+                        {
91
+                            for (int ii = 0; ii < objs.Count; ii++)
92
+                            {
93
+                                Entity ent = (Entity)tr.GetObject(objs[ii], OpenMode.ForWrite);
94
+                                if (ent is DBText)
95
+                                {
96
+                                    DBText t = (DBText)ent;
97
+                                    double T_Value = Convert.ToDouble(t.TextString);
98
+                                    int ws = 0;
99
+                                    if (t.TextString.Contains('.'))
100
+                                    {
101
+                                        ws = t.TextString.Split('.')[1].Length;
102
+                                        if (t.TextString.Split('.')[1].All(c => c == '0'))
103
+                                            ws = 0;
104
+                                    }
105
+                                    double ele = Math.Round(t.Position.Z, ws, MidpointRounding.AwayFromZero);
106
+                                    if (T_Value == ele)
107
+                                    {
108
+                                        t.Layer = "点线矛盾高程点图层";
109
+                                        t.Color = Autodesk.AutoCAD.Colors.Color.FromColorIndex(Autodesk.AutoCAD.Colors.ColorMethod.ByLayer, 256);
110
+                                    }
111
+                                }
112
+                            }
113
+                        }
114
+
115
+                        BlockReference blcref = (BlockReference)tr.GetObject(bf.ObjectId, OpenMode.ForWrite);
116
+                        blcref.Layer = "点线矛盾高程点图层";
117
+                        tr.Commit();
118
+                    }
119
+                    doclock.Dispose();
120
+                }
121
+            }
122
+        }
123
+
124
+        //获取所有高程点
125
+        private List<BlockReference> GetPt(Editor ed,Database db)
126
+        {
127
+            List<BlockReference> result = new List<BlockReference>();
128
+
129
+            TypedValue[] typedvalue = new TypedValue[1];
130
+            typedvalue.SetValue(new TypedValue((int)DxfCode.LayerName, elevationLayer), 0);
131
+            SelectionFilter selectionfilter = new SelectionFilter(typedvalue);
132
+            PromptSelectionResult psr = ed.SelectAll(selectionfilter);
133
+            if (psr.Status == PromptStatus.OK)
134
+            {
135
+                SelectionSet selectionset = psr.Value;
136
+                ObjectId[] obj = new ObjectId[selectionset.Count];
137
+                obj = selectionset.GetObjectIds();
138
+                for (int i = 0; i < obj.Length; i++)
139
+                {
140
+                    DocumentLock doclock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
141
+                    using (Transaction tr = db.TransactionManager.StartTransaction())
142
+                    {
143
+                        ObjectId objid = obj[i];
144
+
145
+                        //找到实体,取高程点的位置
146
+                        Entity entity = (Entity)tr.GetObject(objid, OpenMode.ForWrite);
147
+
148
+                        if (entity is BlockReference)
149
+                        {
150
+                            BlockReference bf = (BlockReference)entity;
151
+                            result.Add(bf);
152
+                        }
153
+                        tr.Commit();
154
+                    }
155
+                    doclock.Dispose();
156
+                }
157
+            }
158
+            return result;
159
+        }
160
+
161
+        //设置当前视图
162
+        private void SetWindow(Editor ed, Database db,double x,double y,double width,double height)
163
+        {
164
+            using (Transaction tr = db.TransactionManager.StartTransaction())
165
+            {
166
+                ViewTableRecord currview = ed.GetCurrentView();
167
+                currview.CenterPoint = new Point2d(x, y);
168
+                currview.ViewDirection = new Vector3d(0, 0, 1);
169
+                currview.Width = width;
170
+                currview.Height = height;
171
+                ed.SetCurrentView(currview);
172
+                tr.Commit();
173
+            }
174
+        }
175
+
176
+        //按垂直或水平方向搜索高程点周围等高线
177
+        private List<Polyline> SearchDGX(Point3d pt,double length,Editor ed, Database db, int direction)
178
+        {
179
+            List<Polyline> result = new List<Polyline>();
180
+            Point3d startpt;
181
+            Point3d endpt;
182
+            if (direction == 0)
183
+            {
184
+                startpt = new Point3d(pt.X - length / 2, pt.Y, pt.Z);
185
+                endpt = new Point3d(pt.X + length / 2, pt.Y, pt.Z);
186
+            }
187
+            else
188
+            {
189
+                startpt = new Point3d(pt.X, pt.Y - length / 2, pt.Z);
190
+                endpt = new Point3d(pt.X, pt.Y + length / 2, pt.Z);
191
+            }
192
+            Point3dCollection ptcoll = new Point3dCollection();
193
+            ptcoll.Add(startpt);
194
+            ptcoll.Add(endpt);
195
+
196
+            TypedValue[] typedvalue = new TypedValue[1];
197
+            typedvalue.SetValue(new TypedValue((int)DxfCode.LayerName, sqx + "," + jqx), 0);
198
+            SelectionFilter selectionfilter = new SelectionFilter(typedvalue);
199
+            PromptSelectionResult psr = ed.SelectFence(ptcoll, selectionfilter);
200
+            if (psr.Status == PromptStatus.OK)
201
+            {
202
+                SelectionSet selectionset = psr.Value;
203
+                ObjectId[] obj = new ObjectId[selectionset.Count];
204
+                obj = selectionset.GetObjectIds();
205
+                for (int i = 0; i < obj.Length; i++)
206
+                {
207
+                    ObjectId objid = obj[i];
208
+                    DocumentLock doclock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
209
+                    using (Transaction tr = db.TransactionManager.StartTransaction())
210
+                    {
211
+                        Entity ent = (Entity)tr.GetObject(objid, OpenMode.ForRead);
212
+                        if(ent is Polyline)
213
+                        {
214
+                            Polyline pl = (Polyline)ent;
215
+                            result.Add(pl);
216
+                            tr.Commit();
217
+                        }
218
+                    }
219
+                    doclock.Dispose();
220
+                }
221
+            }
222
+            return result;
223
+        }
224
+
225
+        //检查是否有点线矛盾
226
+        private bool IfContradition(List<Polyline> pllist, Point3d pt, double length)
227
+        {
228
+            var result = new List<List<IntersectionResult>>();
229
+
230
+            // 计算平移向量(以pt为基准,移动至原点)
231
+            Vector3d translation = -pt.GetAsVector();
232
+            Matrix3d translateMatrix = Matrix3d.Displacement(translation);
233
+            var pt_moved = pt.TransformBy(translateMatrix);
234
+
235
+            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));
236
+            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));
237
+
238
+
239
+            var horizontal = new List<IntersectionResult>();
240
+            var vertical = new List<IntersectionResult>();
241
+
242
+            foreach (var item in pllist)
243
+            {
244
+                //创建临时副本用于移动等高线,以便进行无误差的相交判断
245
+                Polyline temppl = (Polyline)item.Clone();
246
+
247
+                //应用平移变换
248
+                temppl.TransformBy(translateMatrix);
249
+
250
+                Point3dCollection horizontal_pt = new Point3dCollection();
251
+                Point3dCollection vertical_pt = new Point3dCollection();
252
+                var plane = new Plane(Point3d.Origin, Vector3d.ZAxis);
253
+                temppl.IntersectWith(searchline1, Intersect.OnBothOperands, plane, horizontal_pt, IntPtr.Zero, IntPtr.Zero);
254
+                temppl.IntersectWith(searchline2, Intersect.OnBothOperands, plane, vertical_pt, IntPtr.Zero, IntPtr.Zero);
255
+
256
+                Matrix3d inverseMatrix = Matrix3d.Displacement(-translation);
257
+                var horizontal_pt_transformed = new List<Point3d>();
258
+                var vertical_pt_transformed = new List<Point3d>();
259
+                if (horizontal_pt.Count != 0)
260
+                {
261
+                    foreach (Point3d ptitem in horizontal_pt)
262
+                        horizontal_pt_transformed.Add(ptitem.TransformBy(inverseMatrix));
263
+                    horizontal.Add(new IntersectionResult { IntersectionPoint = horizontal_pt_transformed, Contour = item });
264
+                }
265
+                if (vertical_pt.Count != 0)
266
+                {
267
+                    foreach (Point3d ptitem in vertical_pt)
268
+                        vertical_pt_transformed.Add(ptitem.TransformBy(inverseMatrix));
269
+                    vertical.Add(new IntersectionResult { IntersectionPoint = vertical_pt_transformed, Contour = item });
270
+                }
271
+            }
272
+            //根据高程点值判断高程点两边应有的等高线高程值
273
+            var ele1 = Math.Floor(pt.Z / dgj) * dgj;
274
+            var ele2 = ele1 + dgj;
275
+            if (ele1 == pt.Z)
276
+                return true;
277
+            Database db = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Database;
278
+            //搜索是否有相应高程的等高线
279
+            bool hastarget_horizontal = horizontal.Any(item => Math.Round(item.Contour.Elevation - ele1, db.Luprec) == 0) &&
280
+                                        horizontal.Any(item => Math.Round(item.Contour.Elevation - ele2, db.Luprec) == 0);
281
+            bool hastarget_vertical = vertical.Any(item => Math.Round(item.Contour.Elevation - ele1, db.Luprec) == 0) &&
282
+                                      vertical.Any(item => Math.Round(item.Contour.Elevation - ele2, db.Luprec) == 0);
283
+
284
+            //如果有,则判断高程点是否在两线之间,
285
+            //没有的话再判断高程点是否是根据等高线变化趋势变化
286
+            //if (hastarget_horizontal)
287
+            //{
288
+            //    var pl1 = horizontal.FindAll(item => Math.Round(item.Contour.Elevation - ele1, db.Luprec) == 0).ToList();
289
+            //    var pl2 = horizontal.FindAll(item => Math.Round(item.Contour.Elevation - ele2, db.Luprec) == 0).ToList();
290
+            //    for (int i = 0; i < pl1.Count; i++)
291
+            //    {
292
+            //        Vector3d vec1;
293
+            //        foreach (Point3d item1 in pl1[i].IntersectionPoint)
294
+            //        {
295
+            //            vec1 = (pt - item1).GetNormal();
296
+            //            for (int ii = 0; ii < pl2.Count; ii++)
297
+            //            {
298
+            //                foreach (Point3d item2 in pl2[ii].IntersectionPoint)
299
+            //                {
300
+            //                    var dot = (pt - item2).GetNormal().DotProduct(vec1);
301
+            //                    if (dot <= 0)
302
+            //                        return false;
303
+            //                }
304
+            //            }
305
+            //        }
306
+            //    }
307
+            //}
308
+            //if (hastarget_vertical)
309
+            //{
310
+            //    var pl1 = vertical.FindAll(item => Math.Round(item.Contour.Elevation - ele1, db.Luprec) == 0).ToList();
311
+            //    var pl2 = vertical.FindAll(item => Math.Round(item.Contour.Elevation - ele2, db.Luprec) == 0).ToList();
312
+            //    for (int i = 0; i < pl1.Count; i++)
313
+            //    {
314
+            //        Vector3d vec1;
315
+            //        foreach (Point3d item1 in pl1[i].IntersectionPoint)
316
+            //        {
317
+            //            vec1 = (pt - item1).GetNormal();
318
+            //            for (int ii = 0; ii < pl2.Count; ii++)
319
+            //            {
320
+            //                foreach (Point3d item2 in pl2[ii].IntersectionPoint)
321
+            //                {
322
+            //                    var dot = (pt - item2).GetNormal().DotProduct(vec1);
323
+            //                    if (dot <= 0)
324
+            //                        return false;
325
+            //                }
326
+            //            }
327
+            //        }
328
+            //    }
329
+            //}
330
+            //else
331
+            //{
332
+                return CheckPl(horizontal, vertical, pt);
333
+                //只有对应方向上的多段线数量足以判断方向才进行下一步
334
+                //if (horizontal.Count >= 2)
335
+                //{
336
+                //    //将高程点左右的线分开,分别放到两个list
337
+                //    var side1 = new List<Point3d>();
338
+                //    var side2 = new List<Point3d>();
339
+                //    foreach (var item in horizontal)
340
+                //    {
341
+                //        foreach (var p in item.IntersectionPoint)
342
+                //        {
343
+                //            if (Math.Sign(pt.X - p.X) > 0 & !side1.Contains(p) && !side2.Contains(p))
344
+                //                side1.Add(p);
345
+                //            else if (Math.Sign(pt.X - p.X) < 0 & !side1.Contains(p) && !side2.Contains(p))
346
+                //                side2.Add(p);
347
+                //            else
348
+                //                continue;
349
+                //        }
350
+                //    }
351
+                //    //如果左右各有一条等高线,由于左右的等高线高程不是需要的高程所以为异常点
352
+                //    if (side1.Count == 1 && side2.Count == 1)
353
+                //        return true;
354
+                //    var largerList = side1.Count >= side2.Count ? side1 : side2;
355
+                //    var pts_sorted = largerList.OrderBy(p => p.DistanceTo(pt));
356
+                //    Point3d point = new Point3d();
357
+                //    Polyline pl = new Polyline();
358
+                //    foreach (var item in pts_sorted)
359
+                //    {
360
+                //        //if (point == new Point3d())
361
+                //        //{
362
+                //        //    point = item;
363
+                //        //    pl = horizontal.Find(p => p.IntersectionPoint.Contains(item)).Contour;
364
+                //        //    if (Math.Abs(pt.Z - pl.Elevation) > dgj)
365
+                //        //        return true;
366
+                //        //}
367
+                //        //else
368
+                //        //{
369
+                //        point = item;
370
+                //        //如果下一个点所在多段线不是这个点所在的多段线且高程不同,判断高程点变化方向是否一致
371
+                //        if (horizontal.Find(p => p.IntersectionPoint.Contains(item)).Contour != pl &&
372
+                //                horizontal.Find(p => p.IntersectionPoint.Contains(item)).Contour.Elevation != pl.Elevation)
373
+                //            {
374
+                //                var direction = point.Z - item.Z;
375
+                //                if (pt.Z - point.Z < 0 && direction < 0 ||
376
+                //                    pt.Z - point.Z > 0 && direction > 0)
377
+                //                    return false;
378
+                //            }
379
+                //            //else
380
+                //                //point = item;
381
+                //        //}
382
+                //    }
383
+                //}
384
+                //if (vertical.Count >= 2)
385
+                //{
386
+                //    List<Point3d> pts = new List<Point3d>();
387
+                //    var side1 = new List<Point3d>();
388
+                //    var side2 = new List<Point3d>();
389
+                //    foreach (var item in vertical)
390
+                //    {
391
+                //        foreach (var p in item.IntersectionPoint)
392
+                //        {
393
+                //            if (Math.Sign(pt.Y - p.Y) > 0 & !side1.Contains(p) && !side2.Contains(p))
394
+                //                side1.Add(p);
395
+                //            else if (Math.Sign(pt.Y - p.Y) < 0 & !side1.Contains(p) && !side2.Contains(p))
396
+                //                side2.Add(p);
397
+                //            else
398
+                //                continue;
399
+                //        }
400
+                //    }
401
+                //    if (side1.Count == 1 && side2.Count == 1)
402
+                //        return true;
403
+                //    var largerList = side1.Count >= side2.Count ? side1 : side2;
404
+                //    var pts_sorted = largerList.OrderBy(p => p.DistanceTo(pt));
405
+                //    Point3d point = new Point3d();
406
+                //    Polyline pl = new Polyline();
407
+                //    foreach (var item in pts_sorted)
408
+                //    {
409
+                //        //if (point == new Point3d())
410
+                //        //{
411
+                //        //    point = item;
412
+                //        //    pl = vertical.Find(p => p.IntersectionPoint.Contains(item)).Contour;
413
+                //        //    if (Math.Abs(pt.Z - pl.Elevation) > dgj)
414
+                //        //        return true;
415
+                //        //}
416
+                //        //else
417
+                //        //{
418
+                //        point = item;
419
+                //        if (vertical.Find(p => p.IntersectionPoint.Contains(item)).Contour != pl)
420
+                //            {
421
+                //                var direction = point.Z - item.Z;
422
+                //                if (pt.Z - point.Z < 0 && direction < 0 ||
423
+                //                    pt.Z - point.Z > 0 && direction > 0)
424
+                //                    return false;
425
+                //            }
426
+                //            //else
427
+                //                //point = item;
428
+                //        //}
429
+                //    }
430
+                //}
431
+            //}
432
+            //return true;
433
+        }
434
+
435
+        //标记错误点
436
+        private void MakeFlag(Point3d pt,int blc)
437
+        {
438
+            double flagradius = 4.0 * blc / 1000;//根据比例尺画圆标记半径
439
+
440
+            LayerControl layerscontrol = new LayerControl();
441
+            string layname = "点线矛盾标记图层";
442
+            if (layerscontrol.haslayername(layname) == false)
443
+            {
444
+                colorgb col = new colorgb(255, 0, 0);
445
+                layerscontrol.creatlayer(layname, col);
446
+            }
447
+            layname = "点线矛盾高程点图层";
448
+            if (layerscontrol.haslayername(layname) == false)
449
+            {
450
+                colorgb col = new colorgb(255, 255, 0);
451
+                layerscontrol.creatlayer(layname, col);
452
+                layerscontrol.movelayertofront(layname);
453
+            }
454
+
455
+            Database db = HostApplicationServices.WorkingDatabase;
456
+            DocumentLock doclock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
457
+            using (Transaction traction = db.TransactionManager.StartTransaction())
458
+            { 
459
+                BlockTable blocktable= traction.GetObject(db.BlockTableId, OpenMode.ForWrite) as BlockTable;
460
+                BlockTableRecord blocktablerecord = traction.GetObject(blocktable[BlockTableRecord.ModelSpace],
461
+                                                OpenMode.ForWrite) as BlockTableRecord;
462
+                Circle circ = new Circle();
463
+                circ.Layer = "点线矛盾标记图层";
464
+
465
+                circ.Center = pt;
466
+                circ.Radius = flagradius;
467
+                circ.Normal = new Vector3d(0, 0, 1);
468
+                circ.SetDatabaseDefaults();
469
+                blocktablerecord.AppendEntity(circ);
470
+                traction.AddNewlyCreatedDBObject(circ, true);
471
+                traction.Commit();
472
+            
473
+                traction.Dispose();
474
+            }
475
+            doclock.Dispose();
476
+        }
477
+
478
+        private bool CheckPl(List<IntersectionResult> horizontal, List<IntersectionResult> vertical, Point3d pt)
479
+        {
480
+            bool constradition = true;
481
+            bool isclosed = false;
482
+            bool isridge = false;
483
+            if (horizontal.Count >= 2)
484
+            {
485
+                //将高程点左右的线分开,分别放到两个list
486
+                var side1 = new List<Point3d>();
487
+                var side2 = new List<Point3d>();
488
+                foreach (var item in horizontal)
489
+                {
490
+                    int side1count = 0;
491
+                    int side2count = 0;
492
+                    foreach (var p in item.IntersectionPoint)
493
+                    {
494
+                        if (Math.Sign(pt.X - p.X) > 0 & !side1.Contains(p) && !side2.Contains(p)&& side1count==0)
495
+                        {
496
+                            side1.Add(p);
497
+                            side1count = 1;
498
+                        }
499
+                        else if (Math.Sign(pt.X - p.X) < 0 & !side1.Contains(p) && !side2.Contains(p)&& side2count==0)
500
+                        { 
501
+                            side2.Add(p);
502
+                            side2count = 1;
503
+                        }
504
+                        else
505
+                            continue;
506
+                    }
507
+                }
508
+                var pl1 = new Polyline();
509
+                var pl2 = new Polyline();
510
+                if (side1.Count != 0 && side2.Count != 0)
511
+                {
512
+                    var pts_sorted1 = side1.OrderBy(p => p.DistanceTo(pt)).ToList();
513
+                    var pts_sorted2 = side2.OrderBy(p => p.DistanceTo(pt)).ToList();
514
+                    pl1 = horizontal.Find(p => p.IntersectionPoint.Contains(pts_sorted1[0])).Contour;
515
+                    pl2 = horizontal.Find(p => p.IntersectionPoint.Contains(pts_sorted2[0])).Contour;
516
+                    if (pl1 != pl2)
517
+                    {
518
+                        if (pl1.Elevation < pt.Z && pt.Z < pl2.Elevation ||
519
+                           pl2.Elevation < pt.Z && pt.Z < pl1.Elevation)
520
+                            constradition = false;
521
+                        else if (pl1.Elevation == pl2.Elevation)
522
+                        {
523
+                            isridge = true;
524
+                            foreach (var item1 in pts_sorted1)
525
+                            {
526
+                                var pl3 = horizontal.Find(p => p.IntersectionPoint.Contains(item1)).Contour;
527
+                                if (pl3 != pl1)
528
+                                {
529
+                                    if (pl3.Elevation < pl1.Elevation && pl1.Elevation < pt.Z ||
530
+                                        pl3.Elevation > pl1.Elevation && pl1.Elevation > pt.Z)
531
+                                    {
532
+                                        foreach (var item2 in pts_sorted2)
533
+                                        {
534
+                                            var pl4 = horizontal.Find(p => p.IntersectionPoint.Contains(item2)).Contour;
535
+                                            if (pl4 != pl2)
536
+                                            {
537
+                                                if (pl4.Elevation < pl2.Elevation && pl2.Elevation < pt.Z ||
538
+                                                    pl4.Elevation > pl2.Elevation && pl2.Elevation > pt.Z)
539
+                                                {
540
+                                                    constradition = false;
541
+                                                    break;
542
+                                                }
543
+                                            }
544
+                                        }
545
+                                        break;
546
+                                    }
547
+                                }
548
+                            }
549
+                            
550
+                        }
551
+                        else
552
+                            constradition = true;
553
+                    }
554
+                    else
555
+                        isclosed = true;
556
+                }
557
+                if (side1.Count != 0 && side2.Count == 0 || isclosed && side1.Count >= 2)
558
+                {
559
+                    var pts_sorted1 = side1.OrderBy(p => p.DistanceTo(pt)).ToList();
560
+                    pl1 = horizontal.Find(p => p.IntersectionPoint.Contains(pts_sorted1[0])).Contour;
561
+                    foreach (var item in pts_sorted1)
562
+                    {
563
+                        pl2 = horizontal.Find(p => p.IntersectionPoint.Contains(item)).Contour;
564
+                        if (pl2 != pl1)
565
+                            break;
566
+                    }
567
+                }
568
+                else if (side1.Count == 0 && side2.Count != 0 || isclosed && side2.Count >= 2)
569
+                {
570
+                    var pts_sorted2 = side2.OrderBy(p => p.DistanceTo(pt)).ToList();
571
+                    pl1 = horizontal.Find(p => p.IntersectionPoint.Contains(pts_sorted2[0])).Contour;
572
+                    foreach (var item in pts_sorted2)
573
+                    {
574
+                        pl2 = horizontal.Find(p => p.IntersectionPoint.Contains(item)).Contour;
575
+                        if (pl2 != pl1)
576
+                            break;
577
+                    }
578
+                }
579
+                if (pl1 != pl2 && side1.Count == 0|| pl1 != pl2 && side2.Count == 0|| pl1 != pl2 && isclosed)
580
+                {
581
+                    if (pl2.Elevation < pl1.Elevation && pl1.Elevation < pt.Z ||
582
+                        pl2.Elevation > pl1.Elevation && pl1.Elevation > pt.Z)
583
+                        constradition =  false;
584
+                    else
585
+                        constradition =  true;
586
+                }
587
+            }
588
+            if (vertical.Count >= 2 && constradition == true||isridge==true&& vertical.Count >= 2)
589
+            {
590
+                isclosed = false;
591
+                //将高程点左右的线分开,分别放到两个list
592
+                var side1 = new List<Point3d>();
593
+                var side2 = new List<Point3d>();
594
+                foreach (var item in vertical)
595
+                {
596
+                    foreach (var p in item.IntersectionPoint)
597
+                    {
598
+                        if (Math.Sign(pt.Y - p.Y) > 0 & !side1.Contains(p) && !side2.Contains(p))
599
+                            side1.Add(p);
600
+                        else if (Math.Sign(pt.Y - p.Y) < 0 & !side1.Contains(p) && !side2.Contains(p))
601
+                            side2.Add(p);
602
+                        else
603
+                            continue;
604
+                    }
605
+                }
606
+                var pl1 = new Polyline();
607
+                var pl2 = new Polyline();
608
+                if (side1.Count != 0 && side2.Count != 0)
609
+                {
610
+                    var pts_sorted1 = side1.OrderBy(p => p.DistanceTo(pt)).ToList();
611
+                    var pts_sorted2 = side2.OrderBy(p => p.DistanceTo(pt)).ToList();
612
+                    pl1 = vertical.Find(p => p.IntersectionPoint.Contains(pts_sorted1[0])).Contour;
613
+                    pl2 = vertical.Find(p => p.IntersectionPoint.Contains(pts_sorted2[0])).Contour;
614
+                    if (pl1 != pl2)
615
+                    {
616
+                        if (pl1.Elevation < pt.Z && pt.Z < pl2.Elevation ||
617
+                           pl2.Elevation < pt.Z && pt.Z < pl1.Elevation)
618
+                            constradition = false;
619
+                        else
620
+                            constradition = true;
621
+                    }
622
+                    else if (pl1.Elevation == pl2.Elevation)
623
+                    {
624
+                        isridge = true;
625
+                        foreach (var item1 in pts_sorted1)
626
+                        {
627
+                            var pl3 = vertical.Find(p => p.IntersectionPoint.Contains(item1)).Contour;
628
+                            if (pl3 != pl1)
629
+                            {
630
+                                if (pl3.Elevation < pl1.Elevation && pl1.Elevation < pt.Z ||
631
+                                    pl3.Elevation > pl1.Elevation && pl1.Elevation > pt.Z)
632
+                                {
633
+                                    foreach (var item2 in pts_sorted2)
634
+                                    {
635
+                                        var pl4 = vertical.Find(p => p.IntersectionPoint.Contains(item2)).Contour;
636
+                                        if (pl4 != pl2)
637
+                                        {
638
+                                            if (pl4.Elevation < pl2.Elevation && pl2.Elevation < pt.Z ||
639
+                                                pl4.Elevation > pl2.Elevation && pl2.Elevation > pt.Z)
640
+                                            {
641
+                                                constradition = false;
642
+                                                break;
643
+                                            }
644
+                                        }
645
+                                    }
646
+                                    break;
647
+                                }
648
+                            }
649
+                        }
650
+
651
+                    }
652
+                    else
653
+                        isclosed = true;
654
+                }
655
+                if (side1.Count != 0 && side2.Count == 0 || isclosed && side1.Count >= 2)
656
+                {
657
+                    var pts_sorted1 = side1.OrderBy(p => p.DistanceTo(pt)).ToList();
658
+                    pl1 = vertical.Find(p => p.IntersectionPoint.Contains(pts_sorted1[0])).Contour;
659
+                    foreach (var item in pts_sorted1)
660
+                    {
661
+                        pl2 = vertical.Find(p => p.IntersectionPoint.Contains(item)).Contour;
662
+                        if (pl2 != pl1)
663
+                            break;
664
+                    }
665
+                }
666
+                else if (side1.Count == 0 && side2.Count != 0 || isclosed && side2.Count >= 2)
667
+                {
668
+                    var pts_sorted2 = side2.OrderBy(p => p.DistanceTo(pt)).ToList();
669
+                    pl1 = vertical.Find(p => p.IntersectionPoint.Contains(pts_sorted2[0])).Contour;
670
+                    foreach (var item in pts_sorted2)
671
+                    {
672
+                        pl2 = vertical.Find(p => p.IntersectionPoint.Contains(item)).Contour;
673
+                        if (pl2 != pl1)
674
+                            break;
675
+                    }
676
+                }
677
+                if (pl1 != pl2 && side1.Count == 0 || pl1 != pl2 && side2.Count == 0 || pl1 != pl2 && isclosed)
678
+                {
679
+                    if (pl2.Elevation < pl1.Elevation && pl1.Elevation < pt.Z ||
680
+                       pl2.Elevation > pl1.Elevation && pl1.Elevation > pt.Z)
681
+                        constradition = false;
682
+                    else
683
+                        constradition = true;
684
+                }
685
+            }
686
+            return constradition;
687
+        }
688
+    }
689
+}

+ 1100
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/ChPLContradiction.cs
文件差异内容过多而无法显示
查看文件


+ 169
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/Chaginfos.Designer.cs 查看文件

@@ -0,0 +1,169 @@
1
+
2
+namespace CADTools
3
+{
4
+    partial class Chaginfos
5
+    {
6
+        /// <summary>
7
+        /// Required designer variable.
8
+        /// </summary>
9
+        private System.ComponentModel.IContainer components = null;
10
+
11
+        /// <summary>
12
+        /// Clean up any resources being used.
13
+        /// </summary>
14
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
15
+        protected override void Dispose(bool disposing)
16
+        {
17
+            if (disposing && (components != null))
18
+            {
19
+                components.Dispose();
20
+            }
21
+            base.Dispose(disposing);
22
+        }
23
+
24
+        #region Windows Form Designer generated code
25
+
26
+        /// <summary>
27
+        /// Required method for Designer support - do not modify
28
+        /// the contents of this method with the code editor.
29
+        /// </summary>
30
+        private void InitializeComponent()
31
+        {
32
+            this.btn_BrowseSave = new System.Windows.Forms.Button();
33
+            this.btn_BrowseNdupdate = new System.Windows.Forms.Button();
34
+            this.label_Save = new System.Windows.Forms.Label();
35
+            this.label_Update = new System.Windows.Forms.Label();
36
+            this.txtbox_SaveLocation = new System.Windows.Forms.TextBox();
37
+            this.txtbox_nDupdateLocation = new System.Windows.Forms.TextBox();
38
+            this.dataGridView_Update = new System.Windows.Forms.DataGridView();
39
+            this.btn_Update = new System.Windows.Forms.Button();
40
+            this.label1 = new System.Windows.Forms.Label();
41
+            this.textBox1_layer = new System.Windows.Forms.TextBox();
42
+            ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Update)).BeginInit();
43
+            this.SuspendLayout();
44
+            // 
45
+            // btn_BrowseSave
46
+            // 
47
+            this.btn_BrowseSave.Location = new System.Drawing.Point(494, 90);
48
+            this.btn_BrowseSave.Name = "btn_BrowseSave";
49
+            this.btn_BrowseSave.Size = new System.Drawing.Size(47, 30);
50
+            this.btn_BrowseSave.TabIndex = 18;
51
+            this.btn_BrowseSave.Text = "浏览";
52
+            this.btn_BrowseSave.UseVisualStyleBackColor = true;
53
+            this.btn_BrowseSave.Click += new System.EventHandler(this.btn_BrowseSave_Click);
54
+            // 
55
+            // btn_BrowseNdupdate
56
+            // 
57
+            this.btn_BrowseNdupdate.Location = new System.Drawing.Point(494, 38);
58
+            this.btn_BrowseNdupdate.Name = "btn_BrowseNdupdate";
59
+            this.btn_BrowseNdupdate.Size = new System.Drawing.Size(47, 29);
60
+            this.btn_BrowseNdupdate.TabIndex = 17;
61
+            this.btn_BrowseNdupdate.Text = "浏览";
62
+            this.btn_BrowseNdupdate.UseVisualStyleBackColor = true;
63
+            this.btn_BrowseNdupdate.Click += new System.EventHandler(this.btn_BrowseNdupdate_Click);
64
+            // 
65
+            // label_Save
66
+            // 
67
+            this.label_Save.AutoSize = true;
68
+            this.label_Save.Location = new System.Drawing.Point(74, 98);
69
+            this.label_Save.Name = "label_Save";
70
+            this.label_Save.Size = new System.Drawing.Size(82, 15);
71
+            this.label_Save.TabIndex = 16;
72
+            this.label_Save.Text = "保存路径:";
73
+            // 
74
+            // label_Update
75
+            // 
76
+            this.label_Update.Location = new System.Drawing.Point(74, 29);
77
+            this.label_Update.Name = "label_Update";
78
+            this.label_Update.Size = new System.Drawing.Size(77, 55);
79
+            this.label_Update.TabIndex = 15;
80
+            this.label_Update.Text = "需修改的文件所在路径:";
81
+            // 
82
+            // txtbox_SaveLocation
83
+            // 
84
+            this.txtbox_SaveLocation.Location = new System.Drawing.Point(157, 95);
85
+            this.txtbox_SaveLocation.Name = "txtbox_SaveLocation";
86
+            this.txtbox_SaveLocation.Size = new System.Drawing.Size(319, 25);
87
+            this.txtbox_SaveLocation.TabIndex = 14;
88
+            // 
89
+            // txtbox_nDupdateLocation
90
+            // 
91
+            this.txtbox_nDupdateLocation.Location = new System.Drawing.Point(157, 41);
92
+            this.txtbox_nDupdateLocation.Name = "txtbox_nDupdateLocation";
93
+            this.txtbox_nDupdateLocation.Size = new System.Drawing.Size(319, 25);
94
+            this.txtbox_nDupdateLocation.TabIndex = 13;
95
+            // 
96
+            // dataGridView_Update
97
+            // 
98
+            this.dataGridView_Update.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
99
+            this.dataGridView_Update.Location = new System.Drawing.Point(77, 197);
100
+            this.dataGridView_Update.Margin = new System.Windows.Forms.Padding(4);
101
+            this.dataGridView_Update.Name = "dataGridView_Update";
102
+            this.dataGridView_Update.RowHeadersWidth = 51;
103
+            this.dataGridView_Update.RowTemplate.Height = 23;
104
+            this.dataGridView_Update.Size = new System.Drawing.Size(473, 195);
105
+            this.dataGridView_Update.TabIndex = 12;
106
+            // 
107
+            // btn_Update
108
+            // 
109
+            this.btn_Update.Location = new System.Drawing.Point(252, 411);
110
+            this.btn_Update.Name = "btn_Update";
111
+            this.btn_Update.Size = new System.Drawing.Size(89, 31);
112
+            this.btn_Update.TabIndex = 19;
113
+            this.btn_Update.Text = "确定更新";
114
+            this.btn_Update.UseVisualStyleBackColor = true;
115
+            this.btn_Update.Click += new System.EventHandler(this.btn_Update_Click);
116
+            // 
117
+            // label1
118
+            // 
119
+            this.label1.Location = new System.Drawing.Point(74, 138);
120
+            this.label1.Name = "label1";
121
+            this.label1.Size = new System.Drawing.Size(77, 55);
122
+            this.label1.TabIndex = 20;
123
+            this.label1.Text = "待修改信息所在图层:";
124
+            // 
125
+            // textBox1_layer
126
+            // 
127
+            this.textBox1_layer.Location = new System.Drawing.Point(158, 156);
128
+            this.textBox1_layer.Name = "textBox1_layer";
129
+            this.textBox1_layer.Size = new System.Drawing.Size(123, 25);
130
+            this.textBox1_layer.TabIndex = 21;
131
+            // 
132
+            // Chaginfos
133
+            // 
134
+            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
135
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
136
+            this.ClientSize = new System.Drawing.Size(624, 466);
137
+            this.Controls.Add(this.textBox1_layer);
138
+            this.Controls.Add(this.label1);
139
+            this.Controls.Add(this.btn_Update);
140
+            this.Controls.Add(this.btn_BrowseSave);
141
+            this.Controls.Add(this.btn_BrowseNdupdate);
142
+            this.Controls.Add(this.label_Save);
143
+            this.Controls.Add(this.label_Update);
144
+            this.Controls.Add(this.txtbox_SaveLocation);
145
+            this.Controls.Add(this.txtbox_nDupdateLocation);
146
+            this.Controls.Add(this.dataGridView_Update);
147
+            this.Name = "Chaginfos";
148
+            this.Text = "批量修改图框信息";
149
+            this.Load += new System.EventHandler(this.Chaginfos_Load);
150
+            ((System.ComponentModel.ISupportInitialize)(this.dataGridView_Update)).EndInit();
151
+            this.ResumeLayout(false);
152
+            this.PerformLayout();
153
+
154
+        }
155
+
156
+        #endregion
157
+
158
+        private System.Windows.Forms.Button btn_BrowseSave;
159
+        private System.Windows.Forms.Button btn_BrowseNdupdate;
160
+        private System.Windows.Forms.Label label_Save;
161
+        private System.Windows.Forms.Label label_Update;
162
+        private System.Windows.Forms.TextBox txtbox_SaveLocation;
163
+        private System.Windows.Forms.TextBox txtbox_nDupdateLocation;
164
+        private System.Windows.Forms.DataGridView dataGridView_Update;
165
+        private System.Windows.Forms.Button btn_Update;
166
+        private System.Windows.Forms.Label label1;
167
+        private System.Windows.Forms.TextBox textBox1_layer;
168
+    }
169
+}

+ 350
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/Chaginfos.cs 查看文件

@@ -0,0 +1,350 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.ComponentModel;
4
+using System.Data;
5
+using System.Drawing;
6
+using System.Linq;
7
+using System.Text;
8
+using System.Threading.Tasks;
9
+using System.Windows.Forms;
10
+
11
+using Autodesk.AutoCAD.EditorInput;
12
+using Autodesk.AutoCAD.DatabaseServices;
13
+using Autodesk.AutoCAD.Geometry;
14
+using System.IO;
15
+using Autodesk.AutoCAD.ApplicationServices;
16
+
17
+namespace CADTools
18
+{
19
+    public partial class Chaginfos : Form
20
+    {
21
+        public Chaginfos()
22
+        {
23
+            InitializeComponent();
24
+        }
25
+
26
+        public struct record
27
+        {
28
+            public string original;
29
+            public string now;
30
+            public double distance;
31
+
32
+            public record(string original, string now, double distance)
33
+            {
34
+                this.original = original;
35
+                this.now = now;
36
+                this.distance = distance;
37
+            }
38
+        }
39
+
40
+        private void Chaginfos_Load(object sender, EventArgs e)
41
+        {
42
+            dataGridView_Update.ColumnCount = 3;
43
+            dataGridView_Update.Columns[0].HeaderText = "原始内容";
44
+            dataGridView_Update.Columns[1].HeaderText = "修改内容";
45
+            dataGridView_Update.Columns[2].HeaderText = "平移距离";
46
+
47
+            dataGridView_Update.RowHeadersVisible = false;
48
+            dataGridView_Update.AllowUserToResizeRows = false;
49
+
50
+            dataGridView_Update.Columns[0].Width = 181;
51
+            dataGridView_Update.Columns[1].Width = 181;
52
+            dataGridView_Update.Columns[2].Width = 100;
53
+
54
+            dataGridView_Update.Columns[0].SortMode = DataGridViewColumnSortMode.NotSortable;
55
+            dataGridView_Update.Columns[1].SortMode = DataGridViewColumnSortMode.NotSortable;
56
+            dataGridView_Update.Columns[2].SortMode = DataGridViewColumnSortMode.NotSortable;
57
+
58
+            Database database = Autodesk.AutoCAD.DatabaseServices.HostApplicationServices.WorkingDatabase;
59
+            using (Transaction traction = database.TransactionManager.StartTransaction())
60
+            {
61
+                //存放所有图层名
62
+                List<string> alllayername = new List<string>();
63
+                LayerTable layertable = traction.GetObject(database.LayerTableId, OpenMode.ForRead) as LayerTable;
64
+                foreach (ObjectId objid in layertable)
65
+                {
66
+                    LayerTableRecord layertablerecord = traction.GetObject(objid, OpenMode.ForRead) as LayerTableRecord;
67
+                    alllayername.Add(layertablerecord.Name);
68
+                }
69
+                alllayername.Sort();
70
+
71
+            }
72
+        }
73
+
74
+
75
+        List<record> list = new List<record>();
76
+        private void btn_Update_Click(object sender, EventArgs e)
77
+        {
78
+            list.Clear();
79
+            int j = 0;
80
+            string layer = textBox1_layer.Text.Trim();
81
+            path_Open = txtbox_nDupdateLocation.Text;
82
+            path_Save = txtbox_SaveLocation.Text;
83
+            if (path_Open == "" || path_Save == "")
84
+            {
85
+                MessageBox.Show("需修改的文件所在路径或保存路径为空!", "提示");
86
+                return;
87
+            }
88
+
89
+            //Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
90
+            dataGridView_Update.ReadOnly = true;
91
+            for (int i = 0; i < dataGridView_Update.Rows.Count; i++)
92
+            {
93
+                string original = "";
94
+                string now = "";
95
+                string str = "";
96
+                double distance = 0;
97
+
98
+                object obj0 = dataGridView_Update[0, i].Value;
99
+                if (obj0 != null)
100
+                {
101
+                    original = obj0.ToString();
102
+                }
103
+                object obj1 = dataGridView_Update[1, i].Value;
104
+
105
+                if (obj1 != null)
106
+                {
107
+                    now = obj1.ToString();
108
+                }
109
+                object obj2 = dataGridView_Update[2, i].Value;
110
+
111
+                if (obj2 != null)
112
+                {
113
+                    str = obj2.ToString();
114
+                }
115
+
116
+                if (string.IsNullOrEmpty(str) == false)
117
+                {
118
+                    distance = Convert.ToDouble(str.ToString());
119
+                }
120
+
121
+                list.Add(new record(original, now, distance));
122
+            }
123
+            dataGridView_Update.ReadOnly = false;
124
+
125
+            //记录删除记录
126
+            List<string> delete = new List<string>();
127
+
128
+            string[] file = Directory.GetFiles(path_Open);
129
+            for (int i = 0; i < file.Length; i++)
130
+            {
131
+                string paths = file[i];
132
+                string name = System.IO.Path.GetFileName(paths);
133
+
134
+                if (name.Contains(".dwg") == false)
135
+                {
136
+                    continue;
137
+                }
138
+
139
+                Database data = new Database(false, true);
140
+                data.ReadDwgFile(paths, FileShare.Read, true, null);
141
+                data.CloseInput(true);
142
+
143
+
144
+                //记录附注起始坐标
145
+                //Point3d position = new Point3d();
146
+
147
+
148
+                delete.Clear();
149
+
150
+                using (Transaction trans = data.TransactionManager.StartTransaction())
151
+                {
152
+                    BlockTable bt = (BlockTable)trans.GetObject(data.BlockTableId, OpenMode.ForWrite);
153
+                    BlockTableRecord btr = (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
154
+
155
+
156
+                    LayerTable lt = trans.GetObject(data.LayerTableId, OpenMode.ForRead) as LayerTable;
157
+                    LayerTableRecord ltr = trans.GetObject(lt[layer], OpenMode.ForRead) as LayerTableRecord;
158
+                    ObjectId LayerID = ltr.ObjectId;
159
+
160
+                    foreach (ObjectId id in btr)
161
+                    {
162
+                        Entity ent = trans.GetObject(id, OpenMode.ForWrite) as Entity;
163
+                        if (ent != null)
164
+                        {
165
+                            if (ent.GetType().ToString() == "Autodesk.AutoCAD.DatabaseServices.DBText" && ent.LayerId == LayerID)
166
+                            {
167
+
168
+                                DBText T = ent as DBText;
169
+                                string str = T.TextString.Trim();
170
+
171
+                                //if (str.Contains("投影方式") && T.LayerId == LayerID)
172
+                                //{
173
+                                //    position = T.Position;
174
+                                //}
175
+
176
+                                //if (str.Contains("测图员") || str.Contains("数化员") || str.Contains("检查员") || str.Contains("复查员"))
177
+                                //{
178
+                                //    if (T.LayerId == LayerID)
179
+                                //    {
180
+                                //        delete.Add(str + "\t");
181
+                                //        T.Erase(true);
182
+                                //        //continue;
183
+                                //    }
184
+
185
+                                //}
186
+
187
+                                for (int k = 0; k < list.Count; k++)
188
+                                {
189
+                                    if (str == list[k].original.Trim())
190
+                                    {
191
+
192
+                                        if (string.IsNullOrEmpty(list[k].now) == true)
193
+                                        {
194
+                                            if (T.LayerId == LayerID)
195
+                                            {
196
+                                                j++;
197
+                                                delete.Add(str + "\t");
198
+                                                T.Erase(true);
199
+                                                continue;
200
+                                            }
201
+                                        }
202
+                                        else
203
+                                        {
204
+                                            j++;
205
+                                            T.TextString = list[k].now;
206
+                                            T.Position = new Point3d(T.Position.X + list[k].distance, T.Position.Y, 0);
207
+                                        }
208
+                                    }
209
+                                }
210
+
211
+                            }
212
+
213
+                        }
214
+
215
+                    }
216
+
217
+
218
+                    //if (position != null)
219
+                    //{
220
+
221
+                    //    TextStyleTable tst = trans.GetObject(data.TextStyleTableId, OpenMode.ForRead) as TextStyleTable;
222
+                    //    TextStyleTableRecord tstr = trans.GetObject(tst["HZ"], OpenMode.ForRead) as TextStyleTableRecord;
223
+                    //    ObjectId TStyleID = tstr.ObjectId;
224
+
225
+
226
+
227
+                    //    ObjectId HZ = TStyleID;
228
+                    //    double xx = position.X;
229
+                    //    double yy = position.Y;
230
+
231
+                    //    string[] contents = new string[7];
232
+                    //    contents[0] = "SPHEROID:WGS-84 ";
233
+                    //    contents[1] = "PROJECTION:Gauss-Kruger projection;";
234
+                    //    contents[2] = "Center meridian is 104°16′; Projection elevation is 310m.";
235
+                    //    //
236
+                    //    //
237
+                    //    //
238
+                    //    contents[3] = "VERTICAL DATUM : From Mean Sea Level HONDAU(Vietnam), Contour intervals: 1 meter";
239
+                    //    contents[4] = "GB/T 20257.1-2007 Cartographic symbols for national fundamental scale maps ";
240
+                    //    //contents[4] = "GB/T 20257.2-2006 Cartographic symbols for national fundamental scale maps ";
241
+                    //    contents[5] = "Part 1: Specifications for cartographic symbols 1:500 1:1000&1:2000 topographic maps";
242
+                    //    //contents[5] = "Part 2: Specifications for cartographic symbols 1:5000&1:10000 topographic maps";
243
+                    //    contents[6] = "December 2012";
244
+
245
+                    //    for (int k = 0; k < contents.Length; k++)
246
+                    //    {
247
+                    //        DBText text1 = new DBText();
248
+                    //        text1.TextString = contents[k];
249
+                    //        text1.Position = new Point3d(xx, yy, 0);
250
+                    //        //text1.Height = 15;
251
+                    //        text1.Height = 3;
252
+                    //        text1.Color = Autodesk.AutoCAD.Colors.Color.FromColorIndex(Autodesk.AutoCAD.Colors.ColorMethod.ByColor, 4);
253
+                    //        text1.LayerId = LayerID;
254
+                    //        text1.TextStyleId = HZ;
255
+                    //        text1.WidthFactor = 0.8;
256
+
257
+                    //        text1.SetDatabaseDefaults(data);
258
+                    //        btr.AppendEntity(text1);
259
+                    //        trans.AddNewlyCreatedDBObject(text1, true);
260
+
261
+
262
+
263
+                    //        //yy = yy - 30;
264
+                    //        yy = yy - 5;
265
+                    //    }
266
+
267
+                    //}
268
+                    //else
269
+                    //{
270
+
271
+                    //}
272
+
273
+
274
+                    trans.Commit();
275
+                }
276
+
277
+                //Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
278
+                //2007版本格式
279
+                //data.SaveAs(path_Save + "\\" + name, true, DwgVersion.AC1021, doc.Database.SecurityParameters);
280
+                data.SaveAs(path_Save + "\\" + name, DwgVersion.AC1021);
281
+                //2004版本格式
282
+                //data.SaveAs(path_Save + "\\" + name, DwgVersion.AC1800);
283
+                //2000版本格式
284
+                //data.SaveAs(path_Save + "\\" + name, DwgVersion.AC1015);
285
+
286
+
287
+                data.Dispose();
288
+
289
+                //
290
+                delete.Sort();
291
+                string deleterecord = "";
292
+                foreach (var item in delete)
293
+                {
294
+                    deleterecord += item;
295
+                }
296
+
297
+                deleterecord = name + "\t" + deleterecord;
298
+                deleterecord += "\r\n";
299
+
300
+                System.IO.StreamWriter writer = new StreamWriter(path_Save+"\\改动文件.txt", true);
301
+                writer.Write(deleterecord);
302
+                writer.Dispose();
303
+            }
304
+            if (j > 0)
305
+                MessageBox.Show("修改成功!");
306
+            else
307
+                MessageBox.Show("未找到原始内容,修改失败!");
308
+            this.Close();
309
+        }
310
+
311
+
312
+        private string path_Open = "";
313
+        private void btn_BrowseNdupdate_Click(object sender, EventArgs e)
314
+        {
315
+            path_Open = "";
316
+
317
+            FolderBrowserDialog FBD = new FolderBrowserDialog();
318
+            FBD.Description = "选择需修改数据数据目录";
319
+            FBD.ShowNewFolderButton = false;
320
+            DialogResult result = FBD.ShowDialog();
321
+
322
+            if (result == DialogResult.OK)
323
+            {
324
+                path_Open = FBD.SelectedPath;
325
+            }
326
+
327
+            txtbox_nDupdateLocation.Text = path_Open;
328
+        }
329
+
330
+
331
+        string path_Save = "";
332
+        private void btn_BrowseSave_Click(object sender, EventArgs e)
333
+        {
334
+            path_Save = "";
335
+
336
+            FolderBrowserDialog FBD = new FolderBrowserDialog();
337
+            FBD.Description = "选择保存数据目录";
338
+            FBD.ShowNewFolderButton = false;
339
+            DialogResult result = FBD.ShowDialog();
340
+
341
+            if (result == DialogResult.OK)
342
+            {
343
+                path_Save = FBD.SelectedPath;
344
+            }
345
+
346
+            txtbox_SaveLocation.Text = path_Save;
347
+        }
348
+
349
+    }
350
+}

+ 120
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/Chaginfos.resx 查看文件

@@ -0,0 +1,120 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<root>
3
+  <!-- 
4
+    Microsoft ResX Schema 
5
+    
6
+    Version 2.0
7
+    
8
+    The primary goals of this format is to allow a simple XML format 
9
+    that is mostly human readable. The generation and parsing of the 
10
+    various data types are done through the TypeConverter classes 
11
+    associated with the data types.
12
+    
13
+    Example:
14
+    
15
+    ... ado.net/XML headers & schema ...
16
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
17
+    <resheader name="version">2.0</resheader>
18
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
19
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
20
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
21
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
22
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
24
+    </data>
25
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
26
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
27
+        <comment>This is a comment</comment>
28
+    </data>
29
+                
30
+    There are any number of "resheader" rows that contain simple 
31
+    name/value pairs.
32
+    
33
+    Each data row contains a name, and value. The row also contains a 
34
+    type or mimetype. Type corresponds to a .NET class that support 
35
+    text/value conversion through the TypeConverter architecture. 
36
+    Classes that don't support this are serialized and stored with the 
37
+    mimetype set.
38
+    
39
+    The mimetype is used for serialized objects, and tells the 
40
+    ResXResourceReader how to depersist the object. This is currently not 
41
+    extensible. For a given mimetype the value must be set accordingly:
42
+    
43
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
44
+    that the ResXResourceWriter will generate, however the reader can 
45
+    read any of the formats listed below.
46
+    
47
+    mimetype: application/x-microsoft.net.object.binary.base64
48
+    value   : The object must be serialized with 
49
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
50
+            : and then encoded with base64 encoding.
51
+    
52
+    mimetype: application/x-microsoft.net.object.soap.base64
53
+    value   : The object must be serialized with 
54
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
55
+            : and then encoded with base64 encoding.
56
+
57
+    mimetype: application/x-microsoft.net.object.bytearray.base64
58
+    value   : The object must be serialized into a byte array 
59
+            : using a System.ComponentModel.TypeConverter
60
+            : and then encoded with base64 encoding.
61
+    -->
62
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
64
+    <xsd:element name="root" msdata:IsDataSet="true">
65
+      <xsd:complexType>
66
+        <xsd:choice maxOccurs="unbounded">
67
+          <xsd:element name="metadata">
68
+            <xsd:complexType>
69
+              <xsd:sequence>
70
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
71
+              </xsd:sequence>
72
+              <xsd:attribute name="name" use="required" type="xsd:string" />
73
+              <xsd:attribute name="type" type="xsd:string" />
74
+              <xsd:attribute name="mimetype" type="xsd:string" />
75
+              <xsd:attribute ref="xml:space" />
76
+            </xsd:complexType>
77
+          </xsd:element>
78
+          <xsd:element name="assembly">
79
+            <xsd:complexType>
80
+              <xsd:attribute name="alias" type="xsd:string" />
81
+              <xsd:attribute name="name" type="xsd:string" />
82
+            </xsd:complexType>
83
+          </xsd:element>
84
+          <xsd:element name="data">
85
+            <xsd:complexType>
86
+              <xsd:sequence>
87
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
88
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
89
+              </xsd:sequence>
90
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
91
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
92
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
93
+              <xsd:attribute ref="xml:space" />
94
+            </xsd:complexType>
95
+          </xsd:element>
96
+          <xsd:element name="resheader">
97
+            <xsd:complexType>
98
+              <xsd:sequence>
99
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
100
+              </xsd:sequence>
101
+              <xsd:attribute name="name" type="xsd:string" use="required" />
102
+            </xsd:complexType>
103
+          </xsd:element>
104
+        </xsd:choice>
105
+      </xsd:complexType>
106
+    </xsd:element>
107
+  </xsd:schema>
108
+  <resheader name="resmimetype">
109
+    <value>text/microsoft-resx</value>
110
+  </resheader>
111
+  <resheader name="version">
112
+    <value>2.0</value>
113
+  </resheader>
114
+  <resheader name="reader">
115
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116
+  </resheader>
117
+  <resheader name="writer">
118
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119
+  </resheader>
120
+</root>

+ 95
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/CheckContourLine.cs 查看文件

@@ -0,0 +1,95 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Threading.Tasks;
6
+
7
+using Autodesk.AutoCAD.ApplicationServices;
8
+using Autodesk.AutoCAD.DatabaseServices;
9
+using Autodesk.AutoCAD.EditorInput;
10
+using Autodesk.AutoCAD.Geometry;
11
+
12
+namespace CADTools
13
+{
14
+    class CheckContourLine
15
+    {
16
+        public static int gap;
17
+        public static string jqx;
18
+        public static string sqx;
19
+
20
+        public void Valuecheck()
21
+        {
22
+            Document doc = Application.DocumentManager.MdiActiveDocument;
23
+            string LayerName = jqx + "," +sqx;
24
+            ObjectId[] ids = BasicFunction.getHeight(LayerName);//存放获取的等高线id
25
+
26
+
27
+            //如果没有等高线则返回
28
+            if (ids == null)
29
+                return;
30
+
31
+            //检查是否有错误曲线图层,没有则创建
32
+            LayerControl layerscontrol = new LayerControl();
33
+            string layname = "等高线有误";
34
+            if (!layerscontrol.haslayername(layname))
35
+            {
36
+                colorgb col = new colorgb(255, 0, 225);
37
+                layerscontrol.creatlayer(layname, col);
38
+                layerscontrol.movelayertofront(layname);
39
+            }
40
+            else
41
+                layerscontrol.movelayertofront(layname);
42
+
43
+            int j = 0;
44
+            int num = 0;
45
+            for (int i = 0; i < ids.Length; i++)
46
+            {
47
+                Polyline pll = BasicFunction.GetDBObject(ids[i]) as Polyline;
48
+                if (pll.Elevation <= 0)
49
+                {
50
+                    ChangeLayer(pll.Id, layname);
51
+                    j++;
52
+                }
53
+                else
54
+                {
55
+                    if (int.TryParse(Math.Round(pll.Elevation, 3, MidpointRounding.AwayFromZero).ToString(), out num))
56
+                    {
57
+                        if (Math.Round(pll.Elevation,3, MidpointRounding.AwayFromZero) % gap == 0)
58
+                        {
59
+                            continue;
60
+                        }
61
+                        else
62
+                        {
63
+                            ChangeLayer(pll.Id, layname);
64
+                            j++;
65
+                        }
66
+                    }
67
+                    else
68
+                    {
69
+                        ChangeLayer(pll.Id, layname);
70
+                        j++;
71
+                    }
72
+                }
73
+            }
74
+            Editor ed = doc.Editor; ed.WriteMessage("共有" + j + "处错误");
75
+        }
76
+
77
+
78
+        private void ChangeLayer(ObjectId c1Id, string lyname)
79
+        {
80
+            Database db = HostApplicationServices.WorkingDatabase;
81
+            DocumentLock doclock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
82
+            using (Transaction trans = db.TransactionManager.StartTransaction())
83
+            {
84
+                BlockTable bt = (BlockTable)trans.GetObject(db.BlockTableId, OpenMode.ForRead);
85
+                BlockTableRecord btr = (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
86
+                Entity ent1 = (Entity)c1Id.GetObject(OpenMode.ForWrite);
87
+                ent1.Layer = lyname;
88
+                trans.Commit();
89
+            }
90
+            doclock.Dispose();
91
+        }
92
+    }
93
+}
94
+
95
+

+ 147
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/CheckL.Designer.cs 查看文件

@@ -0,0 +1,147 @@
1
+
2
+namespace CADTools
3
+{
4
+    partial class CheckL
5
+    {
6
+        /// <summary>
7
+        /// Required designer variable.
8
+        /// </summary>
9
+        private System.ComponentModel.IContainer components = null;
10
+
11
+        /// <summary>
12
+        /// Clean up any resources being used.
13
+        /// </summary>
14
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
15
+        protected override void Dispose(bool disposing)
16
+        {
17
+            if (disposing && (components != null))
18
+            {
19
+                components.Dispose();
20
+            }
21
+            base.Dispose(disposing);
22
+        }
23
+
24
+        #region Windows Form Designer generated code
25
+
26
+        /// <summary>
27
+        /// Required method for Designer support - do not modify
28
+        /// the contents of this method with the code editor.
29
+        /// </summary>
30
+        private void InitializeComponent()
31
+        {
32
+            this.textBox_Gap = new System.Windows.Forms.TextBox();
33
+            this.label_Gap = new System.Windows.Forms.Label();
34
+            this.btn_Cancel = new System.Windows.Forms.Button();
35
+            this.btn_OK = new System.Windows.Forms.Button();
36
+            this.label1 = new System.Windows.Forms.Label();
37
+            this.label2 = new System.Windows.Forms.Label();
38
+            this.comboBox_sqx = new System.Windows.Forms.ComboBox();
39
+            this.comboBox_jqx = new System.Windows.Forms.ComboBox();
40
+            this.SuspendLayout();
41
+            // 
42
+            // textBox_Gap
43
+            // 
44
+            this.textBox_Gap.Location = new System.Drawing.Point(167, 127);
45
+            this.textBox_Gap.Name = "textBox_Gap";
46
+            this.textBox_Gap.Size = new System.Drawing.Size(169, 25);
47
+            this.textBox_Gap.TabIndex = 3;
48
+            // 
49
+            // label_Gap
50
+            // 
51
+            this.label_Gap.AutoSize = true;
52
+            this.label_Gap.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
53
+            this.label_Gap.Location = new System.Drawing.Point(94, 130);
54
+            this.label_Gap.Name = "label_Gap";
55
+            this.label_Gap.Size = new System.Drawing.Size(67, 15);
56
+            this.label_Gap.TabIndex = 2;
57
+            this.label_Gap.Text = "等高距:";
58
+            // 
59
+            // btn_Cancel
60
+            // 
61
+            this.btn_Cancel.Location = new System.Drawing.Point(255, 171);
62
+            this.btn_Cancel.Margin = new System.Windows.Forms.Padding(4);
63
+            this.btn_Cancel.Name = "btn_Cancel";
64
+            this.btn_Cancel.Size = new System.Drawing.Size(100, 29);
65
+            this.btn_Cancel.TabIndex = 34;
66
+            this.btn_Cancel.Text = "取 消";
67
+            this.btn_Cancel.UseVisualStyleBackColor = true;
68
+            this.btn_Cancel.Click += new System.EventHandler(this.btn_Cancel_Click);
69
+            // 
70
+            // btn_OK
71
+            // 
72
+            this.btn_OK.Location = new System.Drawing.Point(77, 171);
73
+            this.btn_OK.Margin = new System.Windows.Forms.Padding(4);
74
+            this.btn_OK.Name = "btn_OK";
75
+            this.btn_OK.Size = new System.Drawing.Size(100, 29);
76
+            this.btn_OK.TabIndex = 33;
77
+            this.btn_OK.Text = "确 定";
78
+            this.btn_OK.UseVisualStyleBackColor = true;
79
+            this.btn_OK.Click += new System.EventHandler(this.btn_OK_Click);
80
+            // 
81
+            // label1
82
+            // 
83
+            this.label1.AutoSize = true;
84
+            this.label1.Location = new System.Drawing.Point(64, 25);
85
+            this.label1.Name = "label1";
86
+            this.label1.Size = new System.Drawing.Size(97, 15);
87
+            this.label1.TabIndex = 35;
88
+            this.label1.Text = "首曲线图层:";
89
+            // 
90
+            // label2
91
+            // 
92
+            this.label2.AutoSize = true;
93
+            this.label2.Location = new System.Drawing.Point(64, 74);
94
+            this.label2.Name = "label2";
95
+            this.label2.Size = new System.Drawing.Size(97, 15);
96
+            this.label2.TabIndex = 36;
97
+            this.label2.Text = "计曲线图层:";
98
+            // 
99
+            // comboBox_sqx
100
+            // 
101
+            this.comboBox_sqx.FormattingEnabled = true;
102
+            this.comboBox_sqx.Location = new System.Drawing.Point(167, 22);
103
+            this.comboBox_sqx.Name = "comboBox_sqx";
104
+            this.comboBox_sqx.Size = new System.Drawing.Size(169, 23);
105
+            this.comboBox_sqx.TabIndex = 37;
106
+            // 
107
+            // comboBox_jqx
108
+            // 
109
+            this.comboBox_jqx.FormattingEnabled = true;
110
+            this.comboBox_jqx.Location = new System.Drawing.Point(167, 71);
111
+            this.comboBox_jqx.Name = "comboBox_jqx";
112
+            this.comboBox_jqx.Size = new System.Drawing.Size(169, 23);
113
+            this.comboBox_jqx.TabIndex = 38;
114
+            // 
115
+            // CheckL
116
+            // 
117
+            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
118
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
119
+            this.ClientSize = new System.Drawing.Size(434, 213);
120
+            this.Controls.Add(this.comboBox_jqx);
121
+            this.Controls.Add(this.comboBox_sqx);
122
+            this.Controls.Add(this.label2);
123
+            this.Controls.Add(this.label1);
124
+            this.Controls.Add(this.btn_Cancel);
125
+            this.Controls.Add(this.btn_OK);
126
+            this.Controls.Add(this.textBox_Gap);
127
+            this.Controls.Add(this.label_Gap);
128
+            this.Name = "CheckL";
129
+            this.Text = "等高线检查";
130
+            this.Load += new System.EventHandler(this.CheckL_Load);
131
+            this.ResumeLayout(false);
132
+            this.PerformLayout();
133
+
134
+        }
135
+
136
+        #endregion
137
+
138
+        private System.Windows.Forms.TextBox textBox_Gap;
139
+        private System.Windows.Forms.Label label_Gap;
140
+        private System.Windows.Forms.Button btn_Cancel;
141
+        private System.Windows.Forms.Button btn_OK;
142
+        private System.Windows.Forms.Label label1;
143
+        private System.Windows.Forms.Label label2;
144
+        private System.Windows.Forms.ComboBox comboBox_sqx;
145
+        private System.Windows.Forms.ComboBox comboBox_jqx;
146
+    }
147
+}

+ 101
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/CheckL.cs 查看文件

@@ -0,0 +1,101 @@
1
+using Autodesk.AutoCAD.DatabaseServices;
2
+using System;
3
+using System.Collections.Generic;
4
+using System.ComponentModel;
5
+using System.Data;
6
+using System.Drawing;
7
+using System.Linq;
8
+using System.Text;
9
+using System.Threading.Tasks;
10
+using System.Windows.Forms;
11
+
12
+namespace CADTools
13
+{
14
+    public partial class CheckL : Form
15
+    {
16
+        public CheckL()
17
+        {
18
+            InitializeComponent();
19
+        }
20
+
21
+        private void btn_OK_Click(object sender, EventArgs e)
22
+        {
23
+            int num = 0;
24
+            if (comboBox_jqx.Text == "")
25
+            {
26
+                Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("请选择计曲线所在图层");
27
+                return;
28
+            }
29
+            if (comboBox_sqx.Text == "")
30
+            {
31
+                Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("请选择首曲线所在图层");
32
+                return;
33
+            }
34
+            if (textBox_Gap.Text == "")
35
+            {
36
+                Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("请输入等高距");
37
+                return;
38
+            }
39
+
40
+            if (int.TryParse(textBox_Gap.Text.ToString(), out num) == false)
41
+            {
42
+                Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("等高距必须为整数");
43
+                return;
44
+            }
45
+
46
+            CheckContourLine.gap = Convert.ToInt32(textBox_Gap.Text);
47
+            CheckContourLine.jqx = comboBox_jqx.Text;
48
+            CheckContourLine.sqx = comboBox_sqx.Text;
49
+
50
+            this.Close();
51
+            CheckContourLine ccline = new CheckContourLine();
52
+            ccline.Valuecheck();
53
+            this.Close();
54
+        }
55
+
56
+        private void CheckL_Load(object sender, EventArgs e)
57
+        {
58
+            this.comboBox_jqx.DropDownStyle = ComboBoxStyle.DropDownList;
59
+            this.comboBox_sqx.DropDownStyle = ComboBoxStyle.DropDownList;
60
+
61
+            //自动填充下拉框
62
+            Database database = Autodesk.AutoCAD.DatabaseServices.HostApplicationServices.WorkingDatabase;
63
+            using (Transaction traction = database.TransactionManager.StartTransaction())
64
+            {
65
+                //存放所有图层名
66
+                List<string> alllayername = new List<string>();
67
+                LayerTable layertable = traction.GetObject(database.LayerTableId, OpenMode.ForRead) as LayerTable;
68
+                foreach (ObjectId objid in layertable)
69
+                {
70
+                    LayerTableRecord layertablerecord = traction.GetObject(objid, OpenMode.ForRead) as LayerTableRecord;
71
+                    alllayername.Add(layertablerecord.Name);
72
+                }
73
+
74
+                alllayername.Sort();
75
+
76
+                for (int i = 0; i < alllayername.Count; i++)
77
+                {
78
+                    this.comboBox_jqx.Items.Add(alllayername[i]);
79
+                    this.comboBox_sqx.Items.Add(alllayername[i]);
80
+                }
81
+
82
+                if (alllayername.Contains("8110"))
83
+                {
84
+                    int index = alllayername.IndexOf("8110");
85
+                    this.comboBox_sqx.SelectedIndex = index;
86
+                }
87
+                if (alllayername.Contains("8120"))
88
+                {
89
+                    int index = alllayername.IndexOf("8120");
90
+                    this.comboBox_jqx.SelectedIndex = index;
91
+                }
92
+                traction.Commit();
93
+            }
94
+        }
95
+
96
+        private void btn_Cancel_Click(object sender, EventArgs e)
97
+        {
98
+            this.Close();
99
+        }
100
+    }
101
+}

+ 120
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/CheckL.resx 查看文件

@@ -0,0 +1,120 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<root>
3
+  <!-- 
4
+    Microsoft ResX Schema 
5
+    
6
+    Version 2.0
7
+    
8
+    The primary goals of this format is to allow a simple XML format 
9
+    that is mostly human readable. The generation and parsing of the 
10
+    various data types are done through the TypeConverter classes 
11
+    associated with the data types.
12
+    
13
+    Example:
14
+    
15
+    ... ado.net/XML headers & schema ...
16
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
17
+    <resheader name="version">2.0</resheader>
18
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
19
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
20
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
21
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
22
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
24
+    </data>
25
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
26
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
27
+        <comment>This is a comment</comment>
28
+    </data>
29
+                
30
+    There are any number of "resheader" rows that contain simple 
31
+    name/value pairs.
32
+    
33
+    Each data row contains a name, and value. The row also contains a 
34
+    type or mimetype. Type corresponds to a .NET class that support 
35
+    text/value conversion through the TypeConverter architecture. 
36
+    Classes that don't support this are serialized and stored with the 
37
+    mimetype set.
38
+    
39
+    The mimetype is used for serialized objects, and tells the 
40
+    ResXResourceReader how to depersist the object. This is currently not 
41
+    extensible. For a given mimetype the value must be set accordingly:
42
+    
43
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
44
+    that the ResXResourceWriter will generate, however the reader can 
45
+    read any of the formats listed below.
46
+    
47
+    mimetype: application/x-microsoft.net.object.binary.base64
48
+    value   : The object must be serialized with 
49
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
50
+            : and then encoded with base64 encoding.
51
+    
52
+    mimetype: application/x-microsoft.net.object.soap.base64
53
+    value   : The object must be serialized with 
54
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
55
+            : and then encoded with base64 encoding.
56
+
57
+    mimetype: application/x-microsoft.net.object.bytearray.base64
58
+    value   : The object must be serialized into a byte array 
59
+            : using a System.ComponentModel.TypeConverter
60
+            : and then encoded with base64 encoding.
61
+    -->
62
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
64
+    <xsd:element name="root" msdata:IsDataSet="true">
65
+      <xsd:complexType>
66
+        <xsd:choice maxOccurs="unbounded">
67
+          <xsd:element name="metadata">
68
+            <xsd:complexType>
69
+              <xsd:sequence>
70
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
71
+              </xsd:sequence>
72
+              <xsd:attribute name="name" use="required" type="xsd:string" />
73
+              <xsd:attribute name="type" type="xsd:string" />
74
+              <xsd:attribute name="mimetype" type="xsd:string" />
75
+              <xsd:attribute ref="xml:space" />
76
+            </xsd:complexType>
77
+          </xsd:element>
78
+          <xsd:element name="assembly">
79
+            <xsd:complexType>
80
+              <xsd:attribute name="alias" type="xsd:string" />
81
+              <xsd:attribute name="name" type="xsd:string" />
82
+            </xsd:complexType>
83
+          </xsd:element>
84
+          <xsd:element name="data">
85
+            <xsd:complexType>
86
+              <xsd:sequence>
87
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
88
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
89
+              </xsd:sequence>
90
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
91
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
92
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
93
+              <xsd:attribute ref="xml:space" />
94
+            </xsd:complexType>
95
+          </xsd:element>
96
+          <xsd:element name="resheader">
97
+            <xsd:complexType>
98
+              <xsd:sequence>
99
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
100
+              </xsd:sequence>
101
+              <xsd:attribute name="name" type="xsd:string" use="required" />
102
+            </xsd:complexType>
103
+          </xsd:element>
104
+        </xsd:choice>
105
+      </xsd:complexType>
106
+    </xsd:element>
107
+  </xsd:schema>
108
+  <resheader name="resmimetype">
109
+    <value>text/microsoft-resx</value>
110
+  </resheader>
111
+  <resheader name="version">
112
+    <value>2.0</value>
113
+  </resheader>
114
+  <resheader name="reader">
115
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116
+  </resheader>
117
+  <resheader name="writer">
118
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119
+  </resheader>
120
+</root>

+ 417
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/CheckPLOverlay.cs 查看文件

@@ -0,0 +1,417 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Diagnostics;
6
+
7
+using Autodesk.AutoCAD.Geometry;
8
+using Autodesk.AutoCAD.DatabaseServices;
9
+using Autodesk.AutoCAD.ApplicationServices;
10
+using Autodesk.AutoCAD.EditorInput;
11
+
12
+
13
+
14
+namespace CADTools
15
+{
16
+
17
+    public struct CPoint
18
+    {
19
+        public double x;
20
+        public double y;
21
+        public double z;
22
+        public object objID;
23
+    }
24
+
25
+
26
+    /// <summary>
27
+    /// 判断点和线是否重叠
28
+    /// </summary>
29
+    class CheckPLOverlay
30
+    {
31
+        public static int blc;//比例尺
32
+        public static string sqx;//首曲线
33
+        public static string jqx;//计曲线
34
+        public const int looptimes = 15;//循环查找次数
35
+        public static string EleLayerName;//高程点图层名
36
+
37
+        public int windowwidth;//当前可视范围
38
+        public int windowheight;
39
+
40
+
41
+        public double radius;//半径
42
+
43
+        public double length;//搜索半径
44
+        //存放所有高程点数组
45
+        public List<CPoint> pointarrlist = new List<CPoint>();
46
+
47
+        //存放有问题的高程点数组
48
+        public List<CPoint> errorpointarrlist = new List<CPoint>();
49
+
50
+
51
+
52
+
53
+
54
+
55
+        /// <summary>
56
+        /// 检测点线矛盾,并画圆标记出错误点
57
+        /// </summary>
58
+
59
+        public void contourch()
60
+        {
61
+            Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
62
+
63
+            //清空各数组
64
+            pointarrlist.Clear();
65
+            errorpointarrlist.Clear();
66
+
67
+            double flagradius = 4.0 * blc / 1000;//画圆标记半径
68
+            windowwidth = 30 * 4 * blc / 1000;//确定可视范围
69
+            windowheight = 30 * 4 * blc / 1000;
70
+
71
+            if (blc == 500)
72
+            {
73
+                radius = 0.125;
74
+            }
75
+            else if (blc == 1000)
76
+            {
77
+                radius = 0.25;
78
+            }
79
+            else if (blc == 2000)
80
+            {
81
+                radius = 0.5;
82
+            }
83
+            else if (blc == 5000)
84
+            {
85
+                radius = 1.25;
86
+            }
87
+
88
+
89
+            //外切圆半径
90
+            length = radius * Math.Pow(2, 0.5);
91
+
92
+            selectcontourpoint(EleLayerName);//选出高程点
93
+            if (pointarrlist.Count == 0)
94
+            {
95
+                return;
96
+            }
97
+
98
+            //开始计时
99
+            Stopwatch watch = new Stopwatch();
100
+            watch.Start();
101
+
102
+            LayerControl layerscontrol = new LayerControl();
103
+            string layname = "点线重叠标记符号";
104
+            if (!layerscontrol.haslayername(layname))
105
+            {
106
+                colorgb col = new colorgb(255, 0, 255);
107
+                layerscontrol.creatlayer(layname, col);
108
+                layerscontrol.movelayertofront(layname);
109
+            }
110
+            else
111
+                layerscontrol.movelayertofront(layname);
112
+
113
+            layname = "点线重叠高程点";
114
+            if (layerscontrol.haslayername(layname) == false)
115
+            {
116
+                colorgb col = new colorgb(255, 0, 255);
117
+                layerscontrol.creatlayer(layname, col);
118
+            }
119
+
120
+
121
+
122
+            for (int i = 0; i < pointarrlist.Count; i++)
123
+            {
124
+                CPoint p = pointarrlist[i];
125
+                bool flag = check(p.x, p.y, p.z);
126
+                if (flag == false)
127
+                {
128
+                    errorpointarrlist.Add(p);
129
+                }
130
+            }
131
+
132
+
133
+            DocumentLock documentlock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
134
+            Database database = HostApplicationServices.WorkingDatabase;
135
+            using (Transaction traction = database.TransactionManager.StartTransaction())
136
+            {
137
+                BlockTable blocktable = traction.GetObject(database.BlockTableId,
138
+                                         OpenMode.ForWrite) as BlockTable;
139
+
140
+
141
+                string decimals = "";
142
+                if (blc == 2000 || blc == 5000)
143
+                {
144
+                    decimals = "F1";
145
+                }
146
+                else
147
+                {
148
+                    decimals = "F2";
149
+                }
150
+
151
+                for (int i = 0; i < errorpointarrlist.Count; i++)
152
+                {
153
+                    CPoint p = errorpointarrlist[i];
154
+
155
+                    BasicFunction functions = new BasicFunction();
156
+                    functions.makeflag(p.x, p.y, 0, flagradius, "点线重叠标记符号");
157
+
158
+
159
+                    ObjectId id = (ObjectId)p.objID;
160
+                    Entity entity = (Entity)traction.GetObject(id, OpenMode.ForWrite);
161
+                    entity.Layer = "点线重叠高程点";
162
+
163
+                    double z = p.z;
164
+                    string ele = z.ToString(decimals);
165
+
166
+
167
+                    Point3d p1 = new Point3d(p.x, p.y - 2.5, 0);
168
+                    Point3d p2 = new Point3d(p.x + 10, p.y + 2.5, 0);
169
+                    TypedValue[] typedvalue = new TypedValue[2];
170
+
171
+                    typedvalue.SetValue(new TypedValue((int)DxfCode.Start, "Text"), 0);
172
+                    typedvalue.SetValue(new TypedValue((int)DxfCode.LayerName, EleLayerName), 1);
173
+
174
+                    SelectionFilter filter = new SelectionFilter(typedvalue);
175
+                    PromptSelectionResult psr = editor.SelectCrossingWindow(p1, p2, filter);
176
+                    if (psr.Status == PromptStatus.OK)
177
+                    {
178
+                        SelectionSet set = psr.Value;
179
+                        ObjectId[] objs = new ObjectId[set.Count];
180
+                        objs = set.GetObjectIds();
181
+                        for (int ii = 0; ii < objs.Length; ii++)
182
+                        {
183
+                            Entity Text = (Entity)traction.GetObject(objs[ii], OpenMode.ForWrite);
184
+
185
+                            DBText T = (DBText)Text;
186
+                            if (T.TextString == ele)
187
+                            {
188
+                                T.Layer = "点线重叠高程点";
189
+                                T.Color = Autodesk.AutoCAD.Colors.Color.FromRgb(255, 0, 255);
190
+                            }
191
+                        }
192
+                    }
193
+
194
+
195
+                }
196
+
197
+                traction.Commit();
198
+            }
199
+            documentlock.Dispose();
200
+
201
+
202
+
203
+            //耗时
204
+            watch.Stop();
205
+            long times = watch.ElapsedMilliseconds;
206
+            //editor.Regen();
207
+            //editor.UpdateScreen();
208
+
209
+            editor.WriteMessage("\n" + "耗时:" + times.ToString() + "毫秒");
210
+            editor.WriteMessage("\n" + "检测到压线高程点" + errorpointarrlist.Count.ToString());
211
+            editor.WriteMessage("\n");
212
+
213
+        }
214
+
215
+
216
+
217
+
218
+        /// <summary>
219
+        /// 选出所有高程点,并取出其x,y,z坐标
220
+        /// </summary>
221
+        /// <param name="layername">高程点图层名</param>
222
+        private void selectcontourpoint(string layername)
223
+        {
224
+            Document document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
225
+            Database database = HostApplicationServices.WorkingDatabase;
226
+            using (Transaction traction = database.TransactionManager.StartTransaction())
227
+            {
228
+                // 获得当前文档的编辑器  
229
+                Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
230
+                // 创建一个 TypedValue 数组,用于定义过滤条件
231
+                TypedValue[] typedvalue = new TypedValue[1];
232
+                typedvalue.SetValue(new TypedValue((int)DxfCode.LayerName, layername), 0);
233
+                // 赋值过滤条件给 SelectionFilter 对象
234
+                SelectionFilter selectionfilter = new SelectionFilter(typedvalue);
235
+
236
+                // 要求在图形区域中手动选择对象
237
+                PromptSelectionResult psr = editor.GetSelection(selectionfilter);
238
+
239
+                //自动选择图像区域全部对象
240
+                //PromptSelectionResult psr = editor.SelectAll(selectionfilter);
241
+
242
+
243
+                if (psr.Status == PromptStatus.OK)
244
+                {
245
+                    SelectionSet selectionset = psr.Value;
246
+
247
+                    ObjectId[] obj = new ObjectId[selectionset.Count];
248
+                    obj = selectionset.GetObjectIds();
249
+
250
+
251
+                    for (int i = 0; i < obj.Length; i++)
252
+                    {
253
+                        ObjectId objid = obj[i];
254
+
255
+                        //找到实体,取出高程点的x,y,z
256
+                        Entity entity = (Entity)traction.GetObject(objid, OpenMode.ForRead);
257
+
258
+                        if (entity is BlockReference)
259
+                        {
260
+                            BlockReference blockreference = (BlockReference)entity;
261
+                            CPoint cp = new CPoint();
262
+
263
+                            cp.x = blockreference.Position.X;
264
+                            cp.y = blockreference.Position.Y;
265
+                            cp.z = blockreference.Position.Z;
266
+                            cp.objID = objid;
267
+
268
+                            pointarrlist.Add(cp);
269
+                        }
270
+
271
+                    }
272
+                    editor.WriteMessage("\n" + "选中高程点数量:" + pointarrlist.Count.ToString());
273
+
274
+                }
275
+
276
+
277
+
278
+                traction.Commit();
279
+                traction.Dispose();
280
+            }
281
+        }
282
+
283
+
284
+        /// <summary>
285
+        /// 检查是否压线 
286
+        /// </summary>
287
+        /// <param name="x">高程点x坐标</param>
288
+        /// <param name="y">高程点y坐标</param>
289
+        /// <param name="z">高程点z坐标</param>
290
+        private bool check(double x, double y, double z)
291
+        {
292
+
293
+            Database database = HostApplicationServices.WorkingDatabase;
294
+            Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
295
+            DocumentLock doclock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
296
+            using (Transaction acTrans = database.TransactionManager.StartTransaction())
297
+            {
298
+                ViewTableRecord currview = editor.GetCurrentView();
299
+                currview.CenterPoint = new Point2d(x, y);
300
+                currview.ViewDirection = new Vector3d(0, 0, 1);
301
+                currview.Width = windowwidth;
302
+                currview.Height = windowheight;
303
+                editor.SetCurrentView(currview);
304
+                acTrans.Commit();
305
+            }
306
+
307
+            Transaction traction = database.TransactionManager.StartTransaction();
308
+            List<double> elevation = new List<double>();
309
+            try
310
+            {
311
+
312
+                BlockTable blocktable = traction.GetObject(database.BlockTableId,
313
+                                             OpenMode.ForWrite) as BlockTable;
314
+
315
+
316
+                BlockTableRecord blocktablerecord = traction.GetObject(blocktable[BlockTableRecord.ModelSpace],
317
+                                                OpenMode.ForWrite) as BlockTableRecord;
318
+
319
+
320
+                //ViewTableRecord currview = editor.GetCurrentView();
321
+                //currview.CenterPoint = new Point2d(x, y);
322
+                //currview.ViewDirection = new Vector3d(0, 0, 1);
323
+                //currview.Width = windowwidth;
324
+                //currview.Height = windowheight;
325
+                //editor.SetCurrentView(currview);
326
+
327
+
328
+                string filttext = sqx + "," + jqx;
329
+                TypedValue[] filterlist = new TypedValue[1]
330
+                    {
331
+                        new TypedValue((int)DxfCode.LayerName,filttext)
332
+                    };
333
+                //filterelist.SetValue(new TypedValue((int)DxfCode.LayerName, "8110,8120"),0);
334
+                // 赋值过滤条件给 SelectionFilter 对象
335
+                SelectionFilter filter = new SelectionFilter(filterlist);
336
+
337
+                Point3d p1 = new Point3d(x - length, y - length, 0);
338
+                Point3d p2 = new Point3d(x + length, y + length, 0);
339
+
340
+
341
+                PromptSelectionResult pselectresult;
342
+                pselectresult = editor.SelectCrossingWindow(p1, p2, filter);
343
+
344
+                if (pselectresult.Status == PromptStatus.OK)
345
+                {
346
+                    SelectionSet selectionset = pselectresult.Value;
347
+                    ObjectId[] obj = new ObjectId[selectionset.Count];
348
+                    obj = selectionset.GetObjectIds();
349
+                    for (int i = 0; i < obj.Length; i++)
350
+                    {
351
+                        ObjectId objid = obj[i];
352
+                        Entity entity = (Entity)traction.GetObject(objid, OpenMode.ForRead);
353
+
354
+                        if (entity is Polyline)
355
+                        {
356
+                            Polyline pline = (Polyline)entity;
357
+                            Point3d p = pline.GetClosestPointTo(new Point3d(x, y, z), new Vector3d(0, 0, 1), false);
358
+                            double distance = System.Math.Sqrt((p.X - x) * (p.X - x) + (p.Y - y) * (p.Y - y));
359
+                            if (distance < radius)
360
+                            {
361
+                                if ((distance == 0 || pline.Elevation != z) == true)
362
+                                {
363
+
364
+                                    return false;
365
+                                    //cpoint cp = new cpoint();
366
+                                    //cp.x = x;
367
+                                    //cp.y = y;
368
+                                    //cp.z = z;
369
+                                    //errorpointarrlist.Add(cp);
370
+                                }
371
+                            }
372
+                        }
373
+                        else if (entity is Polyline2d)
374
+                        {
375
+                            Polyline2d pline2d = (Polyline2d)entity;
376
+                            Point3d p = pline2d.GetClosestPointTo(new Point3d(x, y, z), new Vector3d(0, 0, 1), false);
377
+                            double distance = System.Math.Sqrt((p.X - x) * (p.X - x) + (p.Y - y) * (p.Y - y));
378
+                            if (distance < radius)
379
+                            {
380
+                                if ((distance == 0 && pline2d.Elevation == z) == false)
381
+                                {
382
+                                    return false;
383
+                                    //cpoint cp = new cpoint();
384
+                                    //cp.x = x;
385
+                                    //cp.y = y;
386
+                                    //cp.z = z;
387
+                                    //errorpointarrlist.Add(cp);
388
+                                }
389
+                            }
390
+                        }
391
+
392
+                    }
393
+
394
+                }
395
+
396
+
397
+            }
398
+            catch (Autodesk.AutoCAD.Runtime.Exception ex)
399
+            {
400
+                string str = ex.ToString();
401
+                Application.ShowAlertDialog(str);
402
+            }
403
+            finally
404
+            {
405
+                doclock.Dispose();
406
+                traction.Dispose();
407
+            }
408
+
409
+            return true;
410
+
411
+        }
412
+
413
+
414
+
415
+
416
+    }
417
+}

+ 154
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/Conn.Designer.cs 查看文件

@@ -0,0 +1,154 @@
1
+
2
+namespace CADTools
3
+{
4
+    partial class Conn
5
+    {
6
+        /// <summary>
7
+        /// Required designer variable.
8
+        /// </summary>
9
+        private System.ComponentModel.IContainer components = null;
10
+
11
+        /// <summary>
12
+        /// Clean up any resources being used.
13
+        /// </summary>
14
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
15
+        protected override void Dispose(bool disposing)
16
+        {
17
+            if (disposing && (components != null))
18
+            {
19
+                components.Dispose();
20
+            }
21
+            base.Dispose(disposing);
22
+        }
23
+
24
+        #region Windows Form Designer generated code
25
+
26
+        /// <summary>
27
+        /// Required method for Designer support - do not modify
28
+        /// the contents of this method with the code editor.
29
+        /// </summary>
30
+        private void InitializeComponent()
31
+        {
32
+            this.comboBox_blc = new System.Windows.Forms.ComboBox();
33
+            this.label_Blc = new System.Windows.Forms.Label();
34
+            this.btn_Cancel = new System.Windows.Forms.Button();
35
+            this.btn_OK = new System.Windows.Forms.Button();
36
+            this.comboBox_jqx = new System.Windows.Forms.ComboBox();
37
+            this.label2 = new System.Windows.Forms.Label();
38
+            this.comboBox_sqx = new System.Windows.Forms.ComboBox();
39
+            this.label1 = new System.Windows.Forms.Label();
40
+            this.SuspendLayout();
41
+            // 
42
+            // comboBox_blc
43
+            // 
44
+            this.comboBox_blc.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
45
+            this.comboBox_blc.FormattingEnabled = true;
46
+            this.comboBox_blc.Items.AddRange(new object[] {
47
+            "1:500",
48
+            "1:1000",
49
+            "1:2000",
50
+            "1:5000"});
51
+            this.comboBox_blc.Location = new System.Drawing.Point(186, 28);
52
+            this.comboBox_blc.Margin = new System.Windows.Forms.Padding(4);
53
+            this.comboBox_blc.Name = "comboBox_blc";
54
+            this.comboBox_blc.Size = new System.Drawing.Size(160, 23);
55
+            this.comboBox_blc.TabIndex = 53;
56
+            // 
57
+            // label_Blc
58
+            // 
59
+            this.label_Blc.AutoSize = true;
60
+            this.label_Blc.Location = new System.Drawing.Point(83, 31);
61
+            this.label_Blc.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
62
+            this.label_Blc.Name = "label_Blc";
63
+            this.label_Blc.Size = new System.Drawing.Size(97, 15);
64
+            this.label_Blc.TabIndex = 52;
65
+            this.label_Blc.Text = "比例尺选择:";
66
+            // 
67
+            // btn_Cancel
68
+            // 
69
+            this.btn_Cancel.Location = new System.Drawing.Point(246, 167);
70
+            this.btn_Cancel.Margin = new System.Windows.Forms.Padding(4);
71
+            this.btn_Cancel.Name = "btn_Cancel";
72
+            this.btn_Cancel.Size = new System.Drawing.Size(100, 29);
73
+            this.btn_Cancel.TabIndex = 55;
74
+            this.btn_Cancel.Text = "取 消";
75
+            this.btn_Cancel.UseVisualStyleBackColor = true;
76
+            // 
77
+            // btn_OK
78
+            // 
79
+            this.btn_OK.Location = new System.Drawing.Point(83, 167);
80
+            this.btn_OK.Margin = new System.Windows.Forms.Padding(4);
81
+            this.btn_OK.Name = "btn_OK";
82
+            this.btn_OK.Size = new System.Drawing.Size(100, 29);
83
+            this.btn_OK.TabIndex = 54;
84
+            this.btn_OK.Text = "确 定";
85
+            this.btn_OK.UseVisualStyleBackColor = true;
86
+            this.btn_OK.Click += new System.EventHandler(this.btn_OK_Click);
87
+            // 
88
+            // comboBox_jqx
89
+            // 
90
+            this.comboBox_jqx.FormattingEnabled = true;
91
+            this.comboBox_jqx.Location = new System.Drawing.Point(186, 77);
92
+            this.comboBox_jqx.Name = "comboBox_jqx";
93
+            this.comboBox_jqx.Size = new System.Drawing.Size(160, 23);
94
+            this.comboBox_jqx.TabIndex = 59;
95
+            // 
96
+            // label2
97
+            // 
98
+            this.label2.AutoSize = true;
99
+            this.label2.Location = new System.Drawing.Point(83, 80);
100
+            this.label2.Name = "label2";
101
+            this.label2.Size = new System.Drawing.Size(97, 15);
102
+            this.label2.TabIndex = 58;
103
+            this.label2.Text = "计曲线图层:";
104
+            // 
105
+            // comboBox_sqx
106
+            // 
107
+            this.comboBox_sqx.FormattingEnabled = true;
108
+            this.comboBox_sqx.Location = new System.Drawing.Point(186, 123);
109
+            this.comboBox_sqx.Name = "comboBox_sqx";
110
+            this.comboBox_sqx.Size = new System.Drawing.Size(160, 23);
111
+            this.comboBox_sqx.TabIndex = 61;
112
+            // 
113
+            // label1
114
+            // 
115
+            this.label1.AutoSize = true;
116
+            this.label1.Location = new System.Drawing.Point(83, 126);
117
+            this.label1.Name = "label1";
118
+            this.label1.Size = new System.Drawing.Size(97, 15);
119
+            this.label1.TabIndex = 60;
120
+            this.label1.Text = "首曲线图层:";
121
+            // 
122
+            // Conn
123
+            // 
124
+            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
125
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
126
+            this.ClientSize = new System.Drawing.Size(432, 223);
127
+            this.Controls.Add(this.comboBox_sqx);
128
+            this.Controls.Add(this.label1);
129
+            this.Controls.Add(this.comboBox_jqx);
130
+            this.Controls.Add(this.label2);
131
+            this.Controls.Add(this.btn_Cancel);
132
+            this.Controls.Add(this.btn_OK);
133
+            this.Controls.Add(this.comboBox_blc);
134
+            this.Controls.Add(this.label_Blc);
135
+            this.Name = "Conn";
136
+            this.Text = "线相交检查";
137
+            this.Load += new System.EventHandler(this.Conn_Load);
138
+            this.ResumeLayout(false);
139
+            this.PerformLayout();
140
+
141
+        }
142
+
143
+        #endregion
144
+
145
+        private System.Windows.Forms.ComboBox comboBox_blc;
146
+        private System.Windows.Forms.Label label_Blc;
147
+        private System.Windows.Forms.Button btn_Cancel;
148
+        private System.Windows.Forms.Button btn_OK;
149
+        private System.Windows.Forms.ComboBox comboBox_jqx;
150
+        private System.Windows.Forms.Label label2;
151
+        private System.Windows.Forms.ComboBox comboBox_sqx;
152
+        private System.Windows.Forms.Label label1;
153
+    }
154
+}

+ 115
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/Conn.cs 查看文件

@@ -0,0 +1,115 @@
1
+using Autodesk.AutoCAD.DatabaseServices;
2
+using System;
3
+using System.Collections.Generic;
4
+using System.ComponentModel;
5
+using System.Data;
6
+using System.Drawing;
7
+using System.Linq;
8
+using System.Text;
9
+using System.Threading.Tasks;
10
+using System.Windows.Forms;
11
+
12
+namespace CADTools
13
+{
14
+    public partial class Conn : Form
15
+    {
16
+        public Conn()
17
+        {
18
+            InitializeComponent();
19
+        }
20
+
21
+        private void Conn_Load(object sender, EventArgs e)
22
+        {
23
+            if (MainClass.Flag == "SelfIntersect")
24
+            {
25
+                this.Text = "线自相交";
26
+            }
27
+            if (MainClass.Flag == "EachIntersect")
28
+            {
29
+                this.Text = "线相交";
30
+            }
31
+
32
+            this.comboBox_jqx.DropDownStyle = ComboBoxStyle.DropDownList;
33
+            this.comboBox_sqx.DropDownStyle = ComboBoxStyle.DropDownList;
34
+
35
+            //自动填充下拉框
36
+            Database database = Autodesk.AutoCAD.DatabaseServices.HostApplicationServices.WorkingDatabase;
37
+            using (Transaction traction = database.TransactionManager.StartTransaction())
38
+            {
39
+                //存放所有图层名
40
+                List<string> alllayername = new List<string>();
41
+                LayerTable layertable = traction.GetObject(database.LayerTableId, OpenMode.ForRead) as LayerTable;
42
+                foreach (ObjectId objid in layertable)
43
+                {
44
+                    LayerTableRecord layertablerecord = traction.GetObject(objid, OpenMode.ForRead) as LayerTableRecord;
45
+                    alllayername.Add(layertablerecord.Name);
46
+                }
47
+
48
+                alllayername.Sort();
49
+
50
+                for (int i = 0; i < alllayername.Count; i++)
51
+                {
52
+                    this.comboBox_jqx.Items.Add(alllayername[i]);
53
+                    this.comboBox_sqx.Items.Add(alllayername[i]);
54
+                }
55
+
56
+                if (alllayername.Contains("8110"))
57
+                {
58
+                    int index = alllayername.IndexOf("8110");
59
+                    this.comboBox_sqx.SelectedIndex = index;
60
+                }
61
+                if (alllayername.Contains("8120"))
62
+                {
63
+                    int index = alllayername.IndexOf("8120");
64
+                    this.comboBox_jqx.SelectedIndex = index;
65
+                }
66
+                traction.Commit();
67
+            }
68
+        }
69
+
70
+        private void btn_OK_Click(object sender, EventArgs e)
71
+        {
72
+            if (MainClass.Flag == "SelfIntersect")
73
+            {
74
+                if (comboBox_blc.Text == "")
75
+                {
76
+                    Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("请选择比例尺");
77
+                    return;
78
+                }
79
+
80
+                //比例尺
81
+                string blctext = comboBox_blc.Text;
82
+                int blcindex = blctext.LastIndexOf(':');
83
+                string strblc = blctext.Substring(blcindex + 1);
84
+                Inters.blc = Convert.ToInt32(strblc);
85
+                Inters.jqx = comboBox_jqx.Text;
86
+                Inters.sqx = comboBox_sqx.Text;
87
+
88
+                this.Close();
89
+                Inters selfints = new Inters();
90
+                selfints.SelfInts();
91
+            }
92
+
93
+            if (MainClass.Flag == "EachIntersect")
94
+            {
95
+                if (comboBox_blc.Text == "")
96
+                {
97
+                    Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("请选择比例尺");
98
+                    return;
99
+                }
100
+
101
+                //比例尺
102
+                string blctext = comboBox_blc.Text;
103
+                int blcindex = blctext.LastIndexOf(':');
104
+                string strblc = blctext.Substring(blcindex + 1);
105
+                Inters.blc = Convert.ToInt32(strblc);
106
+                Inters.jqx = comboBox_jqx.Text;
107
+                Inters.sqx = comboBox_sqx.Text;
108
+
109
+                this.Close();
110
+                Inters eachints = new Inters();
111
+                eachints.Ints();
112
+            }
113
+        }
114
+    }
115
+}

+ 120
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/Conn.resx 查看文件

@@ -0,0 +1,120 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<root>
3
+  <!-- 
4
+    Microsoft ResX Schema 
5
+    
6
+    Version 2.0
7
+    
8
+    The primary goals of this format is to allow a simple XML format 
9
+    that is mostly human readable. The generation and parsing of the 
10
+    various data types are done through the TypeConverter classes 
11
+    associated with the data types.
12
+    
13
+    Example:
14
+    
15
+    ... ado.net/XML headers & schema ...
16
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
17
+    <resheader name="version">2.0</resheader>
18
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
19
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
20
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
21
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
22
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
24
+    </data>
25
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
26
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
27
+        <comment>This is a comment</comment>
28
+    </data>
29
+                
30
+    There are any number of "resheader" rows that contain simple 
31
+    name/value pairs.
32
+    
33
+    Each data row contains a name, and value. The row also contains a 
34
+    type or mimetype. Type corresponds to a .NET class that support 
35
+    text/value conversion through the TypeConverter architecture. 
36
+    Classes that don't support this are serialized and stored with the 
37
+    mimetype set.
38
+    
39
+    The mimetype is used for serialized objects, and tells the 
40
+    ResXResourceReader how to depersist the object. This is currently not 
41
+    extensible. For a given mimetype the value must be set accordingly:
42
+    
43
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
44
+    that the ResXResourceWriter will generate, however the reader can 
45
+    read any of the formats listed below.
46
+    
47
+    mimetype: application/x-microsoft.net.object.binary.base64
48
+    value   : The object must be serialized with 
49
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
50
+            : and then encoded with base64 encoding.
51
+    
52
+    mimetype: application/x-microsoft.net.object.soap.base64
53
+    value   : The object must be serialized with 
54
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
55
+            : and then encoded with base64 encoding.
56
+
57
+    mimetype: application/x-microsoft.net.object.bytearray.base64
58
+    value   : The object must be serialized into a byte array 
59
+            : using a System.ComponentModel.TypeConverter
60
+            : and then encoded with base64 encoding.
61
+    -->
62
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
64
+    <xsd:element name="root" msdata:IsDataSet="true">
65
+      <xsd:complexType>
66
+        <xsd:choice maxOccurs="unbounded">
67
+          <xsd:element name="metadata">
68
+            <xsd:complexType>
69
+              <xsd:sequence>
70
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
71
+              </xsd:sequence>
72
+              <xsd:attribute name="name" use="required" type="xsd:string" />
73
+              <xsd:attribute name="type" type="xsd:string" />
74
+              <xsd:attribute name="mimetype" type="xsd:string" />
75
+              <xsd:attribute ref="xml:space" />
76
+            </xsd:complexType>
77
+          </xsd:element>
78
+          <xsd:element name="assembly">
79
+            <xsd:complexType>
80
+              <xsd:attribute name="alias" type="xsd:string" />
81
+              <xsd:attribute name="name" type="xsd:string" />
82
+            </xsd:complexType>
83
+          </xsd:element>
84
+          <xsd:element name="data">
85
+            <xsd:complexType>
86
+              <xsd:sequence>
87
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
88
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
89
+              </xsd:sequence>
90
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
91
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
92
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
93
+              <xsd:attribute ref="xml:space" />
94
+            </xsd:complexType>
95
+          </xsd:element>
96
+          <xsd:element name="resheader">
97
+            <xsd:complexType>
98
+              <xsd:sequence>
99
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
100
+              </xsd:sequence>
101
+              <xsd:attribute name="name" type="xsd:string" use="required" />
102
+            </xsd:complexType>
103
+          </xsd:element>
104
+        </xsd:choice>
105
+      </xsd:complexType>
106
+    </xsd:element>
107
+  </xsd:schema>
108
+  <resheader name="resmimetype">
109
+    <value>text/microsoft-resx</value>
110
+  </resheader>
111
+  <resheader name="version">
112
+    <value>2.0</value>
113
+  </resheader>
114
+  <resheader name="reader">
115
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116
+  </resheader>
117
+  <resheader name="writer">
118
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119
+  </resheader>
120
+</root>

+ 483
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/Connect.cs 查看文件

@@ -0,0 +1,483 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Threading.Tasks;
6
+
7
+using Autodesk.AutoCAD.DatabaseServices;
8
+using Autodesk.AutoCAD.Geometry;
9
+using Autodesk.AutoCAD.ApplicationServices;
10
+using Autodesk.AutoCAD.EditorInput;
11
+using System.Windows.Forms;
12
+
13
+namespace CADTools
14
+{
15
+    class Connect
16
+    {
17
+        Point3dCollection joinpoint = new Point3dCollection();//连接点
18
+
19
+        #region 连接
20
+        /// <summary>
21
+        /// 连接线
22
+        /// </summary>
23
+        public void joinplline()
24
+        {
25
+            ObjectId[] line = BasicFunction.getPll();//获取待连接线
26
+            if (line == null)
27
+                return;
28
+
29
+            //遍历比较待连接线,连接高程相同的两等高线
30
+            Database db = HostApplicationServices.WorkingDatabase;
31
+            DocumentLock doclock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
32
+            Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
33
+
34
+            using (Transaction trans = db.TransactionManager.StartTransaction())
35
+            {
36
+                if (line.Length == 1)
37
+                {
38
+                    ed.WriteMessage("请选择另一条连接线");
39
+                    return;
40
+                }
41
+
42
+                //try
43
+                //{
44
+                Entity entity1 = line[0].GetObject(OpenMode.ForWrite) as Entity;
45
+                Entity entity2 = line[1].GetObject(OpenMode.ForWrite) as Entity;
46
+                if (entity1 is Polyline2d && entity2 is Polyline)
47
+                {
48
+                    Polyline2d pll1 = (Polyline2d)entity1;
49
+                    Polyline pll2 = (Polyline)trans.GetObject(entity2.Id, OpenMode.ForWrite);
50
+                    pll2.Elevation = pll1.Elevation;
51
+                    Calculate(pll1.StartPoint, pll1.EndPoint, pll2.StartPoint, pll2.EndPoint);
52
+                    Polyline pline = new Polyline();
53
+                    pline.AddVertexAt(0, new Point2d(joinpoint[0].X, joinpoint[0].Y), 0, 0, 0);
54
+                    pline.AddVertexAt(1, new Point2d(joinpoint[1].X, joinpoint[1].Y), 0, 0, 0);//创建连接线
55
+
56
+                    if (pll2.Elevation == pll1.Elevation)
57
+                    {
58
+                        pline.Elevation = pll1.Elevation;
59
+                        pll1.JoinEntity(pline);//浩辰的JoinEntity函数会报enotemplementedyet,不知道原因。
60
+                                               //Polyline pll_temp = PllConn(pll2, pline);
61
+                        pll1.JoinEntity(pll2);
62
+                        //Polyline pll_final = Pllpll2d(pll_temp, pll1, trans);
63
+                        //pll1.Erase();
64
+                        pll2.Erase();
65
+                        //BlockTable bt = (BlockTable)(trans.GetObject(db.BlockTableId, OpenMode.ForRead));
66
+                        //BlockTableRecord btr = (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
67
+                        //btr.AppendEntity(pll1);
68
+                        //trans.AddNewlyCreatedDBObject(pll1, true);
69
+                    }
70
+                    else
71
+                        MessageBox.Show("两线高程不一致!", "提示", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation);
72
+                }
73
+                else if (entity1 is Polyline && entity2 is Polyline2d)
74
+                {
75
+                    Polyline pll1 = (Polyline)entity1;
76
+                    Polyline2d pll2 = (Polyline2d)entity2;
77
+                    Calculate(pll1.StartPoint, pll1.EndPoint, pll2.StartPoint, pll2.EndPoint);
78
+                    Polyline pline = new Polyline();
79
+                    pline.AddVertexAt(0, new Point2d(joinpoint[0].X, joinpoint[0].Y), 0, 0, 0);
80
+                    pline.AddVertexAt(1, new Point2d(joinpoint[1].X, joinpoint[1].Y), 0, 0, 0);//创建连接线
81
+
82
+                    if (pll2.Elevation == pll1.Elevation)
83
+                    {
84
+                        pline.Elevation = pll1.Elevation;
85
+                        pll1.JoinEntity(pline);//浩辰的JoinEntity函数会报enotemplementedyet,不知道原因。
86
+                                               //Polyline pll_temp = PllConn(pll1,pline);
87
+                        pll1.JoinEntity(pll2);
88
+                        //Polyline pll_final = Pllpll2d(pll_temp, pll2, trans);
89
+                        //pll1.Erase();
90
+                        pll2.Erase();
91
+                        //BlockTable bt = (BlockTable)(trans.GetObject(db.BlockTableId, OpenMode.ForRead));
92
+                        //BlockTableRecord btr = (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
93
+                        //btr.AppendEntity(pll1);
94
+                        //trans.AddNewlyCreatedDBObject(pll1, true);
95
+                    }
96
+                    else
97
+                        MessageBox.Show("两线高程不一致!", "提示", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation);
98
+                }
99
+                else if (entity1 is Polyline2d && entity2 is Polyline2d)
100
+                {
101
+                    Polyline2d pll1 = (Polyline2d)entity1;
102
+                    Polyline2d pll2 = (Polyline2d)entity2;
103
+                    Calculate(pll1.StartPoint, pll1.EndPoint, pll2.StartPoint, pll2.EndPoint);
104
+                    Point3dCollection pos = new Point3dCollection { joinpoint[0], joinpoint[1] };
105
+                    Polyline2d pline = new Polyline2d(Poly2dType.SimplePoly, pos, 0, false, 0, 0, null);
106
+                    BlockTable bt = (BlockTable)(trans.GetObject(db.BlockTableId, OpenMode.ForRead));
107
+                    BlockTableRecord btr = (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
108
+                    btr.AppendEntity(pline);
109
+                    trans.AddNewlyCreatedDBObject(pline, true);
110
+                    //pline.AppendVertex(0, new Point2d(joinpoint[0].X, joinpoint[0].Y), 0, 0, 0);
111
+                    //pline.AppendVertex(1, new Point2d(joinpoint[1].X, joinpoint[1].Y), 0, 0, 0);//创建连接线
112
+
113
+                    if (pll2.Elevation == pll1.Elevation)
114
+                    {
115
+                        pline.Elevation = pll1.Elevation;
116
+                        //Polyline2d pll_temp = Pll2dConn(pll1, pline,trans);
117
+                        //btr.AppendEntity(pll_temp);
118
+                        //trans.AddNewlyCreatedDBObject(pll_temp, true);
119
+                        pll1.JoinEntity(pline);
120
+                        pll1.JoinEntity(pll2);
121
+                        //Polyline2d pll_final = Pll2dConn(pll_temp, pll2,trans);
122
+                        //pll1.Erase();
123
+                        pline.Erase();
124
+                        pll2.Erase();
125
+                        //pll1.Erase();
126
+                        //btr.AppendEntity(pll1);
127
+                        //trans.AddNewlyCreatedDBObject(pll1, true);
128
+                    }
129
+                    else
130
+                        MessageBox.Show("两线高程不一致!", "提示", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation);
131
+                }
132
+                else
133
+                {
134
+                    Polyline pll1 = (Polyline)entity1;
135
+                    Polyline pll2 = (Polyline)entity2;
136
+                    Calculate(pll1.StartPoint, pll1.EndPoint, pll2.StartPoint, pll2.EndPoint);
137
+                    Polyline pline = new Polyline();
138
+                    pline.AddVertexAt(0, new Point2d(joinpoint[0].X, joinpoint[0].Y), 0, 0, 0);
139
+                    pline.AddVertexAt(1, new Point2d(joinpoint[1].X, joinpoint[1].Y), 0, 0, 0);//创建连接线
140
+
141
+                    if (pll2.Elevation == pll1.Elevation)
142
+                    {
143
+                        pline.Elevation = pll1.Elevation;
144
+                        pll1.JoinEntity(pline);//浩辰的JoinEntity函数会报enotemplementedyet,不知道原因。
145
+                                               //Polyline pll_temp = PllConn(pll1, pline);
146
+                        pll1.JoinEntity(pll2);
147
+                        //Polyline pll_final = PllConn(pll_temp, pll2);
148
+                        //pll1.Erase();
149
+                        pll2.Erase();
150
+                        //BlockTable bt = (BlockTable)(trans.GetObject(db.BlockTableId, OpenMode.ForRead));
151
+                        //BlockTableRecord btr = (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
152
+                        //btr.AppendEntity(pll1);
153
+                        //trans.AddNewlyCreatedDBObject(pll1, true);
154
+                    }
155
+                    else
156
+                        MessageBox.Show("两线高程不一致!", "提示", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Exclamation);
157
+                }
158
+                trans.Commit();
159
+                //}
160
+
161
+
162
+                //catch (Autodesk.AutoCAD.Runtime.Exception ex)
163
+                //{
164
+                //    string str = ex.ToString();
165
+                //    Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog(str);
166
+                //}
167
+            }
168
+            doclock.Dispose();
169
+        }
170
+
171
+
172
+        /// <summary>
173
+        /// 计算获得连接点
174
+        /// </summary>
175
+        private Point3dCollection Calculate(Point3d startpt1, Point3d endpt1, Point3d startpt2, Point3d endpt2)
176
+        {
177
+            Double[] distance=new Double[4];
178
+            joinpoint.Clear();
179
+            int i = 0;
180
+
181
+            //两线段四个端点之间的距离
182
+            distance[0] = Math.Sqrt(Math.Pow((startpt1.X - startpt2.X), 2) + Math.Pow((startpt1.Y - startpt2.Y), 2));
183
+            distance[1] = Math.Sqrt(Math.Pow((startpt1.X - endpt2.X), 2) + Math.Pow((startpt1.Y - endpt2.Y), 2));
184
+            distance[2] = Math.Sqrt(Math.Pow((endpt1.X - startpt2.X), 2) + Math.Pow((endpt1.Y - startpt2.Y), 2));
185
+            distance[3] = Math.Sqrt(Math.Pow((endpt1.X - endpt2.X), 2) + Math.Pow((endpt1.Y - endpt2.Y), 2));
186
+
187
+            //比较获取最小的距离,得到连接点
188
+            for (i = 0; i < distance.Length; i++)
189
+            {
190
+                if (distance[i] == distance.Min())
191
+                    break;
192
+            }
193
+            switch (i.ToString())
194
+            {
195
+                case "0":
196
+                    joinpoint.Add(startpt1);
197
+                    joinpoint.Add(startpt2);
198
+                    break;
199
+
200
+                case "1":
201
+                    joinpoint.Add(startpt1);
202
+                    joinpoint.Add(endpt2);
203
+                    break;
204
+
205
+                case "2":
206
+                    joinpoint.Add(endpt1);
207
+                    joinpoint.Add(startpt2);
208
+                    break;
209
+
210
+                case "3":
211
+                    joinpoint.Add(endpt1);
212
+                    joinpoint.Add(endpt2);
213
+                    break;
214
+            }
215
+            return joinpoint;
216
+        }
217
+
218
+        ///// <summary>
219
+        ///// 连接两条线(两条都是Polyline)
220
+        ///// </summary>
221
+        //private Polyline PllConn(Polyline pll1, Polyline pll2)
222
+        //{
223
+        //    List<Point2d> pllpt = new List<Point2d>();
224
+        //    List<Point2d> pll1pt = new List<Point2d>();
225
+        //    for (int i = 0; i < pll1.NumberOfVertices; i++)
226
+        //    {
227
+        //        pllpt.Add(pll1.GetPoint2dAt(i));
228
+        //    }
229
+        //    for (int i = 0; i < pll2.NumberOfVertices; i++)
230
+        //    {
231
+        //        pll1pt.Add(pll2.GetPoint2dAt(i));
232
+        //    }
233
+        //    //if (pllpt[pllpt.Count - 1] != pll1pt[pll1pt.Count - 1])
234
+        //    //    pllpt.Reverse();
235
+        //    //else if (pllpt[0] != pll1pt[0])
236
+        //    //    pll1pt.Reverse();
237
+        //    if (pllpt[pllpt.Count - 1] == pll1pt[pll1pt.Count - 1])
238
+        //        pll1pt.Reverse();
239
+        //    else if (pllpt[0] == pll1pt[pll1pt.Count - 1])
240
+        //    {
241
+        //        pllpt.Reverse();
242
+        //        pll1pt.Reverse();
243
+        //    }
244
+        //    else if (pllpt[0] == pll1pt[0])
245
+        //        pllpt.Reverse();
246
+        //        for (int i = 0; i < pll1pt.Count; i++)
247
+        //    {
248
+        //        if (pllpt.Contains(pll1pt[i]))
249
+        //            continue;
250
+        //        else
251
+        //            pllpt.Add(pll1pt[i]);
252
+        //    }
253
+        //    Polyline pline = new Polyline();
254
+        //    for (int i = 0; i < pllpt.Count; i++)
255
+        //    {
256
+        //        pline.AddVertexAt(i, new Point2d(pllpt[i].X, pllpt[i].Y), 0, 0, 0);
257
+        //    }
258
+        //    pline.Elevation = pll1.Elevation;
259
+        //    pline.LinetypeId = pll1.LinetypeId;
260
+        //    pline.Color = pll1.Color;
261
+        //    pline.Layer = pll1.Layer;
262
+        //    return pline;
263
+        //}
264
+
265
+
266
+        ///// <summary>
267
+        ///// 连接两条线(两条都是Polyline2d)
268
+        ///// </summary>
269
+        //private Polyline2d Pll2dConn(Polyline2d pll1, Polyline2d pll2, Transaction tr)
270
+        //{
271
+        //    List<Point3d> pllpt = new List<Point3d>();
272
+        //    List<Point3d> pll1pt = new List<Point3d>();
273
+        //    List<double> bulgeList = new List<double>();//存凸度
274
+        //    List<double> bulgeList1 = new List<double>();
275
+        //    Point3dCollection ptcoll = new Point3dCollection();
276
+        //    DoubleCollection dbcoll = new DoubleCollection();
277
+        //    foreach(ObjectId id in pll1)
278
+        //    {
279
+        //        Vertex2d vx = (Vertex2d)tr.GetObject(id, OpenMode.ForRead);
280
+        //        if (vx.VertexType != Vertex2dType.SplineControlVertex)
281
+        //        { 
282
+        //            pllpt.Add(vx.Position);
283
+        //            bulgeList.Add(vx.Bulge);
284
+        //        }
285
+        //    }
286
+        //    foreach (ObjectId id in pll2)
287
+        //    {
288
+        //        Vertex2d vx = (Vertex2d)tr.GetObject(id, OpenMode.ForRead);
289
+        //        if (vx.VertexType != Vertex2dType.SplineControlVertex)
290
+        //        {
291
+        //            pll1pt.Add(vx.Position);
292
+        //            bulgeList1.Add(vx.Bulge);
293
+        //        }
294
+        //    }
295
+        //    //if (pllpt[pllpt.Count - 1] != pll1pt[pll1pt.Count - 1])
296
+        //    //{
297
+        //    //    pllpt.Reverse();
298
+        //    //    bulgeList.Reverse();
299
+        //    //}
300
+        //    //else if (pllpt[0] != pll1pt[0])
301
+        //    //{ 
302
+        //    //    pll1pt.Reverse();
303
+        //    //    bulgeList1.Reverse();
304
+        //    //}
305
+        //    if (pllpt[pllpt.Count - 1] == pll1pt[pll1pt.Count - 1])
306
+        //    { 
307
+        //        pll1pt.Reverse();
308
+        //        bulgeList1.Reverse();
309
+        //    }
310
+        //    else if (pllpt[0] == pll1pt[pll1pt.Count - 1])
311
+        //    {
312
+        //        pllpt.Reverse();
313
+        //        pll1pt.Reverse();
314
+        //        bulgeList.Reverse();
315
+        //        bulgeList1.Reverse();
316
+        //    }
317
+        //    else if (pllpt[0] == pll1pt[0])
318
+        //    { 
319
+        //        pllpt.Reverse();
320
+        //        bulgeList1.Reverse();
321
+        //    }
322
+        //    for (int i = 0; i < pll1pt.Count; i++)
323
+        //    {
324
+        //        if (pllpt.Contains(pll1pt[i]))
325
+        //            continue;
326
+        //        else
327
+        //        { 
328
+        //            pllpt.Add(pll1pt[i]);
329
+        //            bulgeList.Add(bulgeList1[i]);
330
+        //        }
331
+        //    }
332
+        //    for (int i = 0; i < pllpt.Count; i++)
333
+        //    {
334
+        //        ptcoll.Add(pllpt[i]);
335
+        //    }
336
+        //    for (int i = 0; i < bulgeList.Count; i++)
337
+        //    {
338
+        //        dbcoll.Add(bulgeList[i]);
339
+        //    }
340
+        //    Polyline2d pline = new Polyline2d(pll1.PolyType, ptcoll, 0, false, 0, 0, dbcoll);
341
+        //    pline.Elevation = pll1.Elevation;
342
+        //    pline.LinetypeId = pll1.LinetypeId;
343
+        //    pline.Color = pll1.Color;
344
+        //    pline.Layer = pll1.Layer;
345
+        //    return pline;
346
+        //}
347
+
348
+
349
+        ///// <summary>
350
+        ///// 连接两条线(一条是Polyline,一条是Polyline2d,连接后的线为Polyline)
351
+        ///// </summary>
352
+        //private Polyline Pllpll2d(Polyline pll1, Polyline2d pll2, Transaction tr)
353
+        //{
354
+        //    List<Point3d> pllpt = new List<Point3d>();
355
+        //    List<Point3d> pll1pt = new List<Point3d>();
356
+        //    for (int i = 0; i < pll1.NumberOfVertices; i++)
357
+        //    {
358
+        //        pllpt.Add(pll1.GetPoint3dAt(i));
359
+        //    }
360
+        //    foreach (ObjectId id in pll2)
361
+        //    {
362
+        //        Vertex2d vx = (Vertex2d)tr.GetObject(id, OpenMode.ForRead);
363
+        //        if (vx.VertexType != Vertex2dType.SplineControlVertex)
364
+        //        {
365
+        //            pll1pt.Add(vx.Position);
366
+        //        }
367
+        //    }
368
+        //    //if (pllpt[pllpt.Count - 1] != pll1pt[pll1pt.Count - 1])
369
+        //    //    pllpt.Reverse();
370
+        //    //else if (pllpt[0] != pll1pt[0])
371
+        //    //    pll1pt.Reverse();
372
+        //    if (pllpt[pllpt.Count - 1] == pll1pt[pll1pt.Count - 1])
373
+        //        pll1pt.Reverse();
374
+        //    else if (pllpt[0] == pll1pt[pll1pt.Count - 1])
375
+        //    {
376
+        //        pllpt.Reverse();
377
+        //        pll1pt.Reverse();
378
+        //    }
379
+        //    else if (pllpt[0] == pll1pt[0])
380
+        //        pllpt.Reverse();
381
+        //    for (int i = 0; i < pll1pt.Count; i++)
382
+        //    {
383
+        //        if (pllpt.Contains(pll1pt[i]))
384
+        //            continue;
385
+        //        else
386
+        //            pllpt.Add(pll1pt[i]);
387
+        //    }
388
+        //    Polyline pline = new Polyline();
389
+        //    for (int i = 0; i < pllpt.Count; i++)
390
+        //    {
391
+        //        pline.AddVertexAt(i, new Point2d(pllpt[i].X, pllpt[i].Y), 0, 0, 0);
392
+        //    }
393
+        //    pline.Elevation = pll1.Elevation;
394
+        //    pline.LinetypeId = pll1.LinetypeId;
395
+        //    pline.Color = pll1.Color;
396
+        //    pline.Layer = pll1.Layer;
397
+        //    return pline;
398
+        //}
399
+
400
+        #endregion
401
+
402
+
403
+        //public void conn()
404
+        //{
405
+        //    ObjectIdCollection ids = getEntity();
406
+        //    BlockReference br = null;
407
+        //    Polyline pll = null;
408
+        //    DBObjectCollection objcoll = new DBObjectCollection();
409
+        //    string Brname = "";
410
+        //    Point3d Brposition = new Point3d();
411
+
412
+        //    Database db = HostApplicationServices.WorkingDatabase;
413
+        //    DocumentLock doclock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
414
+        //    Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
415
+        //    using (Transaction trans = db.TransactionManager.StartTransaction())
416
+        //    {
417
+        //        foreach(ObjectId id in ids)
418
+        //        {
419
+        //            if (trans.GetObject(id, OpenMode.ForRead) is BlockReference)
420
+        //            {
421
+        //                br = trans.GetObject(id, OpenMode.ForRead)as BlockReference;
422
+        //                Brname = br.Name;
423
+        //                Brposition = br.Position;
424
+        //            }
425
+        //            if (trans.GetObject(id, OpenMode.ForRead) is Polyline)
426
+        //            {
427
+        //                pll = trans.GetObject(id, OpenMode.ForRead) as Polyline;
428
+        //            }
429
+        //        }
430
+        //        br.Explode(objcoll);
431
+        //        trans.Commit();
432
+        //    }
433
+
434
+        //    foreach (Entity ent in objcoll)
435
+        //    {
436
+        //        using (Transaction trans = db.TransactionManager.StartTransaction())
437
+        //        {
438
+        //            BlockTable blocktable = trans.GetObject(db.BlockTableId, OpenMode.ForWrite) as BlockTable;
439
+        //            BlockTableRecord blocktablerecord = trans.GetObject(blocktable[BlockTableRecord.ModelSpace],
440
+        //                OpenMode.ForWrite) as BlockTableRecord;
441
+        //            blocktablerecord.AppendEntity(ent);
442
+        //            trans.AddNewlyCreatedDBObject(ent, true);
443
+        //            trans.Commit();
444
+        //        }
445
+        //    }
446
+
447
+
448
+        //    doclock.Dispose();
449
+        //}
450
+
451
+
452
+        //private static ObjectIdCollection getEntity()
453
+        //{
454
+        //    ObjectIdCollection ids = new ObjectIdCollection();
455
+
456
+        //    Document doc = Application.DocumentManager.MdiActiveDocument;
457
+        //    Database db = doc.Database;
458
+        //    Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
459
+
460
+        //    TypedValue[] value = new TypedValue[]
461
+        //    {
462
+        //        new TypedValue((int)DxfCode.Start,"Insert,POLYLINE"),
463
+        //    };//设置筛选条件
464
+        //    SelectionFilter filter = new SelectionFilter(value);
465
+        //    //选择区域中全部对象
466
+        //    //PromptSelectionResult psr = ed.SelectAll(filter);
467
+        //    // 要求在图形区域中手动选择对象
468
+        //    PromptSelectionResult psr = ed.GetSelection(filter);
469
+
470
+
471
+        //    if (psr.Status == PromptStatus.OK)
472
+        //    {
473
+        //        using (Transaction trans = db.TransactionManager.StartTransaction())
474
+        //        {
475
+        //            SelectionSet ss = psr.Value;
476
+        //            ids = new ObjectIdCollection(ss.GetObjectIds());
477
+        //            trans.Commit();
478
+        //        }
479
+        //    }
480
+        //    return ids;
481
+        //}
482
+    }
483
+}

+ 175
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/ContourLineFix.cs 查看文件

@@ -0,0 +1,175 @@
1
+using Autodesk.AutoCAD.ApplicationServices;
2
+using Autodesk.AutoCAD.DatabaseServices;
3
+using Autodesk.AutoCAD.EditorInput;
4
+using Autodesk.AutoCAD.Geometry;
5
+using Autodesk.AutoCAD.GraphicsInterface;
6
+using System;
7
+using System.Collections.Generic;
8
+using System.Linq;
9
+using System.Text;
10
+using System.Threading.Tasks;
11
+
12
+namespace CADTools
13
+{
14
+    class ContourLineFix
15
+    {
16
+        public void Clfix()
17
+        {
18
+            Database db = HostApplicationServices.WorkingDatabase;
19
+            Document doc = Application.DocumentManager.MdiActiveDocument;
20
+            DocumentLock doclock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
21
+
22
+            ObjectId jigid = new ObjectId();
23
+            PromptPointResult pPtRes;
24
+            PromptPointOptions pPtOpts = new PromptPointOptions("");
25
+
26
+            pPtOpts.Message = "选择起点\n ";
27
+            pPtRes = doc.Editor.GetPoint(pPtOpts);
28
+            Point3d ptStart = pPtRes.Value;
29
+
30
+            if (pPtRes.Status == PromptStatus.OK)
31
+            {
32
+                LineJig lJig = new LineJig(ptStart);
33
+                PromptResult PR = doc.Editor.Drag(lJig);
34
+                if (PR.Status == PromptStatus.OK)
35
+                {
36
+                    jigid = BasicFunction.AddObj(doc, lJig.line_1);
37
+                    Autodesk.AutoCAD.DatabaseServices.Line jigl = (Autodesk.AutoCAD.DatabaseServices.Line)BasicFunction.GetDBObject(jigid);
38
+                    List<ObjectId> plllist = Pllsort(jigl);
39
+                    Autodesk.AutoCAD.DatabaseServices.Polyline pll_s = (Autodesk.AutoCAD.DatabaseServices.Polyline)BasicFunction.GetDBObject(plllist[0]);
40
+                    Autodesk.AutoCAD.DatabaseServices.Polyline pll_w = (Autodesk.AutoCAD.DatabaseServices.Polyline)BasicFunction.GetDBObject(plllist[plllist.Count - 1]);
41
+                    double dgj = (pll_s.Elevation - pll_w.Elevation)/(plllist.Count - 1);
42
+                    double ele = pll_s.Elevation;
43
+                    using (Transaction tr = db.TransactionManager.StartTransaction())
44
+                    {
45
+                        for (int i = 1; i < plllist.Count - 1; i++)
46
+                        {
47
+                            Autodesk.AutoCAD.DatabaseServices.Polyline pll = (Autodesk.AutoCAD.DatabaseServices.Polyline)tr.GetObject(plllist[i], OpenMode.ForWrite, true);
48
+                            pll.Elevation = ele - dgj;
49
+                            ele = ele - dgj;
50
+                        }
51
+                        Autodesk.AutoCAD.DatabaseServices.Line jl = (Autodesk.AutoCAD.DatabaseServices.Line)tr.GetObject(jigid, OpenMode.ForWrite, true);
52
+                        jl.Erase();
53
+                        tr.Commit();
54
+                    }
55
+                    Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
56
+                    ed.WriteMessage("修改完成\n");
57
+                }
58
+
59
+            }
60
+            doclock.Dispose();
61
+        }
62
+
63
+
64
+        private static List<ObjectId> Pllsort(Line jigl)
65
+        {
66
+            List<ObjectId> sortedid = new List<ObjectId>();
67
+            Point3dCollection ptcoll = new Point3dCollection();
68
+            var plane = new Plane(Point3d.Origin, Vector3d.ZAxis);
69
+            ptcoll.Add(jigl.StartPoint);
70
+            ptcoll.Add(jigl.EndPoint);
71
+
72
+            Database db = HostApplicationServices.WorkingDatabase;
73
+            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
74
+            TypedValue[] value = new TypedValue[]
75
+                {
76
+                new TypedValue((int)DxfCode.Start,"LWPOLYLINE"),
77
+                };//设置筛选条件
78
+            SelectionFilter filter = new SelectionFilter(value);
79
+            // 要求在图形区域中手动选择对象
80
+            PromptSelectionResult psr = ed.SelectFence(ptcoll, filter);
81
+
82
+            if (psr.Status == PromptStatus.OK)
83
+            {
84
+                SelectionSet ss = psr.Value;
85
+                ObjectIdCollection idcoll = new ObjectIdCollection(ss.GetObjectIds());
86
+
87
+                using (Transaction trans = db.TransactionManager.StartTransaction())
88
+                {
89
+                    for (int i = 1; i < idcoll.Count; i++)
90
+                    {
91
+                        Autodesk.AutoCAD.DatabaseServices.Polyline pll = (Autodesk.AutoCAD.DatabaseServices.Polyline)BasicFunction.GetDBObject(idcoll[i]);
92
+                        Point3dCollection itsresult1 = new Point3dCollection();
93
+                        pll.IntersectWith(jigl, Intersect.OnBothOperands, plane, itsresult1, IntPtr.Zero, IntPtr.Zero);
94
+                        double x1 = itsresult1[0].X;
95
+                        double y1 = itsresult1[0].Y;
96
+                        double x2 = jigl.StartPoint.X;
97
+                        double y2 = jigl.StartPoint.Y;
98
+                        double tempdist = Math.Abs(Math.Sqrt(Math.Pow(x1 - x2, 2) + Math.Pow(y1 - y2, 2)));
99
+                        ObjectId temp = idcoll[i];
100
+                        for (int j = i - 1; j >=0; j--)
101
+                        {
102
+                            Autodesk.AutoCAD.DatabaseServices.Polyline pll2 = (Autodesk.AutoCAD.DatabaseServices.Polyline)BasicFunction.GetDBObject(idcoll[j]);
103
+                        Point3dCollection itsresult2 = new Point3dCollection();
104
+                            pll2.IntersectWith(jigl, Intersect.OnBothOperands, plane, itsresult2, IntPtr.Zero, IntPtr.Zero);
105
+                            double x3 = itsresult2[0].X;
106
+                            double y3 = itsresult2[0].Y;
107
+                            double tempdist2 = Math.Abs(Math.Sqrt(Math.Pow(x3 - x2, 2) + Math.Pow(y3 - y2, 2)));
108
+                            if (tempdist < tempdist2)
109
+                            {
110
+                                idcoll[j + 1] = idcoll[j];
111
+                                idcoll[j] = temp;
112
+                            }
113
+                            else
114
+                                break;
115
+                        }
116
+                    }
117
+                    foreach (ObjectId id in idcoll)
118
+                    {
119
+                        sortedid.Add(id);
120
+                    }
121
+                    trans.Commit();
122
+                }
123
+            }
124
+            return sortedid;
125
+        }
126
+    }
127
+
128
+    public class LineJig : DrawJig
129
+    {
130
+        public Line line_1;
131
+        public Point3d BasePnt;
132
+        public Point3d AcquirePnt;
133
+
134
+        public LineJig(Point3d _basePnt)
135
+        {
136
+            line_1 = new Line();
137
+
138
+            BasePnt = _basePnt;
139
+        }
140
+
141
+        protected override SamplerStatus Sampler(JigPrompts prompts)
142
+        {
143
+            JigPromptPointOptions JPPO = new JigPromptPointOptions();
144
+            JPPO.Message = "选择终点\n";
145
+            JPPO.UserInputControls = (UserInputControls.Accept3dCoordinates | UserInputControls.NullResponseAccepted | UserInputControls.AnyBlankTerminatesInput);
146
+
147
+            PromptPointResult PR = prompts.AcquirePoint(JPPO);
148
+
149
+            if (PR.Status != PromptStatus.OK)
150
+                return SamplerStatus.Cancel;
151
+
152
+            if (PR.Value == AcquirePnt)
153
+                return SamplerStatus.NoChange;
154
+
155
+            AcquirePnt = PR.Value;
156
+            return SamplerStatus.OK;
157
+        }
158
+
159
+        protected override bool WorldDraw(WorldDraw draw)
160
+        {
161
+            Point3d point_1 = new Point3d(BasePnt.X, BasePnt.Y, 0);
162
+            Point3d point_2 = new Point3d(AcquirePnt.X, AcquirePnt.Y, 0);
163
+            line_1.StartPoint = point_1;
164
+            line_1.EndPoint = point_2;
165
+            line_1.Color = Autodesk.AutoCAD.Colors.Color.FromColorIndex(Autodesk.AutoCAD.Colors.ColorMethod.ByColor, 7);
166
+
167
+            draw.Geometry.Draw(line_1);
168
+            return true;
169
+        }
170
+    }
171
+
172
+
173
+}
174
+
175
+

+ 156
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/CutDgx.Designer.cs 查看文件

@@ -0,0 +1,156 @@
1
+
2
+namespace CADTools
3
+{
4
+    partial class CutDgx
5
+    {
6
+        /// <summary>
7
+        /// 必需的设计器变量。
8
+        /// </summary>
9
+        private System.ComponentModel.IContainer components = null;
10
+
11
+        /// <summary>
12
+        /// 清理所有正在使用的资源。
13
+        /// </summary>
14
+        /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
15
+        protected override void Dispose(bool disposing)
16
+        {
17
+            if (disposing && (components != null))
18
+            {
19
+                components.Dispose();
20
+            }
21
+            base.Dispose(disposing);
22
+        }
23
+
24
+        #region Windows 窗体设计器生成的代码
25
+
26
+        /// <summary>
27
+        /// 设计器支持所需的方法 - 不要修改
28
+        /// 使用代码编辑器修改此方法的内容。
29
+        /// </summary>
30
+        private void InitializeComponent()
31
+        {
32
+            this.label1 = new System.Windows.Forms.Label();
33
+            this.label2 = new System.Windows.Forms.Label();
34
+            this.label3 = new System.Windows.Forms.Label();
35
+            this.label4 = new System.Windows.Forms.Label();
36
+            this.comboBox_jqx = new System.Windows.Forms.ComboBox();
37
+            this.comboBox_sqx = new System.Windows.Forms.ComboBox();
38
+            this.textBox_cj = new System.Windows.Forms.TextBox();
39
+            this.textBox_ignore = new System.Windows.Forms.TextBox();
40
+            this.button_ok = new System.Windows.Forms.Button();
41
+            this.SuspendLayout();
42
+            // 
43
+            // label1
44
+            // 
45
+            this.label1.AutoSize = true;
46
+            this.label1.Location = new System.Drawing.Point(64, 48);
47
+            this.label1.Name = "label1";
48
+            this.label1.Size = new System.Drawing.Size(97, 15);
49
+            this.label1.TabIndex = 0;
50
+            this.label1.Text = "计曲线图层:";
51
+            // 
52
+            // label2
53
+            // 
54
+            this.label2.AutoSize = true;
55
+            this.label2.Location = new System.Drawing.Point(67, 114);
56
+            this.label2.Name = "label2";
57
+            this.label2.Size = new System.Drawing.Size(97, 15);
58
+            this.label2.TabIndex = 1;
59
+            this.label2.Text = "首曲线图层:";
60
+            // 
61
+            // label3
62
+            // 
63
+            this.label3.AutoSize = true;
64
+            this.label3.Location = new System.Drawing.Point(371, 48);
65
+            this.label3.Name = "label3";
66
+            this.label3.Size = new System.Drawing.Size(82, 15);
67
+            this.label3.TabIndex = 2;
68
+            this.label3.Text = "裁剪宽度:";
69
+            // 
70
+            // label4
71
+            // 
72
+            this.label4.AutoSize = true;
73
+            this.label4.Location = new System.Drawing.Point(359, 119);
74
+            this.label4.Name = "label4";
75
+            this.label4.Size = new System.Drawing.Size(97, 15);
76
+            this.label4.TabIndex = 3;
77
+            this.label4.Text = "可忽略阈值:";
78
+            // 
79
+            // comboBox_jqx
80
+            // 
81
+            this.comboBox_jqx.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
82
+            this.comboBox_jqx.FormattingEnabled = true;
83
+            this.comboBox_jqx.Location = new System.Drawing.Point(170, 45);
84
+            this.comboBox_jqx.Name = "comboBox_jqx";
85
+            this.comboBox_jqx.Size = new System.Drawing.Size(141, 23);
86
+            this.comboBox_jqx.TabIndex = 4;
87
+            // 
88
+            // comboBox_sqx
89
+            // 
90
+            this.comboBox_sqx.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
91
+            this.comboBox_sqx.FormattingEnabled = true;
92
+            this.comboBox_sqx.Location = new System.Drawing.Point(173, 111);
93
+            this.comboBox_sqx.Name = "comboBox_sqx";
94
+            this.comboBox_sqx.Size = new System.Drawing.Size(141, 23);
95
+            this.comboBox_sqx.TabIndex = 5;
96
+            // 
97
+            // textBox_cj
98
+            // 
99
+            this.textBox_cj.Location = new System.Drawing.Point(462, 45);
100
+            this.textBox_cj.Name = "textBox_cj";
101
+            this.textBox_cj.Size = new System.Drawing.Size(100, 25);
102
+            this.textBox_cj.TabIndex = 6;
103
+            // 
104
+            // textBox_ignore
105
+            // 
106
+            this.textBox_ignore.Location = new System.Drawing.Point(462, 109);
107
+            this.textBox_ignore.Name = "textBox_ignore";
108
+            this.textBox_ignore.Size = new System.Drawing.Size(100, 25);
109
+            this.textBox_ignore.TabIndex = 7;
110
+            // 
111
+            // button_ok
112
+            // 
113
+            this.button_ok.Location = new System.Drawing.Point(290, 169);
114
+            this.button_ok.Name = "button_ok";
115
+            this.button_ok.Size = new System.Drawing.Size(75, 33);
116
+            this.button_ok.TabIndex = 10;
117
+            this.button_ok.Text = "确 定";
118
+            this.button_ok.UseVisualStyleBackColor = true;
119
+            this.button_ok.Click += new System.EventHandler(this.button_ok_Click);
120
+            // 
121
+            // Form1
122
+            // 
123
+            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
124
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
125
+            this.ClientSize = new System.Drawing.Size(664, 228);
126
+            this.Controls.Add(this.button_ok);
127
+            this.Controls.Add(this.textBox_ignore);
128
+            this.Controls.Add(this.textBox_cj);
129
+            this.Controls.Add(this.comboBox_sqx);
130
+            this.Controls.Add(this.comboBox_jqx);
131
+            this.Controls.Add(this.label4);
132
+            this.Controls.Add(this.label3);
133
+            this.Controls.Add(this.label2);
134
+            this.Controls.Add(this.label1);
135
+            this.Name = "Form1";
136
+            this.Text = "等高线裁剪";
137
+            this.Load += new System.EventHandler(this.Form1_Load);
138
+            this.ResumeLayout(false);
139
+            this.PerformLayout();
140
+
141
+        }
142
+
143
+        #endregion
144
+
145
+        private System.Windows.Forms.Label label1;
146
+        private System.Windows.Forms.Label label2;
147
+        private System.Windows.Forms.Label label3;
148
+        private System.Windows.Forms.Label label4;
149
+        private System.Windows.Forms.ComboBox comboBox_jqx;
150
+        private System.Windows.Forms.ComboBox comboBox_sqx;
151
+        private System.Windows.Forms.TextBox textBox_cj;
152
+        private System.Windows.Forms.TextBox textBox_ignore;
153
+        private System.Windows.Forms.Button button_ok;
154
+    }
155
+}
156
+

+ 96
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/CutDgx.cs 查看文件

@@ -0,0 +1,96 @@
1
+using Autodesk.AutoCAD.DatabaseServices;
2
+using System;
3
+using System.Collections.Generic;
4
+using System.ComponentModel;
5
+using System.Data;
6
+using System.Drawing;
7
+using System.Linq;
8
+using System.Text;
9
+using System.Threading.Tasks;
10
+using System.Windows.Forms;
11
+
12
+namespace CADTools
13
+{
14
+    public partial class CutDgx : Form
15
+    {
16
+        public CutDgx()
17
+        {
18
+            InitializeComponent();
19
+        }
20
+
21
+        private void Form1_Load(object sender, EventArgs e)
22
+        {
23
+            this.comboBox_jqx.DropDownStyle = ComboBoxStyle.DropDownList;
24
+            this.comboBox_sqx.DropDownStyle = ComboBoxStyle.DropDownList;
25
+
26
+            //自动填充下拉框
27
+            Database database = Autodesk.AutoCAD.DatabaseServices.HostApplicationServices.WorkingDatabase;
28
+            using (Transaction traction = database.TransactionManager.StartTransaction())
29
+            {
30
+                //存放所有图层名
31
+                List<string> alllayername = new List<string>();
32
+                LayerTable layertable = traction.GetObject(database.LayerTableId, OpenMode.ForRead) as LayerTable;
33
+                foreach (ObjectId objid in layertable)
34
+                {
35
+                    LayerTableRecord layertablerecord = traction.GetObject(objid, OpenMode.ForRead) as LayerTableRecord;
36
+                    alllayername.Add(layertablerecord.Name);
37
+                }
38
+
39
+                alllayername.Sort();
40
+
41
+                for (int i = 0; i < alllayername.Count; i++)
42
+                {
43
+                    this.comboBox_jqx.Items.Add(alllayername[i]);
44
+                    this.comboBox_sqx.Items.Add(alllayername[i]);
45
+                }
46
+
47
+                if (alllayername.Contains("8110"))
48
+                {
49
+                    int index = alllayername.IndexOf("8110");
50
+                    this.comboBox_sqx.SelectedIndex = index;
51
+                }
52
+                if (alllayername.Contains("8120"))
53
+                {
54
+                    int index = alllayername.IndexOf("8120");
55
+                    this.comboBox_jqx.SelectedIndex = index;
56
+                }
57
+                traction.Commit();
58
+            }
59
+        }
60
+
61
+        private void button_ok_Click(object sender, EventArgs e)
62
+        {
63
+            if (comboBox_jqx.Text == "")
64
+                MessageBox.Show("请选择计曲线图层");
65
+            if (comboBox_sqx.Text == "")
66
+                MessageBox.Show("请选择首曲线图层");
67
+            if (textBox_cj.Text == "")
68
+                MessageBox.Show("请输入裁剪宽度");
69
+            //if (textBox_dgj.Text == "")
70
+            //    MessageBox.Show("请输入等高距");
71
+            if (textBox_ignore.Text == "")
72
+                MessageBox.Show("请输入可忽略阈值");
73
+            if(!double.TryParse(textBox_cj.Text, out double doubleResult1))
74
+            {
75
+                MessageBox.Show("裁剪宽度必须为数字");
76
+            }
77
+            //if (!double.TryParse(textBox_dgj.Text, out double doubleResult2))
78
+            //{
79
+            //    MessageBox.Show("等高距必须为数字");
80
+            //}
81
+            if (!double.TryParse(textBox_ignore.Text, out double doubleResult3))
82
+            {
83
+                MessageBox.Show("可忽略阈值必须为数字");
84
+            }
85
+
86
+            string jqx = comboBox_jqx.Text;
87
+            string sqx = comboBox_sqx.Text;
88
+            double cj = double.Parse(textBox_cj.Text);
89
+            //double dgj = double.Parse(textBox_dgj.Text);
90
+            double ignore = double.Parse(textBox_ignore.Text);
91
+            cutdgx_method ct = new cutdgx_method();
92
+            ct.cutdgx(jqx, sqx, cj, ignore);
93
+            this.Close();
94
+        }
95
+    }
96
+}

+ 120
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/CutDgx.resx 查看文件

@@ -0,0 +1,120 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<root>
3
+  <!-- 
4
+    Microsoft ResX Schema 
5
+    
6
+    Version 2.0
7
+    
8
+    The primary goals of this format is to allow a simple XML format 
9
+    that is mostly human readable. The generation and parsing of the 
10
+    various data types are done through the TypeConverter classes 
11
+    associated with the data types.
12
+    
13
+    Example:
14
+    
15
+    ... ado.net/XML headers & schema ...
16
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
17
+    <resheader name="version">2.0</resheader>
18
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
19
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
20
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
21
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
22
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
24
+    </data>
25
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
26
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
27
+        <comment>This is a comment</comment>
28
+    </data>
29
+                
30
+    There are any number of "resheader" rows that contain simple 
31
+    name/value pairs.
32
+    
33
+    Each data row contains a name, and value. The row also contains a 
34
+    type or mimetype. Type corresponds to a .NET class that support 
35
+    text/value conversion through the TypeConverter architecture. 
36
+    Classes that don't support this are serialized and stored with the 
37
+    mimetype set.
38
+    
39
+    The mimetype is used for serialized objects, and tells the 
40
+    ResXResourceReader how to depersist the object. This is currently not 
41
+    extensible. For a given mimetype the value must be set accordingly:
42
+    
43
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
44
+    that the ResXResourceWriter will generate, however the reader can 
45
+    read any of the formats listed below.
46
+    
47
+    mimetype: application/x-microsoft.net.object.binary.base64
48
+    value   : The object must be serialized with 
49
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
50
+            : and then encoded with base64 encoding.
51
+    
52
+    mimetype: application/x-microsoft.net.object.soap.base64
53
+    value   : The object must be serialized with 
54
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
55
+            : and then encoded with base64 encoding.
56
+
57
+    mimetype: application/x-microsoft.net.object.bytearray.base64
58
+    value   : The object must be serialized into a byte array 
59
+            : using a System.ComponentModel.TypeConverter
60
+            : and then encoded with base64 encoding.
61
+    -->
62
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
64
+    <xsd:element name="root" msdata:IsDataSet="true">
65
+      <xsd:complexType>
66
+        <xsd:choice maxOccurs="unbounded">
67
+          <xsd:element name="metadata">
68
+            <xsd:complexType>
69
+              <xsd:sequence>
70
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
71
+              </xsd:sequence>
72
+              <xsd:attribute name="name" use="required" type="xsd:string" />
73
+              <xsd:attribute name="type" type="xsd:string" />
74
+              <xsd:attribute name="mimetype" type="xsd:string" />
75
+              <xsd:attribute ref="xml:space" />
76
+            </xsd:complexType>
77
+          </xsd:element>
78
+          <xsd:element name="assembly">
79
+            <xsd:complexType>
80
+              <xsd:attribute name="alias" type="xsd:string" />
81
+              <xsd:attribute name="name" type="xsd:string" />
82
+            </xsd:complexType>
83
+          </xsd:element>
84
+          <xsd:element name="data">
85
+            <xsd:complexType>
86
+              <xsd:sequence>
87
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
88
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
89
+              </xsd:sequence>
90
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
91
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
92
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
93
+              <xsd:attribute ref="xml:space" />
94
+            </xsd:complexType>
95
+          </xsd:element>
96
+          <xsd:element name="resheader">
97
+            <xsd:complexType>
98
+              <xsd:sequence>
99
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
100
+              </xsd:sequence>
101
+              <xsd:attribute name="name" type="xsd:string" use="required" />
102
+            </xsd:complexType>
103
+          </xsd:element>
104
+        </xsd:choice>
105
+      </xsd:complexType>
106
+    </xsd:element>
107
+  </xsd:schema>
108
+  <resheader name="resmimetype">
109
+    <value>text/microsoft-resx</value>
110
+  </resheader>
111
+  <resheader name="version">
112
+    <value>2.0</value>
113
+  </resheader>
114
+  <resheader name="reader">
115
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116
+  </resheader>
117
+  <resheader name="writer">
118
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119
+  </resheader>
120
+</root>

+ 135
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/CutDgxByTK.Designer.cs 查看文件

@@ -0,0 +1,135 @@
1
+
2
+namespace CADTools
3
+{
4
+    partial class CutDgxByTK
5
+    {
6
+        /// <summary>
7
+        /// Required designer variable.
8
+        /// </summary>
9
+        private System.ComponentModel.IContainer components = null;
10
+
11
+        /// <summary>
12
+        /// Clean up any resources being used.
13
+        /// </summary>
14
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
15
+        protected override void Dispose(bool disposing)
16
+        {
17
+            if (disposing && (components != null))
18
+            {
19
+                components.Dispose();
20
+            }
21
+            base.Dispose(disposing);
22
+        }
23
+
24
+        #region Windows Form Designer generated code
25
+
26
+        /// <summary>
27
+        /// Required method for Designer support - do not modify
28
+        /// the contents of this method with the code editor.
29
+        /// </summary>
30
+        private void InitializeComponent()
31
+        {
32
+            this.label1 = new System.Windows.Forms.Label();
33
+            this.label2 = new System.Windows.Forms.Label();
34
+            this.label3 = new System.Windows.Forms.Label();
35
+            this.comboBox_sqx = new System.Windows.Forms.ComboBox();
36
+            this.comboBox_jqx = new System.Windows.Forms.ComboBox();
37
+            this.comboBox_tk = new System.Windows.Forms.ComboBox();
38
+            this.button_ok = new System.Windows.Forms.Button();
39
+            this.SuspendLayout();
40
+            // 
41
+            // label1
42
+            // 
43
+            this.label1.AutoSize = true;
44
+            this.label1.Location = new System.Drawing.Point(32, 39);
45
+            this.label1.Name = "label1";
46
+            this.label1.Size = new System.Drawing.Size(127, 15);
47
+            this.label1.TabIndex = 0;
48
+            this.label1.Text = "首曲线所在图层:";
49
+            // 
50
+            // label2
51
+            // 
52
+            this.label2.AutoSize = true;
53
+            this.label2.Location = new System.Drawing.Point(32, 87);
54
+            this.label2.Name = "label2";
55
+            this.label2.Size = new System.Drawing.Size(127, 15);
56
+            this.label2.TabIndex = 1;
57
+            this.label2.Text = "计曲线所在图层:";
58
+            // 
59
+            // label3
60
+            // 
61
+            this.label3.AutoSize = true;
62
+            this.label3.Location = new System.Drawing.Point(32, 139);
63
+            this.label3.Name = "label3";
64
+            this.label3.Size = new System.Drawing.Size(112, 15);
65
+            this.label3.TabIndex = 2;
66
+            this.label3.Text = "图框所在图层:";
67
+            // 
68
+            // comboBox_sqx
69
+            // 
70
+            this.comboBox_sqx.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
71
+            this.comboBox_sqx.FormattingEnabled = true;
72
+            this.comboBox_sqx.Location = new System.Drawing.Point(165, 36);
73
+            this.comboBox_sqx.Name = "comboBox_sqx";
74
+            this.comboBox_sqx.Size = new System.Drawing.Size(164, 23);
75
+            this.comboBox_sqx.TabIndex = 3;
76
+            // 
77
+            // comboBox_jqx
78
+            // 
79
+            this.comboBox_jqx.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
80
+            this.comboBox_jqx.FormattingEnabled = true;
81
+            this.comboBox_jqx.Location = new System.Drawing.Point(165, 84);
82
+            this.comboBox_jqx.Name = "comboBox_jqx";
83
+            this.comboBox_jqx.Size = new System.Drawing.Size(164, 23);
84
+            this.comboBox_jqx.TabIndex = 4;
85
+            // 
86
+            // comboBox_tk
87
+            // 
88
+            this.comboBox_tk.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
89
+            this.comboBox_tk.FormattingEnabled = true;
90
+            this.comboBox_tk.Location = new System.Drawing.Point(165, 136);
91
+            this.comboBox_tk.Name = "comboBox_tk";
92
+            this.comboBox_tk.Size = new System.Drawing.Size(164, 23);
93
+            this.comboBox_tk.TabIndex = 5;
94
+            // 
95
+            // button_ok
96
+            // 
97
+            this.button_ok.Location = new System.Drawing.Point(137, 191);
98
+            this.button_ok.Name = "button_ok";
99
+            this.button_ok.Size = new System.Drawing.Size(75, 34);
100
+            this.button_ok.TabIndex = 6;
101
+            this.button_ok.Text = "确 定";
102
+            this.button_ok.UseVisualStyleBackColor = true;
103
+            this.button_ok.Click += new System.EventHandler(this.button_ok_Click);
104
+            // 
105
+            // CutDgxByTK
106
+            // 
107
+            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
108
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
109
+            this.ClientSize = new System.Drawing.Size(368, 237);
110
+            this.Controls.Add(this.button_ok);
111
+            this.Controls.Add(this.comboBox_tk);
112
+            this.Controls.Add(this.comboBox_jqx);
113
+            this.Controls.Add(this.comboBox_sqx);
114
+            this.Controls.Add(this.label3);
115
+            this.Controls.Add(this.label2);
116
+            this.Controls.Add(this.label1);
117
+            this.Name = "CutDgxByTK";
118
+            this.Text = "图框裁剪等高线";
119
+            this.Load += new System.EventHandler(this.CutDgxByTK_Load);
120
+            this.ResumeLayout(false);
121
+            this.PerformLayout();
122
+
123
+        }
124
+
125
+        #endregion
126
+
127
+        private System.Windows.Forms.Label label1;
128
+        private System.Windows.Forms.Label label2;
129
+        private System.Windows.Forms.Label label3;
130
+        private System.Windows.Forms.ComboBox comboBox_sqx;
131
+        private System.Windows.Forms.ComboBox comboBox_jqx;
132
+        private System.Windows.Forms.ComboBox comboBox_tk;
133
+        private System.Windows.Forms.Button button_ok;
134
+    }
135
+}

+ 272
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/CutDgxByTK.cs 查看文件

@@ -0,0 +1,272 @@
1
+using Autodesk.AutoCAD.ApplicationServices;
2
+using Autodesk.AutoCAD.DatabaseServices;
3
+using Autodesk.AutoCAD.EditorInput;
4
+using Autodesk.AutoCAD.Geometry;
5
+using System;
6
+using System.Collections.Generic;
7
+using System.ComponentModel;
8
+using System.Data;
9
+using System.Drawing;
10
+using System.Linq;
11
+using System.Runtime.InteropServices;
12
+using System.Text;
13
+using System.Threading.Tasks;
14
+using System.Windows.Forms;
15
+
16
+namespace CADTools
17
+{
18
+    public partial class CutDgxByTK : Form
19
+    {
20
+        public CutDgxByTK()
21
+        {
22
+            InitializeComponent();
23
+        }
24
+
25
+        private void CutDgxByTK_Load(object sender, EventArgs e)
26
+        {
27
+            //自动填充下拉框
28
+            Database database = Autodesk.AutoCAD.DatabaseServices.HostApplicationServices.WorkingDatabase;
29
+            using (Transaction traction = database.TransactionManager.StartTransaction())
30
+            {
31
+                //存放所有图层名
32
+                List<string> alllayername = new List<string>();
33
+                LayerTable layertable = traction.GetObject(database.LayerTableId, OpenMode.ForRead) as LayerTable;
34
+                foreach (ObjectId objid in layertable)
35
+                {
36
+                    LayerTableRecord layertablerecord = traction.GetObject(objid, OpenMode.ForRead) as LayerTableRecord;
37
+                    alllayername.Add(layertablerecord.Name);
38
+                }
39
+
40
+                alllayername.Sort();
41
+
42
+                for (int i = 0; i < alllayername.Count; i++)
43
+                {
44
+                    this.comboBox_jqx.Items.Add(alllayername[i]);
45
+                    this.comboBox_sqx.Items.Add(alllayername[i]);
46
+                    this.comboBox_tk.Items.Add(alllayername[i]);
47
+                }
48
+
49
+                if (alllayername.Contains("8110"))
50
+                {
51
+                    int index = alllayername.IndexOf("8110");
52
+                    this.comboBox_sqx.SelectedIndex = index;
53
+                }
54
+                if (alllayername.Contains("8120"))
55
+                {
56
+                    int index = alllayername.IndexOf("8120");
57
+                    this.comboBox_jqx.SelectedIndex = index;
58
+                }
59
+                if (alllayername.Contains("TK"))
60
+                {
61
+                    int index = alllayername.IndexOf("TK");
62
+                    this.comboBox_tk.SelectedIndex = index;
63
+                }
64
+                traction.Commit();
65
+            }
66
+        }
67
+
68
+        private void button_ok_Click(object sender, EventArgs e)
69
+        {
70
+            if (comboBox_jqx.Text == "")
71
+            {
72
+                MessageBox.Show("请选择计曲线图层");
73
+                return;
74
+            }
75
+            if (comboBox_sqx.Text == "")
76
+            {
77
+                MessageBox.Show("请选择首曲线图层");
78
+                return;
79
+            }
80
+
81
+            if (comboBox_sqx.Text == "")
82
+            {
83
+                MessageBox.Show("请选择图框图层");
84
+                return;
85
+            }
86
+            CutByTk();
87
+            this.Close();
88
+        }
89
+
90
+        private void CutByTk()
91
+        {
92
+            //图框
93
+            string tk = comboBox_tk.Text;
94
+            //图框顶点列表
95
+            List<Point3d[]> tkpts = new List<Point3d[]>();
96
+
97
+            Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
98
+            Database db = Autodesk.AutoCAD.DatabaseServices.HostApplicationServices.WorkingDatabase;
99
+            List<Polyline> tklist = new List<Polyline>();
100
+            //获取所有图框,记录图框的最大点和最小点
101
+            TypedValue[] typedvalue = new TypedValue[2];
102
+            typedvalue.SetValue(new TypedValue((int)DxfCode.LayerName, tk), 0);
103
+            typedvalue.SetValue(new TypedValue((int)DxfCode.Start, "LWPOLYLINE"), 1);
104
+            SelectionFilter selectionfilter = new SelectionFilter(typedvalue);
105
+            PromptSelectionResult psr = ed.SelectAll(selectionfilter);
106
+            if (psr.Status == PromptStatus.OK)
107
+            {
108
+                SelectionSet ss = psr.Value;
109
+                ObjectId[] tkids = ss.GetObjectIds();
110
+                for (int i = 0; i < tkids.Length; i++)
111
+                {
112
+                    using (Transaction tr = db.TransactionManager.StartTransaction())
113
+                    {
114
+                        Polyline pl = tr.GetObject(tkids[i], OpenMode.ForRead) as Polyline;
115
+                        Point3d[] pts = new Point3d[2]
116
+                        {pl.Bounds.Value.MinPoint,pl.Bounds.Value.MaxPoint};
117
+                        tkpts.Add(pts);
118
+                        tklist.Add(pl);
119
+                        tr.Commit();
120
+                    }
121
+                }
122
+            }
123
+            else
124
+            {
125
+                MessageBox.Show("未找到图框!");
126
+                return;
127
+            }
128
+
129
+            //裁剪与每个图框相交的等高线
130
+            for (int i = 0; i < tkpts.Count; i++)
131
+            {
132
+                //将视图移动到当前图框
133
+                using (Transaction tr = db.TransactionManager.StartTransaction())
134
+                {
135
+                    ViewTableRecord currview = ed.GetCurrentView();
136
+                    currview.CenterPoint = new Point2d
137
+                    ((tkpts[i][1].X - tkpts[i][0].X) / 2 + tkpts[i][0].X,
138
+                    (tkpts[i][1].Y - tkpts[i][0].Y) / 2 + tkpts[i][0].Y);
139
+                    currview.ViewDirection = new Vector3d(0, 0, 1);
140
+                    currview.Width = tkpts[i][1].X - tkpts[i][0].X + 1;
141
+                    currview.Height = tkpts[i][1].Y - tkpts[i][0].Y + 1;
142
+                    ed.SetCurrentView(currview);
143
+                    tr.Commit();
144
+                }
145
+                ProcessByTk(ed, tkpts, db, tklist, i);
146
+
147
+
148
+            }
149
+        }
150
+
151
+        private void ProcessByTk(Editor ed, List<Point3d[]> tkpts, Database db, List<Polyline> tklist, int i)
152
+        {
153
+
154
+            TypedValue[] typedvalue_pl = new TypedValue[2];
155
+            typedvalue_pl.SetValue(new TypedValue((int)DxfCode.LayerName, comboBox_jqx.Text + "," + comboBox_sqx.Text), 0);
156
+            typedvalue_pl.SetValue(new TypedValue((int)DxfCode.Start, "LWPOLYLINE"), 1);
157
+            SelectionFilter selectionfilter_pl = new SelectionFilter(typedvalue_pl);
158
+            PromptSelectionResult psr_pl = ed.SelectCrossingWindow(tkpts[i][0], tkpts[i][1], selectionfilter_pl);
159
+            if (psr_pl.Status == PromptStatus.OK)
160
+            {
161
+                ObjectId[] plids = psr_pl.Value.GetObjectIds();
162
+                for (int ii = 0; ii < plids.Length; ii++)
163
+                {
164
+                    DocumentLock doclock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
165
+                    using (Transaction tr = db.TransactionManager.StartTransaction())
166
+                    {
167
+                        BlockTable bt = tr.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
168
+                        BlockTableRecord btr = tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
169
+
170
+                        Polyline pl = tr.GetObject(plids[ii], OpenMode.ForWrite) as Polyline;
171
+                        if (IsPolylineInsideOrIntersecting(pl, tkpts[i][0], tkpts[i][1]))
172
+                        {
173
+                            var intersectpts = GetIntersections(pl, tklist[i]);
174
+                            if (intersectpts.Count == 0)
175
+                                continue;
176
+                            Point3dCollection ptcoll = new Point3dCollection(intersectpts.ToArray());
177
+                            using (DBObjectCollection dbobjcoll = pl.GetSplitCurves(ptcoll))
178
+                            {
179
+                                for (int j = 0; j < dbobjcoll.Count; j++)
180
+                                {
181
+
182
+                                    Polyline pl_split = (Polyline)dbobjcoll[j];
183
+                                    pl_split.Layer = pl.Layer;
184
+                                    pl_split.Elevation = pl.Elevation;
185
+                                    btr.AppendEntity(pl_split);
186
+                                    tr.AddNewlyCreatedDBObject(pl_split, true);
187
+                                }
188
+                            }
189
+                            pl.Erase();
190
+                            ptcoll.Clear();
191
+                            intersectpts.Clear();
192
+                        }
193
+                        tr.Commit();
194
+                    }
195
+                    doclock.Dispose();
196
+                }
197
+                psr_pl = null;
198
+            }
199
+        }
200
+
201
+        // 检查多段线是否有部分在框内
202
+        private bool IsPolylineInsideOrIntersecting(Polyline pl, Point3d minPoint, Point3d maxPoint)
203
+        {
204
+            // 方法1:检查是否有顶点在框内
205
+            for (int j = 0; j < pl.NumberOfVertices; j++)
206
+            {
207
+                Point3d vertex = pl.GetPoint3dAt(j);
208
+                if (IsPointInside(vertex, minPoint, maxPoint))
209
+                    return true; // 有顶点在框内,说明线有部分在框内
210
+            }
211
+
212
+            // 方法2:检查线的包围盒是否与选择框相交
213
+            Extents3d plExtents = pl.GeometricExtents;
214
+            if (plExtents.MinPoint.X <= maxPoint.X && plExtents.MaxPoint.X >= minPoint.X &&
215
+                plExtents.MinPoint.Y <= maxPoint.Y && plExtents.MaxPoint.Y >= minPoint.Y)
216
+            {
217
+                // 包围盒相交,进一步检查线段
218
+                return true;
219
+            }
220
+
221
+            return false;
222
+        }
223
+
224
+        // 检查点是否在矩形内(不包括边界)
225
+        private bool IsPointInside(Point3d point, Point3d minPoint, Point3d maxPoint)
226
+        {
227
+            return point.X > minPoint.X && point.X < maxPoint.X &&
228
+                   point.Y > minPoint.Y && point.Y < maxPoint.Y;
229
+        }
230
+
231
+        private List<Point3d> GetIntersections(Polyline pll1, Polyline pll2)
232
+        {
233
+            List<Point3d> result = new List<Point3d>();
234
+
235
+            // 创建临时副本
236
+            using (Polyline tempLine1 = (Polyline)pll1.Clone())
237
+            using (Polyline tempLine2 = (Polyline)pll2.Clone())
238
+            {
239
+
240
+                // 计算平移向量(以线1起点为基准,移动至原点)
241
+                Vector3d translation = -tempLine1.StartPoint.GetAsVector();
242
+                Matrix3d translateMatrix = Matrix3d.Displacement(translation);
243
+
244
+                // 应用平移变换
245
+                tempLine1.TransformBy(translateMatrix);
246
+                tempLine2.TransformBy(translateMatrix);
247
+
248
+                Point3dCollection translatedPoints = new Point3dCollection();
249
+                var plane = new Plane(Point3d.Origin, Vector3d.ZAxis);
250
+                tempLine1.IntersectWith(tempLine2, Intersect.OnBothOperands, plane, translatedPoints, IntPtr.Zero, IntPtr.Zero);
251
+
252
+                // 计算逆平移矩阵
253
+                Matrix3d inverseMatrix = Matrix3d.Displacement(-translation);
254
+                if (translatedPoints.Count > 0)
255
+                {
256
+                    // 获取平移后的交点
257
+                    foreach (Point3d item in translatedPoints)
258
+                    {
259
+                        // 恢复交点坐标
260
+                        var pt = item.TransformBy(inverseMatrix);
261
+                        var pt1 = pll1.GetClosestPointTo(pt, false);
262
+                        result.Add(pt1);
263
+                    }
264
+                    translatedPoints.Dispose();
265
+                }
266
+                tempLine1.Dispose();
267
+                tempLine2.Dispose();
268
+            }
269
+            return result;
270
+        }
271
+    }
272
+}

+ 120
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/CutDgxByTK.resx 查看文件

@@ -0,0 +1,120 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<root>
3
+  <!-- 
4
+    Microsoft ResX Schema 
5
+    
6
+    Version 2.0
7
+    
8
+    The primary goals of this format is to allow a simple XML format 
9
+    that is mostly human readable. The generation and parsing of the 
10
+    various data types are done through the TypeConverter classes 
11
+    associated with the data types.
12
+    
13
+    Example:
14
+    
15
+    ... ado.net/XML headers & schema ...
16
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
17
+    <resheader name="version">2.0</resheader>
18
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
19
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
20
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
21
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
22
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
24
+    </data>
25
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
26
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
27
+        <comment>This is a comment</comment>
28
+    </data>
29
+                
30
+    There are any number of "resheader" rows that contain simple 
31
+    name/value pairs.
32
+    
33
+    Each data row contains a name, and value. The row also contains a 
34
+    type or mimetype. Type corresponds to a .NET class that support 
35
+    text/value conversion through the TypeConverter architecture. 
36
+    Classes that don't support this are serialized and stored with the 
37
+    mimetype set.
38
+    
39
+    The mimetype is used for serialized objects, and tells the 
40
+    ResXResourceReader how to depersist the object. This is currently not 
41
+    extensible. For a given mimetype the value must be set accordingly:
42
+    
43
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
44
+    that the ResXResourceWriter will generate, however the reader can 
45
+    read any of the formats listed below.
46
+    
47
+    mimetype: application/x-microsoft.net.object.binary.base64
48
+    value   : The object must be serialized with 
49
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
50
+            : and then encoded with base64 encoding.
51
+    
52
+    mimetype: application/x-microsoft.net.object.soap.base64
53
+    value   : The object must be serialized with 
54
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
55
+            : and then encoded with base64 encoding.
56
+
57
+    mimetype: application/x-microsoft.net.object.bytearray.base64
58
+    value   : The object must be serialized into a byte array 
59
+            : using a System.ComponentModel.TypeConverter
60
+            : and then encoded with base64 encoding.
61
+    -->
62
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
64
+    <xsd:element name="root" msdata:IsDataSet="true">
65
+      <xsd:complexType>
66
+        <xsd:choice maxOccurs="unbounded">
67
+          <xsd:element name="metadata">
68
+            <xsd:complexType>
69
+              <xsd:sequence>
70
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
71
+              </xsd:sequence>
72
+              <xsd:attribute name="name" use="required" type="xsd:string" />
73
+              <xsd:attribute name="type" type="xsd:string" />
74
+              <xsd:attribute name="mimetype" type="xsd:string" />
75
+              <xsd:attribute ref="xml:space" />
76
+            </xsd:complexType>
77
+          </xsd:element>
78
+          <xsd:element name="assembly">
79
+            <xsd:complexType>
80
+              <xsd:attribute name="alias" type="xsd:string" />
81
+              <xsd:attribute name="name" type="xsd:string" />
82
+            </xsd:complexType>
83
+          </xsd:element>
84
+          <xsd:element name="data">
85
+            <xsd:complexType>
86
+              <xsd:sequence>
87
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
88
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
89
+              </xsd:sequence>
90
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
91
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
92
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
93
+              <xsd:attribute ref="xml:space" />
94
+            </xsd:complexType>
95
+          </xsd:element>
96
+          <xsd:element name="resheader">
97
+            <xsd:complexType>
98
+              <xsd:sequence>
99
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
100
+              </xsd:sequence>
101
+              <xsd:attribute name="name" type="xsd:string" use="required" />
102
+            </xsd:complexType>
103
+          </xsd:element>
104
+        </xsd:choice>
105
+      </xsd:complexType>
106
+    </xsd:element>
107
+  </xsd:schema>
108
+  <resheader name="resmimetype">
109
+    <value>text/microsoft-resx</value>
110
+  </resheader>
111
+  <resheader name="version">
112
+    <value>2.0</value>
113
+  </resheader>
114
+  <resheader name="reader">
115
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116
+  </resheader>
117
+  <resheader name="writer">
118
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119
+  </resheader>
120
+</root>

+ 131
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/DGXGeneral.Designer.cs 查看文件

@@ -0,0 +1,131 @@
1
+
2
+namespace CADTools
3
+{
4
+    partial class DGXGeneral
5
+    {
6
+        /// <summary>
7
+        /// Required designer variable.
8
+        /// </summary>
9
+        private System.ComponentModel.IContainer components = null;
10
+
11
+        /// <summary>
12
+        /// Clean up any resources being used.
13
+        /// </summary>
14
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
15
+        protected override void Dispose(bool disposing)
16
+        {
17
+            if (disposing && (components != null))
18
+            {
19
+                components.Dispose();
20
+            }
21
+            base.Dispose(disposing);
22
+        }
23
+
24
+        #region Windows Form Designer generated code
25
+
26
+        /// <summary>
27
+        /// Required method for Designer support - do not modify
28
+        /// the contents of this method with the code editor.
29
+        /// </summary>
30
+        private void InitializeComponent()
31
+        {
32
+            this.checkedListBox_dgxtc = new System.Windows.Forms.CheckedListBox();
33
+            this.label1 = new System.Windows.Forms.Label();
34
+            this.label2 = new System.Windows.Forms.Label();
35
+            this.comboBox_dgj = new System.Windows.Forms.ComboBox();
36
+            this.butn_ok = new System.Windows.Forms.Button();
37
+            this.butn_cancel = new System.Windows.Forms.Button();
38
+            this.SuspendLayout();
39
+            // 
40
+            // checkedListBox_dgxtc
41
+            // 
42
+            this.checkedListBox_dgxtc.FormattingEnabled = true;
43
+            this.checkedListBox_dgxtc.Location = new System.Drawing.Point(44, 102);
44
+            this.checkedListBox_dgxtc.Name = "checkedListBox_dgxtc";
45
+            this.checkedListBox_dgxtc.Size = new System.Drawing.Size(235, 264);
46
+            this.checkedListBox_dgxtc.TabIndex = 0;
47
+            // 
48
+            // label1
49
+            // 
50
+            this.label1.AutoSize = true;
51
+            this.label1.Location = new System.Drawing.Point(25, 35);
52
+            this.label1.Name = "label1";
53
+            this.label1.Size = new System.Drawing.Size(112, 15);
54
+            this.label1.TabIndex = 1;
55
+            this.label1.Text = "转换后等高距:";
56
+            // 
57
+            // label2
58
+            // 
59
+            this.label2.AutoSize = true;
60
+            this.label2.Location = new System.Drawing.Point(25, 75);
61
+            this.label2.Name = "label2";
62
+            this.label2.Size = new System.Drawing.Size(127, 15);
63
+            this.label2.TabIndex = 2;
64
+            this.label2.Text = "选择等高线图层:";
65
+            // 
66
+            // comboBox_dgj
67
+            // 
68
+            this.comboBox_dgj.FormattingEnabled = true;
69
+            this.comboBox_dgj.Items.AddRange(new object[] {
70
+            "0.5",
71
+            "1",
72
+            "2",
73
+            "2.5",
74
+            "5",
75
+            "10",
76
+            "20",
77
+            "40",
78
+            "50"});
79
+            this.comboBox_dgj.Location = new System.Drawing.Point(134, 32);
80
+            this.comboBox_dgj.Name = "comboBox_dgj";
81
+            this.comboBox_dgj.Size = new System.Drawing.Size(155, 23);
82
+            this.comboBox_dgj.TabIndex = 3;
83
+            // 
84
+            // butn_ok
85
+            // 
86
+            this.butn_ok.Location = new System.Drawing.Point(28, 389);
87
+            this.butn_ok.Name = "butn_ok";
88
+            this.butn_ok.Size = new System.Drawing.Size(75, 23);
89
+            this.butn_ok.TabIndex = 4;
90
+            this.butn_ok.Text = "确 定";
91
+            this.butn_ok.UseVisualStyleBackColor = true;
92
+            this.butn_ok.Click += new System.EventHandler(this.butn_ok_Click);
93
+            // 
94
+            // butn_cancel
95
+            // 
96
+            this.butn_cancel.Location = new System.Drawing.Point(214, 389);
97
+            this.butn_cancel.Name = "butn_cancel";
98
+            this.butn_cancel.Size = new System.Drawing.Size(75, 23);
99
+            this.butn_cancel.TabIndex = 5;
100
+            this.butn_cancel.Text = "取 消";
101
+            this.butn_cancel.UseVisualStyleBackColor = true;
102
+            // 
103
+            // DGXGeneral
104
+            // 
105
+            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
106
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
107
+            this.ClientSize = new System.Drawing.Size(338, 424);
108
+            this.Controls.Add(this.butn_cancel);
109
+            this.Controls.Add(this.butn_ok);
110
+            this.Controls.Add(this.comboBox_dgj);
111
+            this.Controls.Add(this.label2);
112
+            this.Controls.Add(this.label1);
113
+            this.Controls.Add(this.checkedListBox_dgxtc);
114
+            this.Name = "DGXGeneral";
115
+            this.Text = "等高线缩编";
116
+            this.Load += new System.EventHandler(this.DGXGeneral_Load);
117
+            this.ResumeLayout(false);
118
+            this.PerformLayout();
119
+
120
+        }
121
+
122
+        #endregion
123
+
124
+        private System.Windows.Forms.CheckedListBox checkedListBox_dgxtc;
125
+        private System.Windows.Forms.Label label1;
126
+        private System.Windows.Forms.Label label2;
127
+        private System.Windows.Forms.ComboBox comboBox_dgj;
128
+        private System.Windows.Forms.Button butn_ok;
129
+        private System.Windows.Forms.Button butn_cancel;
130
+    }
131
+}

+ 76
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/DGXGeneral.cs 查看文件

@@ -0,0 +1,76 @@
1
+using Autodesk.AutoCAD.DatabaseServices;
2
+using System;
3
+using System.Collections;
4
+using System.Collections.Generic;
5
+using System.ComponentModel;
6
+using System.Data;
7
+using System.Drawing;
8
+using System.Linq;
9
+using System.Text;
10
+using System.Threading.Tasks;
11
+using System.Windows.Forms;
12
+
13
+namespace CADTools
14
+{
15
+    public partial class DGXGeneral : Form
16
+    {
17
+        public DGXGeneral()
18
+        {
19
+            InitializeComponent();
20
+        }
21
+
22
+        private void DGXGeneral_Load(object sender, EventArgs e)
23
+        {
24
+            this.comboBox_dgj.DropDownStyle = ComboBoxStyle.DropDownList;
25
+
26
+            Database database = Autodesk.AutoCAD.DatabaseServices.HostApplicationServices.WorkingDatabase;
27
+            using (Transaction traction = database.TransactionManager.StartTransaction())
28
+            {
29
+                //存放所有图层名
30
+                List<string> alllayername = new List<string>();
31
+                LayerTable layertable = traction.GetObject(database.LayerTableId, OpenMode.ForRead) as LayerTable;
32
+                foreach (ObjectId objid in layertable)
33
+                {
34
+                    LayerTableRecord layertablerecord = traction.GetObject(objid, OpenMode.ForRead) as LayerTableRecord;
35
+                    alllayername.Add(layertablerecord.Name);
36
+                }
37
+
38
+                alllayername.Sort();
39
+
40
+                for (int i = 0; i < alllayername.Count; i++)
41
+                {
42
+                    this.checkedListBox_dgxtc.Items.Add(alllayername[i]);
43
+                }
44
+                traction.Commit();
45
+            }
46
+        }
47
+
48
+        private void butn_ok_Click(object sender, EventArgs e)
49
+        {
50
+            ArrayList eplayerlist = new ArrayList();
51
+            if (checkedListBox_dgxtc.CheckedItems.Count > 0)
52
+            {
53
+                int count = checkedListBox_dgxtc.CheckedItems.Count;
54
+                for (int i = 0; i < count; i++)
55
+                {
56
+                    eplayerlist.Add(checkedListBox_dgxtc.CheckedItems[i].ToString());
57
+                }
58
+            }
59
+            else
60
+            {
61
+                MessageBox.Show("请选择处理等高线图层!", "警告");
62
+                return;
63
+            }
64
+            if (comboBox_dgj.Text == "")
65
+            {
66
+                Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("请选择等高距");
67
+                return;
68
+            }
69
+
70
+            DGXGeneralization.dgxlayerlist = eplayerlist;
71
+            DGXGeneralization.dgj = double.Parse(comboBox_dgj.Text);
72
+            DGXGeneralization.dgxGeneralization();
73
+            this.Close();
74
+        }
75
+    }
76
+}

+ 120
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/DGXGeneral.resx 查看文件

@@ -0,0 +1,120 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<root>
3
+  <!-- 
4
+    Microsoft ResX Schema 
5
+    
6
+    Version 2.0
7
+    
8
+    The primary goals of this format is to allow a simple XML format 
9
+    that is mostly human readable. The generation and parsing of the 
10
+    various data types are done through the TypeConverter classes 
11
+    associated with the data types.
12
+    
13
+    Example:
14
+    
15
+    ... ado.net/XML headers & schema ...
16
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
17
+    <resheader name="version">2.0</resheader>
18
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
19
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
20
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
21
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
22
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
24
+    </data>
25
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
26
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
27
+        <comment>This is a comment</comment>
28
+    </data>
29
+                
30
+    There are any number of "resheader" rows that contain simple 
31
+    name/value pairs.
32
+    
33
+    Each data row contains a name, and value. The row also contains a 
34
+    type or mimetype. Type corresponds to a .NET class that support 
35
+    text/value conversion through the TypeConverter architecture. 
36
+    Classes that don't support this are serialized and stored with the 
37
+    mimetype set.
38
+    
39
+    The mimetype is used for serialized objects, and tells the 
40
+    ResXResourceReader how to depersist the object. This is currently not 
41
+    extensible. For a given mimetype the value must be set accordingly:
42
+    
43
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
44
+    that the ResXResourceWriter will generate, however the reader can 
45
+    read any of the formats listed below.
46
+    
47
+    mimetype: application/x-microsoft.net.object.binary.base64
48
+    value   : The object must be serialized with 
49
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
50
+            : and then encoded with base64 encoding.
51
+    
52
+    mimetype: application/x-microsoft.net.object.soap.base64
53
+    value   : The object must be serialized with 
54
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
55
+            : and then encoded with base64 encoding.
56
+
57
+    mimetype: application/x-microsoft.net.object.bytearray.base64
58
+    value   : The object must be serialized into a byte array 
59
+            : using a System.ComponentModel.TypeConverter
60
+            : and then encoded with base64 encoding.
61
+    -->
62
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
64
+    <xsd:element name="root" msdata:IsDataSet="true">
65
+      <xsd:complexType>
66
+        <xsd:choice maxOccurs="unbounded">
67
+          <xsd:element name="metadata">
68
+            <xsd:complexType>
69
+              <xsd:sequence>
70
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
71
+              </xsd:sequence>
72
+              <xsd:attribute name="name" use="required" type="xsd:string" />
73
+              <xsd:attribute name="type" type="xsd:string" />
74
+              <xsd:attribute name="mimetype" type="xsd:string" />
75
+              <xsd:attribute ref="xml:space" />
76
+            </xsd:complexType>
77
+          </xsd:element>
78
+          <xsd:element name="assembly">
79
+            <xsd:complexType>
80
+              <xsd:attribute name="alias" type="xsd:string" />
81
+              <xsd:attribute name="name" type="xsd:string" />
82
+            </xsd:complexType>
83
+          </xsd:element>
84
+          <xsd:element name="data">
85
+            <xsd:complexType>
86
+              <xsd:sequence>
87
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
88
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
89
+              </xsd:sequence>
90
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
91
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
92
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
93
+              <xsd:attribute ref="xml:space" />
94
+            </xsd:complexType>
95
+          </xsd:element>
96
+          <xsd:element name="resheader">
97
+            <xsd:complexType>
98
+              <xsd:sequence>
99
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
100
+              </xsd:sequence>
101
+              <xsd:attribute name="name" type="xsd:string" use="required" />
102
+            </xsd:complexType>
103
+          </xsd:element>
104
+        </xsd:choice>
105
+      </xsd:complexType>
106
+    </xsd:element>
107
+  </xsd:schema>
108
+  <resheader name="resmimetype">
109
+    <value>text/microsoft-resx</value>
110
+  </resheader>
111
+  <resheader name="version">
112
+    <value>2.0</value>
113
+  </resheader>
114
+  <resheader name="reader">
115
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116
+  </resheader>
117
+  <resheader name="writer">
118
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119
+  </resheader>
120
+</root>

+ 193
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/DGXGeneralization.cs 查看文件

@@ -0,0 +1,193 @@
1
+using Autodesk.AutoCAD.ApplicationServices;
2
+using Autodesk.AutoCAD.DatabaseServices;
3
+using Autodesk.AutoCAD.EditorInput;
4
+using System;
5
+using System.Collections;
6
+using System.Collections.Generic;
7
+using System.Linq;
8
+using System.Text;
9
+using System.Threading.Tasks;
10
+using System.Windows.Forms;
11
+
12
+namespace CADTools
13
+{
14
+    class DGXGeneralization
15
+    {
16
+        public static ArrayList dgxlayerlist;
17
+        public static double dgj;
18
+        public static bool openflag = true;
19
+        public static void dgxGeneralization()
20
+        {
21
+            Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
22
+            Database db = doc.Database;
23
+            DocumentLock docLock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
24
+            //try
25
+            //{
26
+                //LayerTable lt = null;
27
+                //ArrayList layerlist = new ArrayList();
28
+
29
+                ////获取图层事务
30
+                //using (Transaction tran = doc.TransactionManager.StartTransaction())
31
+                //{
32
+                //    lt = tran.GetObject(db.LayerTableId, OpenMode.ForRead) as LayerTable;
33
+                //    foreach (ObjectId layerid in lt)
34
+                //    {
35
+                //        LayerTableRecord ltrec = tran.GetObject(layerid, OpenMode.ForWrite) as LayerTableRecord;
36
+                //        layerlist.Add(ltrec.Name);
37
+                //    }
38
+                //    doc.Editor.WriteMessage("程序开始运行\r\n......\r\n");
39
+                //    tran.Commit();
40
+                //    tran.Dispose();
41
+
42
+                //}
43
+                
44
+
45
+
46
+                //DGXSBForm sf = new DGXSBForm(layerlist);
47
+                //if (sf.ShowDialog() == DialogResult.OK)
48
+                //{
49
+                //    dgxlayerlist = sf.DGXlayerlist;
50
+                //    dgj = sf.DGJ;
51
+                //    openflag = true;
52
+                //}
53
+                if (openflag)
54
+                {
55
+                    string dgx1 = string.Empty, dgx2 = string.Empty;
56
+                    if (dgxlayerlist.Count > 0)
57
+                    {
58
+                        if (dgxlayerlist.Count == 1)
59
+                        {
60
+                            dgx1 = dgxlayerlist[0].ToString();
61
+                        }
62
+                        if (dgxlayerlist.Count == 2)
63
+                        {
64
+                            dgx1 = dgxlayerlist[0].ToString();
65
+                            dgx2 = dgxlayerlist[1].ToString();
66
+                        }
67
+                    }
68
+
69
+                    using (Transaction tran = doc.TransactionManager.StartTransaction())
70
+                    {
71
+                        
72
+                        //// 以只读方式打开块表记录   Open the Block table record for read
73
+                        BlockTable acbt = tran.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
74
+                        //// 以写方式打开模型空间块表记录   Open the Block table record Model space for write
75
+                        BlockTableRecord acblr = tran.GetObject(acbt[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
76
+
77
+                        //设置激活图层
78
+                        LayerTable layertable = tran.GetObject(db.LayerTableId, OpenMode.ForWrite) as LayerTable;
79
+                        if (!layertable.Has("Delete"))
80
+                        {
81
+                            LayerTableRecord ltr = new LayerTableRecord();
82
+                            ltr.Name = "Delete";
83
+                            ObjectId layerid = layertable.Add(ltr);
84
+                            tran.AddNewlyCreatedDBObject(ltr, true);
85
+                            //db.Clayer = layerid;
86
+                        }
87
+                        if (!layertable.Has("8120"))
88
+                        {
89
+                            LayerTableRecord ltr = new LayerTableRecord();
90
+                            ltr.Name = "8120";
91
+                            ObjectId layerid = layertable.Add(ltr);
92
+                            tran.AddNewlyCreatedDBObject(ltr, true);
93
+                            //db.Clayer = layerid;
94
+                        }
95
+                        if (!layertable.Has("8110"))
96
+                        {
97
+                            LayerTableRecord ltr = new LayerTableRecord();
98
+                            ltr.Name = "8110";
99
+                            ObjectId layerid = layertable.Add(ltr);
100
+                            tran.AddNewlyCreatedDBObject(ltr, true);
101
+                            //db.Clayer = layerid;
102
+                        }
103
+                        tran.Commit();
104
+                        tran.Dispose();
105
+                        
106
+                    }
107
+                    PromptSelectionResult psr = doc.Editor.SelectAll();
108
+                    //doc.Editor.WriteMessage("请选择等高线!");
109
+                    //PromptSelectionResult psr = doc.Editor.GetSelection();
110
+                    if (psr.Status == PromptStatus.OK)
111
+                    {
112
+                        
113
+                        SelectionSet ss = psr.Value;
114
+                        foreach (ObjectId oid in ss.GetObjectIds())
115
+                        {
116
+                            using (Transaction tran = doc.TransactionManager.StartTransaction())
117
+                            {
118
+                                BlockTable acbt = tran.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
119
+                                BlockTableRecord acbtr = tran.GetObject(acbt[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
120
+
121
+                                Entity en = tran.GetObject(oid, OpenMode.ForWrite) as Entity;
122
+
123
+                                if ((en.Layer == dgx1) || (en.Layer == dgx2))
124
+                                {
125
+                                    Polyline pl = new Polyline();
126
+                                    Polyline2d pl2d = new Polyline2d();
127
+                                    double elevation = 99999999;
128
+                                    if (en is Polyline)
129
+                                    {
130
+                                        pl = en as Polyline;
131
+                                        elevation = pl.Elevation;
132
+                                    }
133
+                                    else if (en is Polyline2d)
134
+                                    {
135
+                                        pl2d = en as Polyline2d;
136
+                                        elevation = pl2d.Elevation;
137
+                                    }
138
+                                    if (elevation != 99999999)
139
+                                    {
140
+                                        elevation = Convert.ToDouble(elevation.ToString("f1"));
141
+                                        if (dgj != 0)
142
+                                        {
143
+                                            double remainder = elevation % dgj;
144
+                                            if (remainder != 0.0)
145
+                                            {
146
+                                                en.Layer = "Delete";
147
+                                                en.Color = Autodesk.AutoCAD.Colors.Color.FromColor(System.Drawing.Color.Red);
148
+                                            }
149
+                                            else
150
+                                            {
151
+                                                double remainder2 = elevation % (dgj * 5);
152
+                                                if (remainder2 == 0.0)
153
+                                                {
154
+                                                    en.Layer = "8120";
155
+                                                    en.Color = Autodesk.AutoCAD.Colors.Color.FromColor(System.Drawing.Color.Yellow);
156
+                                                }
157
+                                                else
158
+                                                {
159
+                                                    en.Layer = "8110";
160
+                                                    en.Color = Autodesk.AutoCAD.Colors.Color.FromColor(System.Drawing.Color.White);
161
+                                                }
162
+                                            }
163
+                                        }
164
+
165
+                                    }
166
+
167
+                                }
168
+                                else
169
+                                    continue;
170
+                                //                            
171
+                                tran.Commit();
172
+                                tran.Dispose();
173
+                            }
174
+                        }
175
+                        doc.Editor.WriteMessage("程序运行结束,谢谢使用");
176
+                        
177
+                    }
178
+
179
+
180
+                }
181
+                else
182
+                {
183
+                    doc.Editor.WriteMessage("请选择相关参数\r\n");
184
+                }
185
+            //}
186
+            //catch (Autodesk.AutoCAD.Runtime.Exception ex)
187
+            //{
188
+            //    doc.Editor.WriteMessage(ex.ToString());
189
+            //}
190
+                docLock.Dispose();
191
+        }
192
+    }
193
+}

+ 150
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/DeleteElept.Designer.cs 查看文件

@@ -0,0 +1,150 @@
1
+
2
+namespace CADTools
3
+{
4
+    partial class DeleteElept
5
+    {
6
+        /// <summary>
7
+        /// Required designer variable.
8
+        /// </summary>
9
+        private System.ComponentModel.IContainer components = null;
10
+
11
+        /// <summary>
12
+        /// Clean up any resources being used.
13
+        /// </summary>
14
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
15
+        protected override void Dispose(bool disposing)
16
+        {
17
+            if (disposing && (components != null))
18
+            {
19
+                components.Dispose();
20
+            }
21
+            base.Dispose(disposing);
22
+        }
23
+
24
+        #region Windows Form Designer generated code
25
+
26
+        /// <summary>
27
+        /// Required method for Designer support - do not modify
28
+        /// the contents of this method with the code editor.
29
+        /// </summary>
30
+        private void InitializeComponent()
31
+        {
32
+            this.label1 = new System.Windows.Forms.Label();
33
+            this.comboBox_gcd = new System.Windows.Forms.ComboBox();
34
+            this.label2 = new System.Windows.Forms.Label();
35
+            this.checkedListBox_ly = new System.Windows.Forms.CheckedListBox();
36
+            this.button_ok = new System.Windows.Forms.Button();
37
+            this.button_cancel = new System.Windows.Forms.Button();
38
+            this.label3 = new System.Windows.Forms.Label();
39
+            this.comboBox_blc = new System.Windows.Forms.ComboBox();
40
+            this.SuspendLayout();
41
+            // 
42
+            // label1
43
+            // 
44
+            this.label1.AutoSize = true;
45
+            this.label1.Location = new System.Drawing.Point(54, 28);
46
+            this.label1.Name = "label1";
47
+            this.label1.Size = new System.Drawing.Size(127, 15);
48
+            this.label1.TabIndex = 0;
49
+            this.label1.Text = "高程点所在图层:";
50
+            // 
51
+            // comboBox_gcd
52
+            // 
53
+            this.comboBox_gcd.FormattingEnabled = true;
54
+            this.comboBox_gcd.Location = new System.Drawing.Point(180, 25);
55
+            this.comboBox_gcd.Name = "comboBox_gcd";
56
+            this.comboBox_gcd.Size = new System.Drawing.Size(222, 23);
57
+            this.comboBox_gcd.TabIndex = 1;
58
+            // 
59
+            // label2
60
+            // 
61
+            this.label2.AutoSize = true;
62
+            this.label2.Location = new System.Drawing.Point(16, 111);
63
+            this.label2.Name = "label2";
64
+            this.label2.Size = new System.Drawing.Size(202, 15);
65
+            this.label2.TabIndex = 2;
66
+            this.label2.Text = "需要删除内部高程点的图层:";
67
+            // 
68
+            // checkedListBox_ly
69
+            // 
70
+            this.checkedListBox_ly.FormattingEnabled = true;
71
+            this.checkedListBox_ly.Location = new System.Drawing.Point(91, 140);
72
+            this.checkedListBox_ly.Name = "checkedListBox_ly";
73
+            this.checkedListBox_ly.Size = new System.Drawing.Size(379, 184);
74
+            this.checkedListBox_ly.TabIndex = 3;
75
+            // 
76
+            // button_ok
77
+            // 
78
+            this.button_ok.Location = new System.Drawing.Point(133, 345);
79
+            this.button_ok.Name = "button_ok";
80
+            this.button_ok.Size = new System.Drawing.Size(75, 31);
81
+            this.button_ok.TabIndex = 4;
82
+            this.button_ok.Text = "确 定";
83
+            this.button_ok.UseVisualStyleBackColor = true;
84
+            this.button_ok.Click += new System.EventHandler(this.button_ok_Click);
85
+            // 
86
+            // button_cancel
87
+            // 
88
+            this.button_cancel.Location = new System.Drawing.Point(355, 345);
89
+            this.button_cancel.Name = "button_cancel";
90
+            this.button_cancel.Size = new System.Drawing.Size(75, 31);
91
+            this.button_cancel.TabIndex = 5;
92
+            this.button_cancel.Text = "取 消";
93
+            this.button_cancel.UseVisualStyleBackColor = true;
94
+            this.button_cancel.Click += new System.EventHandler(this.button_cancel_Click);
95
+            // 
96
+            // label3
97
+            // 
98
+            this.label3.AutoSize = true;
99
+            this.label3.Location = new System.Drawing.Point(114, 66);
100
+            this.label3.Name = "label3";
101
+            this.label3.Size = new System.Drawing.Size(67, 15);
102
+            this.label3.TabIndex = 6;
103
+            this.label3.Text = "比例尺:";
104
+            // 
105
+            // comboBox_blc
106
+            // 
107
+            this.comboBox_blc.FormattingEnabled = true;
108
+            this.comboBox_blc.Items.AddRange(new object[] {
109
+            "1:500",
110
+            "1:1000",
111
+            "1:2000",
112
+            "1:5000"});
113
+            this.comboBox_blc.Location = new System.Drawing.Point(180, 63);
114
+            this.comboBox_blc.Name = "comboBox_blc";
115
+            this.comboBox_blc.Size = new System.Drawing.Size(222, 23);
116
+            this.comboBox_blc.TabIndex = 7;
117
+            // 
118
+            // DeleteElept
119
+            // 
120
+            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
121
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
122
+            this.ClientSize = new System.Drawing.Size(535, 388);
123
+            this.Controls.Add(this.comboBox_blc);
124
+            this.Controls.Add(this.label3);
125
+            this.Controls.Add(this.button_cancel);
126
+            this.Controls.Add(this.button_ok);
127
+            this.Controls.Add(this.checkedListBox_ly);
128
+            this.Controls.Add(this.label2);
129
+            this.Controls.Add(this.comboBox_gcd);
130
+            this.Controls.Add(this.label1);
131
+            this.Name = "DeleteElept";
132
+            this.Text = "删除内部高程点";
133
+            this.Load += new System.EventHandler(this.DeleteElept_Load);
134
+            this.ResumeLayout(false);
135
+            this.PerformLayout();
136
+
137
+        }
138
+
139
+        #endregion
140
+
141
+        private System.Windows.Forms.Label label1;
142
+        private System.Windows.Forms.ComboBox comboBox_gcd;
143
+        private System.Windows.Forms.Label label2;
144
+        private System.Windows.Forms.CheckedListBox checkedListBox_ly;
145
+        private System.Windows.Forms.Button button_ok;
146
+        private System.Windows.Forms.Button button_cancel;
147
+        private System.Windows.Forms.Label label3;
148
+        private System.Windows.Forms.ComboBox comboBox_blc;
149
+    }
150
+}

+ 93
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/DeleteElept.cs 查看文件

@@ -0,0 +1,93 @@
1
+using Autodesk.AutoCAD.DatabaseServices;
2
+using System;
3
+using System.Collections.Generic;
4
+using System.ComponentModel;
5
+using System.Data;
6
+using System.Drawing;
7
+using System.Linq;
8
+using System.Text;
9
+using System.Threading.Tasks;
10
+using System.Windows.Forms;
11
+
12
+namespace CADTools
13
+{
14
+    public partial class DeleteElept : Form
15
+    {
16
+        public DeleteElept()
17
+        {
18
+            InitializeComponent();
19
+        }
20
+
21
+        private void DeleteElept_Load(object sender, EventArgs e)
22
+        {
23
+            this.comboBox_gcd.DropDownStyle = ComboBoxStyle.DropDownList;
24
+            this.comboBox_blc.DropDownStyle = ComboBoxStyle.DropDownList;
25
+
26
+            //自动填充下拉框
27
+            Database database = Autodesk.AutoCAD.DatabaseServices.HostApplicationServices.WorkingDatabase;
28
+            using (Transaction traction = database.TransactionManager.StartTransaction())
29
+            {
30
+                //存放所有图层名
31
+                List<string> alllayername = new List<string>();
32
+                LayerTable layertable = traction.GetObject(database.LayerTableId, OpenMode.ForRead) as LayerTable;
33
+                foreach (ObjectId objid in layertable)
34
+                {
35
+                    LayerTableRecord layertablerecord = traction.GetObject(objid, OpenMode.ForRead) as LayerTableRecord;
36
+                    alllayername.Add(layertablerecord.Name);
37
+                }
38
+
39
+                alllayername.Sort();
40
+
41
+                for (int i = 0; i < alllayername.Count; i++)
42
+                {
43
+                    this.comboBox_gcd.Items.Add(alllayername[i]);
44
+                    this.checkedListBox_ly.Items.Add(alllayername[i]);
45
+                }
46
+
47
+                if (alllayername.Contains("8300"))
48
+                {
49
+                    int index = alllayername.IndexOf("8300");
50
+                    this.comboBox_gcd.SelectedIndex = index;
51
+                }
52
+                traction.Commit();
53
+            }
54
+        }
55
+
56
+        private void button_ok_Click(object sender, EventArgs e)
57
+        {
58
+            if (comboBox_gcd.Text == "")
59
+            { 
60
+                MessageBox.Show("请选择高程点所在图层!");
61
+                return;
62
+            }
63
+            if (comboBox_blc.Text == "")
64
+            { 
65
+                MessageBox.Show("请选择比例尺!");
66
+                return;
67
+            }
68
+            if (checkedListBox_ly.CheckedItems.Count == 0)
69
+            {
70
+                MessageBox.Show("请至少选择一个图层!");
71
+                return;
72
+            }
73
+            DeletePts.gcdly = comboBox_gcd.Text;
74
+            string blctext = comboBox_blc.Text;
75
+            int blcindex = blctext.LastIndexOf(':');
76
+            string strblc = blctext.Substring(blcindex + 1);
77
+            DeletePts.blc = Convert.ToInt32(strblc);
78
+
79
+            for (int i = 0; i < checkedListBox_ly.CheckedItems.Count; i++)
80
+            {
81
+                DeletePts.delely.Add(checkedListBox_ly.CheckedItems[i].ToString());
82
+            }
83
+            DeletePts delept = new DeletePts();
84
+            delept.delept();
85
+            this.Close();
86
+        }
87
+
88
+        private void button_cancel_Click(object sender, EventArgs e)
89
+        {
90
+            this.Close();
91
+        }
92
+    }
93
+}

+ 120
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/DeleteElept.resx 查看文件

@@ -0,0 +1,120 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<root>
3
+  <!-- 
4
+    Microsoft ResX Schema 
5
+    
6
+    Version 2.0
7
+    
8
+    The primary goals of this format is to allow a simple XML format 
9
+    that is mostly human readable. The generation and parsing of the 
10
+    various data types are done through the TypeConverter classes 
11
+    associated with the data types.
12
+    
13
+    Example:
14
+    
15
+    ... ado.net/XML headers & schema ...
16
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
17
+    <resheader name="version">2.0</resheader>
18
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
19
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
20
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
21
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
22
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
24
+    </data>
25
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
26
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
27
+        <comment>This is a comment</comment>
28
+    </data>
29
+                
30
+    There are any number of "resheader" rows that contain simple 
31
+    name/value pairs.
32
+    
33
+    Each data row contains a name, and value. The row also contains a 
34
+    type or mimetype. Type corresponds to a .NET class that support 
35
+    text/value conversion through the TypeConverter architecture. 
36
+    Classes that don't support this are serialized and stored with the 
37
+    mimetype set.
38
+    
39
+    The mimetype is used for serialized objects, and tells the 
40
+    ResXResourceReader how to depersist the object. This is currently not 
41
+    extensible. For a given mimetype the value must be set accordingly:
42
+    
43
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
44
+    that the ResXResourceWriter will generate, however the reader can 
45
+    read any of the formats listed below.
46
+    
47
+    mimetype: application/x-microsoft.net.object.binary.base64
48
+    value   : The object must be serialized with 
49
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
50
+            : and then encoded with base64 encoding.
51
+    
52
+    mimetype: application/x-microsoft.net.object.soap.base64
53
+    value   : The object must be serialized with 
54
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
55
+            : and then encoded with base64 encoding.
56
+
57
+    mimetype: application/x-microsoft.net.object.bytearray.base64
58
+    value   : The object must be serialized into a byte array 
59
+            : using a System.ComponentModel.TypeConverter
60
+            : and then encoded with base64 encoding.
61
+    -->
62
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
64
+    <xsd:element name="root" msdata:IsDataSet="true">
65
+      <xsd:complexType>
66
+        <xsd:choice maxOccurs="unbounded">
67
+          <xsd:element name="metadata">
68
+            <xsd:complexType>
69
+              <xsd:sequence>
70
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
71
+              </xsd:sequence>
72
+              <xsd:attribute name="name" use="required" type="xsd:string" />
73
+              <xsd:attribute name="type" type="xsd:string" />
74
+              <xsd:attribute name="mimetype" type="xsd:string" />
75
+              <xsd:attribute ref="xml:space" />
76
+            </xsd:complexType>
77
+          </xsd:element>
78
+          <xsd:element name="assembly">
79
+            <xsd:complexType>
80
+              <xsd:attribute name="alias" type="xsd:string" />
81
+              <xsd:attribute name="name" type="xsd:string" />
82
+            </xsd:complexType>
83
+          </xsd:element>
84
+          <xsd:element name="data">
85
+            <xsd:complexType>
86
+              <xsd:sequence>
87
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
88
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
89
+              </xsd:sequence>
90
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
91
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
92
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
93
+              <xsd:attribute ref="xml:space" />
94
+            </xsd:complexType>
95
+          </xsd:element>
96
+          <xsd:element name="resheader">
97
+            <xsd:complexType>
98
+              <xsd:sequence>
99
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
100
+              </xsd:sequence>
101
+              <xsd:attribute name="name" type="xsd:string" use="required" />
102
+            </xsd:complexType>
103
+          </xsd:element>
104
+        </xsd:choice>
105
+      </xsd:complexType>
106
+    </xsd:element>
107
+  </xsd:schema>
108
+  <resheader name="resmimetype">
109
+    <value>text/microsoft-resx</value>
110
+  </resheader>
111
+  <resheader name="version">
112
+    <value>2.0</value>
113
+  </resheader>
114
+  <resheader name="reader">
115
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116
+  </resheader>
117
+  <resheader name="writer">
118
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119
+  </resheader>
120
+</root>

+ 160
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/DeletePts.cs 查看文件

@@ -0,0 +1,160 @@
1
+using Autodesk.AutoCAD.ApplicationServices;
2
+using Autodesk.AutoCAD.DatabaseServices;
3
+using Autodesk.AutoCAD.EditorInput;
4
+using Autodesk.AutoCAD.Geometry;
5
+using System;
6
+using System.Collections.Generic;
7
+using System.Linq;
8
+using System.Text;
9
+using System.Threading.Tasks;
10
+
11
+namespace CADTools
12
+{
13
+    class DeletePts
14
+    {
15
+        public static string gcdly;//高程点所在图层
16
+        public static List<string> delely = new List<string>();//需要删除的图层
17
+        public static int blc;//比例尺
18
+        public double radius;//半径
19
+
20
+        public void delept()
21
+        {
22
+            List<ObjectId> deleids = new List<ObjectId>();
23
+            if (blc == 500)
24
+            {
25
+                radius = 1.5;
26
+            }
27
+            else if (blc == 1000)
28
+            {
29
+                radius = 2.5;
30
+            }
31
+            else if (blc == 2000)
32
+            {
33
+                radius = 4;
34
+            }
35
+            else if (blc == 5000)
36
+            {
37
+                radius = 10.5;
38
+            }
39
+            //创建新图层
40
+            LayerControl layerscontrol = new LayerControl();
41
+            string layname = "已删除";
42
+            if (!layerscontrol.haslayername(layname))
43
+            {
44
+                colorgb col = new colorgb(255, 0, 255);
45
+                layerscontrol.creatlayer(layname, col);
46
+                layerscontrol.movelayertofront(layname);
47
+            }
48
+            else
49
+                layerscontrol.movelayertofront(layname);
50
+
51
+
52
+            for (int i = 0; i < delely.Count; i++)
53
+            {
54
+                List<ObjectId> temp = Idget(delely[i]);
55
+                for (int j = 0; j < temp.Count; j++)
56
+                {
57
+                    deleids.Add(temp[j]);
58
+                }
59
+            }
60
+            Database db = HostApplicationServices.WorkingDatabase;
61
+            DocumentLock doclock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
62
+            Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
63
+
64
+            for (int i = 0; i < deleids.Count; i++)
65
+            {
66
+                Point3dCollection ptcoll = new Point3dCollection();
67
+                using (Transaction trans = db.TransactionManager.StartTransaction())
68
+                {
69
+                    Entity ent = (Entity)trans.GetObject(deleids[i], OpenMode.ForWrite);
70
+                    if (ent is Polyline)
71
+                    {
72
+                        Polyline pll = (Polyline)trans.GetObject(deleids[i], OpenMode.ForWrite);
73
+                        for (int j = 0; j < pll.NumberOfVertices; j++)
74
+                        {
75
+                            ptcoll.Add(pll.GetPoint3dAt(j));
76
+                        }
77
+                    }
78
+                    trans.Commit();
79
+                }
80
+                if (ptcoll.Count != 0)
81
+                {
82
+                    Point3d p1 = new Point3d();
83
+                    Point3d p2 = new Point3d();
84
+                    TypedValue[] typedvalue = new TypedValue[]
85
+                    {
86
+                        new TypedValue((int)DxfCode.LayerName, gcdly),
87
+                        new TypedValue((int)DxfCode.Start, "Insert")
88
+                    };
89
+                    SelectionFilter selectionfilter = new SelectionFilter(typedvalue);
90
+                    PromptSelectionResult psr = editor.SelectCrossingPolygon(ptcoll, selectionfilter);
91
+                    if (psr.Status == PromptStatus.OK)
92
+                    {
93
+
94
+                        SelectionSet selectionset = psr.Value;
95
+                        ObjectId[] ids = selectionset.GetObjectIds();
96
+                        for (int j = 0; j < ids.Count(); j++)
97
+                        {
98
+                            using (Transaction trans = db.TransactionManager.StartTransaction())
99
+                            {
100
+                                BlockReference br = (BlockReference)trans.GetObject(ids[j], OpenMode.ForWrite);
101
+                                br.Layer = "已删除";
102
+                                p1 = new Point3d(br.Position.X - radius, br.Position.Y - radius, 0);
103
+                                p2 = new Point3d(br.Position.X + radius, br.Position.Y + radius, 0);
104
+                                trans.Commit();
105
+                            }
106
+                            TypedValue[] tpvl = new TypedValue[]
107
+                            {
108
+                                new TypedValue((int)DxfCode.Start, "Text"),
109
+                                new TypedValue((int)DxfCode.LayerName, gcdly)
110
+                            };
111
+
112
+                            SelectionFilter filter = new SelectionFilter(tpvl);
113
+                            PromptSelectionResult prosr = editor.SelectCrossingWindow(p1, p2, filter);
114
+
115
+                            if (prosr.Status == PromptStatus.OK)
116
+                            {
117
+                                using (Transaction trans = db.TransactionManager.StartTransaction())
118
+                                {
119
+                                    SelectionSet seleset = prosr.Value;
120
+                                    ObjectId[] selid = seleset.GetObjectIds();
121
+                                    for (int ii = 0; ii < selid.Count(); ii++)
122
+                                    {
123
+                                        DBText text = trans.GetObject(selid[ii], OpenMode.ForWrite) as DBText;
124
+                                        text.Layer = "已删除";
125
+                                    }
126
+                                    trans.Commit();
127
+                                }
128
+                            }
129
+                        }
130
+                    }
131
+                }
132
+            }
133
+            editor.WriteMessage("删除完成\n");
134
+            doclock.Dispose();
135
+        }
136
+
137
+        private static List<ObjectId> Idget(string ly)
138
+        {
139
+            Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
140
+            TypedValue[] typedvalue = new TypedValue[1];
141
+            typedvalue.SetValue(new TypedValue((int)DxfCode.LayerName, ly), 0);
142
+
143
+            SelectionFilter selectionfilter = new SelectionFilter(typedvalue);
144
+            PromptSelectionResult psr = editor.SelectAll(selectionfilter);
145
+            SelectionSet selectionset = psr.Value;
146
+            ObjectId[] obj = new ObjectId[selectionset.Count];
147
+            List<ObjectId> ids = new List<ObjectId>();
148
+
149
+            if (psr.Status == PromptStatus.OK)
150
+            {
151
+                obj = selectionset.GetObjectIds();
152
+                for (int i = 0; i < obj.Length; i++)
153
+                {
154
+                    ids.Add(obj[i]);
155
+                }
156
+            }
157
+            return ids;
158
+        }
159
+    }
160
+}

+ 162
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/DgxAnnck.cs 查看文件

@@ -0,0 +1,162 @@
1
+using Autodesk.AutoCAD.ApplicationServices;
2
+using Autodesk.AutoCAD.DatabaseServices;
3
+using Autodesk.AutoCAD.EditorInput;
4
+using Autodesk.AutoCAD.Geometry;
5
+using System;
6
+using System.Collections.Generic;
7
+using System.Linq;
8
+using System.Text;
9
+using System.Threading.Tasks;
10
+
11
+namespace CADTools
12
+{
13
+    class DgxAnnck
14
+    {
15
+        public static string ptlayer;
16
+        public static string tklayer;
17
+        public static double ptnumssity;
18
+        public static int flag;
19
+
20
+        public void check()
21
+        {
22
+            ObjectId[] ids = TKget();
23
+
24
+            Database db = HostApplicationServices.WorkingDatabase;
25
+            Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
26
+
27
+            TypedValue[] typedvalue = new TypedValue[1];
28
+            typedvalue.SetValue(new TypedValue((int)DxfCode.LayerName, ptlayer), 0);
29
+            SelectionFilter selectionfilter = new SelectionFilter(typedvalue);
30
+
31
+            for (int i = 0; i < ids.Length; i++)
32
+            {
33
+                Point3dCollection ptcoll = new Point3dCollection();
34
+                Entity current_entity = BasicFunction.GetDBObject(ids[i]);
35
+                ZoomToExtent(current_entity.GeometricExtents);
36
+                DocumentLock doclock1 = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
37
+                using (Transaction trans = db.TransactionManager.StartTransaction())
38
+                {
39
+                    Polyline pll = (Polyline)trans.GetObject(ids[i], OpenMode.ForWrite);
40
+                    for (int j = 0; j < pll.NumberOfVertices; j++)
41
+                    {
42
+                        ptcoll.Add(pll.GetPoint3dAt(j));
43
+                    }
44
+                    trans.Commit();
45
+                }
46
+                doclock1.Dispose();
47
+
48
+                PromptSelectionResult psr = editor.SelectCrossingPolygon(ptcoll, selectionfilter);
49
+                if (psr.Status == PromptStatus.OK)
50
+                {
51
+                    SelectionSet selectionset = psr.Value;
52
+                    DocumentLock doclock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
53
+                    using (Transaction trans = db.TransactionManager.StartTransaction())
54
+                    {
55
+                        Polyline pll = (Polyline)trans.GetObject(ids[i], OpenMode.ForWrite);
56
+                        int ptnums = selectionset.Count;
57
+                        if (ptnums < ptnumssity && flag == 1)
58
+                        {
59
+                            LayerControl layerscontrol = new LayerControl();
60
+                            string layname = "小于密度";
61
+                            if (!layerscontrol.haslayername(layname))
62
+                            {
63
+                                colorgb col = new colorgb(0, 0, 255);
64
+                                layerscontrol.creatlayer(layname, col);
65
+                                pll.Layer = "小于密度";
66
+                            }
67
+                            else
68
+                                pll.Layer = "小于密度";
69
+                            pll.Color = Autodesk.AutoCAD.Colors.Color.FromColorIndex(Autodesk.AutoCAD.Colors.ColorMethod.ByLayer, 256);
70
+                        }
71
+                        if (ptnums > ptnumssity && flag == 2)
72
+                        {
73
+                            LayerControl layerscontrol = new LayerControl();
74
+                            string layname = "大于密度";
75
+                            if (!layerscontrol.haslayername(layname))
76
+                            {
77
+                                colorgb col = new colorgb(255, 0, 0);
78
+                                layerscontrol.creatlayer(layname, col);
79
+                                pll.Layer = "大于密度";
80
+                            }
81
+                            else
82
+                                pll.Layer = "大于密度";
83
+                            pll.Color = Autodesk.AutoCAD.Colors.Color.FromColorIndex(Autodesk.AutoCAD.Colors.ColorMethod.ByLayer, 256);
84
+                        }
85
+                        if (flag == 3)
86
+                        {
87
+                            if (ptnums < ptnumssity || ptnums > ptnumssity)
88
+                            {
89
+                                LayerControl layerscontrol = new LayerControl();
90
+                                string layname = "不等于密度";
91
+                                if (!layerscontrol.haslayername(layname))
92
+                                {
93
+                                    colorgb col = new colorgb(255, 255, 0);
94
+                                    layerscontrol.creatlayer(layname, col);
95
+                                    pll.Layer = "不等于密度";
96
+                                }
97
+                                else
98
+                                    pll.Layer = "不等于密度";
99
+                                pll.Color = Autodesk.AutoCAD.Colors.Color.FromColorIndex(Autodesk.AutoCAD.Colors.ColorMethod.ByLayer, 256);
100
+                            }
101
+                        }
102
+                        trans.Commit();
103
+                    }
104
+                    doclock.Dispose();
105
+                }
106
+            }
107
+        }
108
+
109
+        private static ObjectId[] TKget()
110
+        {
111
+            Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
112
+            TypedValue[] typedvalue = new TypedValue[1];
113
+            typedvalue.SetValue(new TypedValue((int)DxfCode.LayerName, tklayer), 0);
114
+
115
+            SelectionFilter selectionfilter = new SelectionFilter(typedvalue);
116
+            PromptSelectionResult psr = editor.SelectAll(selectionfilter);
117
+            SelectionSet selectionset = psr.Value;
118
+            ObjectId[] obj = new ObjectId[selectionset.Count];
119
+
120
+            if (psr.Status == PromptStatus.OK)
121
+            {
122
+                obj = selectionset.GetObjectIds();
123
+            }
124
+            return obj;
125
+        }
126
+
127
+        public static void ZoomToExtent(Extents3d extent)
128
+        {
129
+            try
130
+            {
131
+                Point3d pMin = extent.MinPoint;
132
+                Point3d pMax = extent.MaxPoint;
133
+                //获取当前文档及数据库
134
+                Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
135
+                Database acCurDb = acDoc.Database;
136
+
137
+                // 启动事务
138
+                using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
139
+                {
140
+                    using (ViewTableRecord acView = acDoc.Editor.GetCurrentView())
141
+                    {
142
+                        //设置视图的高
143
+                        acView.Height = Math.Abs(pMin.Y - pMax.Y);
144
+                        //设置视图的宽
145
+                        acView.Width = Math.Abs(pMin.X - pMax.X);
146
+                        // 设置视图中心
147
+                        acView.CenterPoint = new Point2d((pMin.X + pMax.X) / 2, (pMin.Y + pMax.Y) / 2);
148
+                        // 更新当前视图
149
+                        acDoc.Editor.SetCurrentView(acView);
150
+                    }
151
+                    // 提交更改
152
+                    acTrans.Commit();
153
+                }
154
+            }
155
+            catch (Exception)
156
+            {
157
+
158
+                throw;
159
+            }
160
+        }
161
+    }
162
+}

+ 170
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/DgxAnno.Designer.cs 查看文件

@@ -0,0 +1,170 @@
1
+
2
+namespace CADTools
3
+{
4
+    partial class DgxAnno
5
+    {
6
+        /// <summary>
7
+        /// Required designer variable.
8
+        /// </summary>
9
+        private System.ComponentModel.IContainer components = null;
10
+
11
+        /// <summary>
12
+        /// Clean up any resources being used.
13
+        /// </summary>
14
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
15
+        protected override void Dispose(bool disposing)
16
+        {
17
+            if (disposing && (components != null))
18
+            {
19
+                components.Dispose();
20
+            }
21
+            base.Dispose(disposing);
22
+        }
23
+
24
+        #region Windows Form Designer generated code
25
+
26
+        /// <summary>
27
+        /// Required method for Designer support - do not modify
28
+        /// the contents of this method with the code editor.
29
+        /// </summary>
30
+        private void InitializeComponent()
31
+        {
32
+            this.checkBox_below = new System.Windows.Forms.CheckBox();
33
+            this.checkBox_upon = new System.Windows.Forms.CheckBox();
34
+            this.textBox_density = new System.Windows.Forms.TextBox();
35
+            this.label3 = new System.Windows.Forms.Label();
36
+            this.button_cancel = new System.Windows.Forms.Button();
37
+            this.button_ok = new System.Windows.Forms.Button();
38
+            this.comboBox_gw = new System.Windows.Forms.ComboBox();
39
+            this.comboBox_ptLayer = new System.Windows.Forms.ComboBox();
40
+            this.label2 = new System.Windows.Forms.Label();
41
+            this.label1 = new System.Windows.Forms.Label();
42
+            this.SuspendLayout();
43
+            // 
44
+            // checkBox_below
45
+            // 
46
+            this.checkBox_below.AutoSize = true;
47
+            this.checkBox_below.Location = new System.Drawing.Point(236, 135);
48
+            this.checkBox_below.Name = "checkBox_below";
49
+            this.checkBox_below.Size = new System.Drawing.Size(89, 19);
50
+            this.checkBox_below.TabIndex = 21;
51
+            this.checkBox_below.Text = "小于密度";
52
+            this.checkBox_below.UseVisualStyleBackColor = true;
53
+            // 
54
+            // checkBox_upon
55
+            // 
56
+            this.checkBox_upon.AutoSize = true;
57
+            this.checkBox_upon.Location = new System.Drawing.Point(346, 135);
58
+            this.checkBox_upon.Name = "checkBox_upon";
59
+            this.checkBox_upon.Size = new System.Drawing.Size(89, 19);
60
+            this.checkBox_upon.TabIndex = 20;
61
+            this.checkBox_upon.Text = "大于密度";
62
+            this.checkBox_upon.UseVisualStyleBackColor = true;
63
+            // 
64
+            // textBox_density
65
+            // 
66
+            this.textBox_density.Location = new System.Drawing.Point(104, 133);
67
+            this.textBox_density.Name = "textBox_density";
68
+            this.textBox_density.Size = new System.Drawing.Size(100, 25);
69
+            this.textBox_density.TabIndex = 19;
70
+            // 
71
+            // label3
72
+            // 
73
+            this.label3.AutoSize = true;
74
+            this.label3.Location = new System.Drawing.Point(46, 139);
75
+            this.label3.Name = "label3";
76
+            this.label3.Size = new System.Drawing.Size(52, 15);
77
+            this.label3.TabIndex = 18;
78
+            this.label3.Text = "密度:";
79
+            // 
80
+            // button_cancel
81
+            // 
82
+            this.button_cancel.Location = new System.Drawing.Point(290, 178);
83
+            this.button_cancel.Name = "button_cancel";
84
+            this.button_cancel.Size = new System.Drawing.Size(75, 29);
85
+            this.button_cancel.TabIndex = 17;
86
+            this.button_cancel.Text = "取 消";
87
+            this.button_cancel.UseVisualStyleBackColor = true;
88
+            this.button_cancel.Click += new System.EventHandler(this.button_cancel_Click);
89
+            // 
90
+            // button_ok
91
+            // 
92
+            this.button_ok.Location = new System.Drawing.Point(100, 178);
93
+            this.button_ok.Name = "button_ok";
94
+            this.button_ok.Size = new System.Drawing.Size(75, 29);
95
+            this.button_ok.TabIndex = 16;
96
+            this.button_ok.Text = "确 定";
97
+            this.button_ok.UseVisualStyleBackColor = true;
98
+            this.button_ok.Click += new System.EventHandler(this.button_ok_Click);
99
+            // 
100
+            // comboBox_gw
101
+            // 
102
+            this.comboBox_gw.FormattingEnabled = true;
103
+            this.comboBox_gw.Location = new System.Drawing.Point(185, 83);
104
+            this.comboBox_gw.Name = "comboBox_gw";
105
+            this.comboBox_gw.Size = new System.Drawing.Size(197, 23);
106
+            this.comboBox_gw.TabIndex = 15;
107
+            // 
108
+            // comboBox_ptLayer
109
+            // 
110
+            this.comboBox_ptLayer.FormattingEnabled = true;
111
+            this.comboBox_ptLayer.Location = new System.Drawing.Point(185, 34);
112
+            this.comboBox_ptLayer.Name = "comboBox_ptLayer";
113
+            this.comboBox_ptLayer.Size = new System.Drawing.Size(197, 23);
114
+            this.comboBox_ptLayer.TabIndex = 14;
115
+            // 
116
+            // label2
117
+            // 
118
+            this.label2.AutoSize = true;
119
+            this.label2.Location = new System.Drawing.Point(67, 86);
120
+            this.label2.Name = "label2";
121
+            this.label2.Size = new System.Drawing.Size(112, 15);
122
+            this.label2.TabIndex = 13;
123
+            this.label2.Text = "格网所在图层:";
124
+            // 
125
+            // label1
126
+            // 
127
+            this.label1.AutoSize = true;
128
+            this.label1.Location = new System.Drawing.Point(22, 37);
129
+            this.label1.Name = "label1";
130
+            this.label1.Size = new System.Drawing.Size(157, 15);
131
+            this.label1.TabIndex = 12;
132
+            this.label1.Text = "等高线注记所在图层:";
133
+            // 
134
+            // DgxAnno
135
+            // 
136
+            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
137
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
138
+            this.ClientSize = new System.Drawing.Size(478, 232);
139
+            this.Controls.Add(this.checkBox_below);
140
+            this.Controls.Add(this.checkBox_upon);
141
+            this.Controls.Add(this.textBox_density);
142
+            this.Controls.Add(this.label3);
143
+            this.Controls.Add(this.button_cancel);
144
+            this.Controls.Add(this.button_ok);
145
+            this.Controls.Add(this.comboBox_gw);
146
+            this.Controls.Add(this.comboBox_ptLayer);
147
+            this.Controls.Add(this.label2);
148
+            this.Controls.Add(this.label1);
149
+            this.Name = "DgxAnno";
150
+            this.Text = "等高线高程注记密度检查";
151
+            this.Load += new System.EventHandler(this.DgxAnno_Load);
152
+            this.ResumeLayout(false);
153
+            this.PerformLayout();
154
+
155
+        }
156
+
157
+        #endregion
158
+
159
+        private System.Windows.Forms.CheckBox checkBox_below;
160
+        private System.Windows.Forms.CheckBox checkBox_upon;
161
+        private System.Windows.Forms.TextBox textBox_density;
162
+        private System.Windows.Forms.Label label3;
163
+        private System.Windows.Forms.Button button_cancel;
164
+        private System.Windows.Forms.Button button_ok;
165
+        private System.Windows.Forms.ComboBox comboBox_gw;
166
+        private System.Windows.Forms.ComboBox comboBox_ptLayer;
167
+        private System.Windows.Forms.Label label2;
168
+        private System.Windows.Forms.Label label1;
169
+    }
170
+}

+ 101
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/DgxAnno.cs 查看文件

@@ -0,0 +1,101 @@
1
+using Autodesk.AutoCAD.DatabaseServices;
2
+using System;
3
+using System.Collections.Generic;
4
+using System.ComponentModel;
5
+using System.Data;
6
+using System.Drawing;
7
+using System.Linq;
8
+using System.Text;
9
+using System.Threading.Tasks;
10
+using System.Windows.Forms;
11
+
12
+namespace CADTools
13
+{
14
+    public partial class DgxAnno : Form
15
+    {
16
+        public DgxAnno()
17
+        {
18
+            InitializeComponent();
19
+        }
20
+
21
+        private void DgxAnno_Load(object sender, EventArgs e)
22
+        {
23
+            this.comboBox_ptLayer.DropDownStyle = ComboBoxStyle.DropDownList;
24
+            this.comboBox_gw.DropDownStyle = ComboBoxStyle.DropDownList;
25
+
26
+            this.MaximizeBox = false;
27
+            this.StartPosition = FormStartPosition.CenterScreen;
28
+
29
+            //自动填充下拉框
30
+            Database database = Autodesk.AutoCAD.DatabaseServices.HostApplicationServices.WorkingDatabase;
31
+            using (Transaction traction = database.TransactionManager.StartTransaction())
32
+            {
33
+                //存放所有图层名
34
+                List<string> alllayername = new List<string>();
35
+                LayerTable layertable = traction.GetObject(database.LayerTableId, OpenMode.ForRead) as LayerTable;
36
+                foreach (ObjectId objid in layertable)
37
+                {
38
+                    LayerTableRecord layertablerecord = traction.GetObject(objid, OpenMode.ForRead) as LayerTableRecord;
39
+                    alllayername.Add(layertablerecord.Name);
40
+                }
41
+
42
+                alllayername.Sort();
43
+
44
+                for (int i = 0; i < alllayername.Count; i++)
45
+                {
46
+                    this.comboBox_ptLayer.Items.Add(alllayername[i]);
47
+                    this.comboBox_gw.Items.Add(alllayername[i]);
48
+                }
49
+
50
+                if (alllayername.Contains("8121"))
51
+                {
52
+                    int index = alllayername.IndexOf("8121");
53
+                    this.comboBox_ptLayer.SelectedIndex = index;
54
+                }
55
+                traction.Commit();
56
+            }
57
+        }
58
+
59
+        private void button_ok_Click(object sender, EventArgs e)
60
+        {
61
+            if (comboBox_ptLayer.Text == "")
62
+            {
63
+                MessageBox.Show("请选择等高线注记所在图层!");
64
+                return;
65
+            }
66
+            if (comboBox_gw.Text == "")
67
+            {
68
+                MessageBox.Show("请选择格网所在图层!");
69
+                return;
70
+            }
71
+            if (textBox_density.Text == "")
72
+            {
73
+                MessageBox.Show("请输入密度!");
74
+                return;
75
+            }
76
+            DgxAnnck.ptlayer = comboBox_ptLayer.Text;
77
+            DgxAnnck.tklayer = comboBox_gw.Text;
78
+            DgxAnnck.ptnumssity = Convert.ToDouble(textBox_density.Text);
79
+            if (checkBox_below.Checked && !checkBox_upon.Checked)
80
+                DgxAnnck.flag = 1;
81
+            else if (!checkBox_below.Checked && checkBox_upon.Checked)
82
+                DgxAnnck.flag = 2;
83
+            else if (checkBox_below.Checked && checkBox_upon.Checked)
84
+                DgxAnnck.flag = 3;
85
+            else if (!checkBox_below.Checked && !checkBox_upon.Checked)
86
+            {
87
+                MessageBox.Show("请选择“大于密度”/“小于密度”!");
88
+                return;
89
+            }
90
+
91
+            DgxAnnck dgx = new DgxAnnck();
92
+            dgx.check();
93
+            this.Close();
94
+        }
95
+
96
+        private void button_cancel_Click(object sender, EventArgs e)
97
+        {
98
+            this.Close();
99
+        }
100
+    }
101
+}

+ 120
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/DgxAnno.resx 查看文件

@@ -0,0 +1,120 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<root>
3
+  <!-- 
4
+    Microsoft ResX Schema 
5
+    
6
+    Version 2.0
7
+    
8
+    The primary goals of this format is to allow a simple XML format 
9
+    that is mostly human readable. The generation and parsing of the 
10
+    various data types are done through the TypeConverter classes 
11
+    associated with the data types.
12
+    
13
+    Example:
14
+    
15
+    ... ado.net/XML headers & schema ...
16
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
17
+    <resheader name="version">2.0</resheader>
18
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
19
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
20
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
21
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
22
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
24
+    </data>
25
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
26
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
27
+        <comment>This is a comment</comment>
28
+    </data>
29
+                
30
+    There are any number of "resheader" rows that contain simple 
31
+    name/value pairs.
32
+    
33
+    Each data row contains a name, and value. The row also contains a 
34
+    type or mimetype. Type corresponds to a .NET class that support 
35
+    text/value conversion through the TypeConverter architecture. 
36
+    Classes that don't support this are serialized and stored with the 
37
+    mimetype set.
38
+    
39
+    The mimetype is used for serialized objects, and tells the 
40
+    ResXResourceReader how to depersist the object. This is currently not 
41
+    extensible. For a given mimetype the value must be set accordingly:
42
+    
43
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
44
+    that the ResXResourceWriter will generate, however the reader can 
45
+    read any of the formats listed below.
46
+    
47
+    mimetype: application/x-microsoft.net.object.binary.base64
48
+    value   : The object must be serialized with 
49
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
50
+            : and then encoded with base64 encoding.
51
+    
52
+    mimetype: application/x-microsoft.net.object.soap.base64
53
+    value   : The object must be serialized with 
54
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
55
+            : and then encoded with base64 encoding.
56
+
57
+    mimetype: application/x-microsoft.net.object.bytearray.base64
58
+    value   : The object must be serialized into a byte array 
59
+            : using a System.ComponentModel.TypeConverter
60
+            : and then encoded with base64 encoding.
61
+    -->
62
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
64
+    <xsd:element name="root" msdata:IsDataSet="true">
65
+      <xsd:complexType>
66
+        <xsd:choice maxOccurs="unbounded">
67
+          <xsd:element name="metadata">
68
+            <xsd:complexType>
69
+              <xsd:sequence>
70
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
71
+              </xsd:sequence>
72
+              <xsd:attribute name="name" use="required" type="xsd:string" />
73
+              <xsd:attribute name="type" type="xsd:string" />
74
+              <xsd:attribute name="mimetype" type="xsd:string" />
75
+              <xsd:attribute ref="xml:space" />
76
+            </xsd:complexType>
77
+          </xsd:element>
78
+          <xsd:element name="assembly">
79
+            <xsd:complexType>
80
+              <xsd:attribute name="alias" type="xsd:string" />
81
+              <xsd:attribute name="name" type="xsd:string" />
82
+            </xsd:complexType>
83
+          </xsd:element>
84
+          <xsd:element name="data">
85
+            <xsd:complexType>
86
+              <xsd:sequence>
87
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
88
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
89
+              </xsd:sequence>
90
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
91
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
92
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
93
+              <xsd:attribute ref="xml:space" />
94
+            </xsd:complexType>
95
+          </xsd:element>
96
+          <xsd:element name="resheader">
97
+            <xsd:complexType>
98
+              <xsd:sequence>
99
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
100
+              </xsd:sequence>
101
+              <xsd:attribute name="name" type="xsd:string" use="required" />
102
+            </xsd:complexType>
103
+          </xsd:element>
104
+        </xsd:choice>
105
+      </xsd:complexType>
106
+    </xsd:element>
107
+  </xsd:schema>
108
+  <resheader name="resmimetype">
109
+    <value>text/microsoft-resx</value>
110
+  </resheader>
111
+  <resheader name="version">
112
+    <value>2.0</value>
113
+  </resheader>
114
+  <resheader name="reader">
115
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116
+  </resheader>
117
+  <resheader name="writer">
118
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119
+  </resheader>
120
+</root>

+ 512
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/DgxCrossrvrd.cs 查看文件

@@ -0,0 +1,512 @@
1
+using Autodesk.AutoCAD.ApplicationServices;
2
+using Autodesk.AutoCAD.DatabaseServices;
3
+using Autodesk.AutoCAD.EditorInput;
4
+using Autodesk.AutoCAD.Geometry;
5
+using GeoAPI.Geometries;
6
+using NetTopologySuite.Geometries;
7
+using System;
8
+using System.Collections.Generic;
9
+using System.Linq;
10
+using System.Text;
11
+using System.Threading.Tasks;
12
+
13
+namespace CADTools
14
+{
15
+    class DgxCrossrvrd
16
+    {
17
+        public static List<string> dgxlist;
18
+        public static List<string> rvrdlist;
19
+        public static List<string> houselist;
20
+        public static int blc;
21
+        public static double yz;
22
+
23
+        public void DgxCut()
24
+        {
25
+            Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
26
+            Database db = Autodesk.AutoCAD.DatabaseServices.HostApplicationServices.WorkingDatabase;
27
+            Editor ed = doc.Editor;
28
+
29
+            string housename = string.Join(",", houselist.Distinct());
30
+            string dgxname = string.Join(",", dgxlist.Distinct());
31
+            string rvrdname = string.Join(",", rvrdlist.Distinct());
32
+
33
+            //过房屋裁剪
34
+            TypedValue[] value = new TypedValue[]
35
+            {
36
+                new TypedValue((int)DxfCode.LayerName,housename)
37
+            };
38
+            SelectionFilter filter = new SelectionFilter(value);
39
+            PromptSelectionResult psr = ed.SelectAll(filter);
40
+            if (psr.Status == PromptStatus.OK)
41
+            {
42
+                SelectionSet ss = psr.Value;
43
+                ObjectIdCollection idcoll = new ObjectIdCollection(ss.GetObjectIds());
44
+                for (int ii = 0; ii < idcoll.Count; ii++)
45
+                {
46
+                    Polyline pll = new Polyline();
47
+                    DocumentLock doclock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
48
+                    using (Transaction trans = db.TransactionManager.StartTransaction())
49
+                    {
50
+                        Entity ent = trans.GetObject(idcoll[ii], OpenMode.ForWrite) as Entity;
51
+                        if (ent is Polyline)
52
+                            pll = (Polyline)ent;
53
+                        trans.Commit();
54
+                    }
55
+                    doclock.Dispose();
56
+                    if (pll.Database != null)
57
+                        housebreak(pll, doc, dgxname);
58
+                }
59
+            }
60
+
61
+            dynamic acadApp = Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication;
62
+            acadApp.ZoomExtents();
63
+            //过河流道路裁剪
64
+            TypedValue[] value1 = new TypedValue[]
65
+            {
66
+                new TypedValue((int)DxfCode.LayerName,dgxname)
67
+            };
68
+            SelectionFilter filter1 = new SelectionFilter(value1);
69
+            PromptSelectionResult psr1 = ed.SelectAll(filter1);
70
+            if (psr1.Status == PromptStatus.OK)
71
+            {
72
+                SelectionSet ss = psr1.Value;
73
+                ObjectIdCollection idcoll = new ObjectIdCollection(ss.GetObjectIds());
74
+                Polyline pll = new Polyline();
75
+                for (int ii = 0; ii < idcoll.Count; ii++)
76
+                {
77
+                    DocumentLock doclock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
78
+                    using (Transaction trans = db.TransactionManager.StartTransaction())
79
+                    {
80
+                        Entity ent = trans.GetObject(idcoll[ii], OpenMode.ForWrite) as Entity;
81
+                        if (ent is Polyline)
82
+                        { 
83
+                            pll = (Polyline)ent;
84
+                            if (pll.Length < yz)
85
+                            { 
86
+                                pll.Erase();
87
+                                trans.Commit();
88
+                                doclock.Dispose();
89
+                                continue;
90
+                            }
91
+                        }
92
+                        trans.Commit();
93
+                    }
94
+                    doclock.Dispose();
95
+
96
+                    if (pll.Database != null)
97
+                    {
98
+                        rvrdbreak(pll, doc, rvrdname);
99
+                    }
100
+                }
101
+            }
102
+        }
103
+
104
+        private void housebreak(Polyline pll, Document doc, string dgxname)
105
+        {
106
+            Database db = doc.Database;
107
+            Editor ed = doc.Editor;
108
+            Point3dCollection ptcoll = new Point3dCollection();
109
+            List<Point3d> pts = new List<Point3d>();
110
+
111
+            for (int i = 0; i < pll.NumberOfVertices; i++)
112
+            {
113
+                if (!ptcoll.Contains(pll.GetPoint3dAt(i)))
114
+                    ptcoll.Add(pll.GetPoint3dAt(i));
115
+            }
116
+            //dynamic acadApp = Application.AcadApplication;
117
+            //double[] lowerLeft = pll.Bounds.Value.MinPoint.ToArray();
118
+            //double[] upperRight = pll.Bounds.Value.MaxPoint.ToArray();
119
+            //acadApp.ZoomWindow(lowerLeft, upperRight);
120
+            ZoomView(ed, pll.Bounds.Value.MinPoint, pll.Bounds.Value.MaxPoint);
121
+            ed.UpdateScreen();
122
+            TypedValue[] value = new TypedValue[]
123
+            {
124
+                new TypedValue((int)DxfCode.LayerName,dgxname)
125
+            };
126
+            SelectionFilter filter = new SelectionFilter(value);
127
+            PromptSelectionResult psr = ed.SelectCrossingPolygon(ptcoll, filter);
128
+            if (psr.Status == PromptStatus.OK)
129
+            {
130
+                SelectionSet ss = psr.Value;
131
+                ObjectIdCollection idcoll = new ObjectIdCollection(ss.GetObjectIds());
132
+                for (int ii = 0; ii < idcoll.Count; ii++)
133
+                {
134
+                    pts.Clear();
135
+                    Polyline pll_new = new Polyline();
136
+                    DocumentLock doclock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
137
+                    using (Transaction trans = db.TransactionManager.StartTransaction())
138
+                    {
139
+                        Entity ent = trans.GetObject(idcoll[ii], OpenMode.ForWrite) as Entity;
140
+                        if (ent is Polyline)
141
+                        {
142
+                            pll_new = (Polyline)ent;
143
+                            var interspt = GetIntersections(pll_new, pll);
144
+                            if (interspt.Count > 0)
145
+                            {
146
+                                //try
147
+                                //{
148
+                                foreach (Point3d pt in interspt)
149
+                                {
150
+                                    pts.Add(pt);
151
+                                    //double param = pll.GetParameterAtPoint(pt);
152
+                                    //double dist = pll.GetDistanceAtParameter(param);
153
+
154
+                                    //// 检查是否与已有点的距离小于0.01
155
+                                    //if (!pts.Any(p => Math.Abs(pll_new.GetDistAtPoint(p) - dist) < 0.01))
156
+                                    //{
157
+                                    //    pts.Add(pt);
158
+                                    //}
159
+                                    //    }
160
+                                }
161
+                                //catch
162
+                                //{
163
+                                //    continue;
164
+                                //}
165
+                            }
166
+                            if (pts.Count > 0)
167
+                            {
168
+                                //创建新图层
169
+                                LayerControl layerscontrol = new LayerControl();
170
+                                string layname = "待删除等高线";
171
+                                if (!layerscontrol.haslayername(layname))
172
+                                {
173
+                                    colorgb col = new colorgb(255, 0, 255);
174
+                                    layerscontrol.creatlayer(layname, col);
175
+                                    layerscontrol.movelayertofront(layname);
176
+                                }
177
+                                else
178
+                                    layerscontrol.movelayertofront(layname);
179
+                                Geometry ntsLine = ConvertToNtsLineString(pll_new);
180
+                                Geometry ntsPolygon = ConvertToNtsPolygon(pll);
181
+
182
+                                //计算交集和差集
183
+                                Geometry intersection = (Geometry)ntsLine.Intersection(ntsPolygon);      // 在多边形内部的部分
184
+                                Geometry difference = (Geometry)ntsLine.Difference(ntsPolygon);          // 在多边形外部的部分
185
+
186
+                                List<Polyline> results1 = new List<Polyline>();
187
+                                List<Polyline> results2 = new List<Polyline>();
188
+
189
+                                //转换回 AutoCAD 多段线
190
+                                if (intersection != null && !intersection.IsEmpty)
191
+                                {
192
+                                    results1.AddRange(ConvertToAcadPolylines(intersection));
193
+                                }
194
+                                if (difference != null && !difference.IsEmpty)
195
+                                {
196
+                                    results2.AddRange(ConvertToAcadPolylines(difference));
197
+                                }
198
+
199
+                                for (int i = 0; i < results1.Count; i++)
200
+                                {
201
+                                    BlockTable bt = (BlockTable)(trans.GetObject(db.BlockTableId, OpenMode.ForRead));
202
+                                    BlockTableRecord btr = (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
203
+                                    results1[i].Elevation = pll_new.Elevation;
204
+                                    btr.AppendEntity(results1[i]);
205
+                                    trans.AddNewlyCreatedDBObject(results1[i], true);
206
+                                    results1[i].Layer = "待删除等高线";
207
+                                }
208
+                                for (int i = 0; i < results2.Count; i++)
209
+                                {
210
+                                    BlockTable bt = (BlockTable)(trans.GetObject(db.BlockTableId, OpenMode.ForRead));
211
+                                    BlockTableRecord btr = (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
212
+                                    results2[i].Elevation = pll_new.Elevation;
213
+                                    btr.AppendEntity(results2[i]);
214
+                                    trans.AddNewlyCreatedDBObject(results2[i], true);
215
+                                    results2[i].Layer = pll_new.Layer;
216
+                                }
217
+                                pll_new.Erase();
218
+                            }
219
+                        }
220
+                        trans.Commit();
221
+                    }
222
+                    doclock.Dispose();
223
+                }
224
+            }
225
+        }
226
+
227
+        private void rvrdbreak(Polyline pll, Document doc, string rvrdname)
228
+        {
229
+            Database db = doc.Database;
230
+            Editor ed = doc.Editor;
231
+            Point3dCollection ptcoll = new Point3dCollection();
232
+            List<Point3d> pts = new List<Point3d>();
233
+
234
+            TypedValue[] value = new TypedValue[]
235
+            {
236
+                new TypedValue((int)DxfCode.LayerName,rvrdname)
237
+            };
238
+            SelectionFilter filter = new SelectionFilter(value);
239
+            ZoomView(ed, pll.Bounds.Value.MinPoint, pll.Bounds.Value.MaxPoint);
240
+            ed.UpdateScreen();
241
+            PromptSelectionResult psr = ed.SelectCrossingWindow(pll.Bounds.Value.MinPoint, pll.Bounds.Value.MaxPoint, filter);
242
+            if (psr.Status == PromptStatus.OK)
243
+            {
244
+                SelectionSet ss = psr.Value;
245
+                ObjectIdCollection idcoll = new ObjectIdCollection(ss.GetObjectIds());
246
+
247
+                Polyline pll_rvrd = new Polyline();
248
+                DocumentLock doclock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
249
+                using (Transaction trans = db.TransactionManager.StartTransaction())
250
+                {
251
+                    for (int i = 0; i < idcoll.Count; i++)
252
+                    {
253
+                        Entity ent1 = trans.GetObject(idcoll[i], OpenMode.ForWrite) as Entity;
254
+                        if (ent1 is Polyline)
255
+                        {
256
+                            pll_rvrd = (Polyline)ent1;
257
+                            List<Point3d> intersectionPoints = GetIntersections(pll, pll_rvrd);
258
+
259
+                            if (intersectionPoints.Count > 0)
260
+                            {
261
+                                try
262
+                                {
263
+                                    foreach (Point3d pt in intersectionPoints)
264
+                                    {
265
+                                        double param = pll.GetParameterAtPoint(pt);
266
+                                        double dist = pll.GetDistanceAtParameter(param);
267
+
268
+                                        // 检查是否与已有点的距离小于0.01
269
+                                        if (!pts.Any(p => Math.Abs(pll.GetDistAtPoint(p) - dist) < 0.01))
270
+                                        {
271
+                                            pts.Add(pt);
272
+                                        }
273
+                                    }
274
+                                }
275
+                                catch
276
+                                {
277
+                                    continue;
278
+                                }
279
+                            }
280
+                        }
281
+                    }
282
+                    if (pts.Count > 0)
283
+                    {
284
+                        //创建新图层
285
+                        LayerControl layerscontrol = new LayerControl();
286
+                        string layname = "待删除等高线";
287
+                        if (!layerscontrol.haslayername(layname))
288
+                        {
289
+                            colorgb col = new colorgb(255, 0, 255);
290
+                            layerscontrol.creatlayer(layname, col);
291
+                            layerscontrol.movelayertofront(layname);
292
+                        }
293
+                        else
294
+                            layerscontrol.movelayertofront(layname);
295
+                        var ptssorted = pts.OrderBy(p => pll.GetDistAtPoint(p)).ToList();
296
+                        Point3dCollection ptcoll1 = new Point3dCollection();
297
+                        foreach (var item in ptssorted)
298
+                        {
299
+                            ptcoll1.Add(item);
300
+                        }
301
+                        var splitlines = pll.GetSplitCurves(ptcoll1);
302
+                        List<Polyline> split_pls = new List<Polyline>();
303
+                        for (int ii = 0; ii < splitlines.Count; ii++)
304
+                        {
305
+                            split_pls.Add((Polyline)splitlines[ii]);
306
+                        }
307
+                        var split_plssorted = split_pls.OrderBy(p => pll.GetDistAtPoint(p.StartPoint)).ToList();
308
+                        for (int ii = 0; ii < split_plssorted.Count; ii++)
309
+                        {
310
+                            if (split_plssorted[ii].Length <= yz)
311
+                            {
312
+                                BlockTable bt = (BlockTable)(trans.GetObject(db.BlockTableId, OpenMode.ForRead));
313
+                                BlockTableRecord btr = (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
314
+                                btr.AppendEntity(split_plssorted[ii]);
315
+                                trans.AddNewlyCreatedDBObject(split_plssorted[ii], true);
316
+                                split_plssorted[ii].Layer = "待删除等高线";
317
+                            }
318
+                            else
319
+                            {
320
+                                BlockTable bt = (BlockTable)(trans.GetObject(db.BlockTableId, OpenMode.ForRead));
321
+                                BlockTableRecord btr = (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
322
+                                btr.AppendEntity(split_plssorted[ii]);
323
+                                trans.AddNewlyCreatedDBObject(split_plssorted[ii], true);
324
+                                split_plssorted[ii].Layer = pll.Layer;
325
+                            }
326
+
327
+                        }
328
+
329
+                        Polyline dgx = trans.GetObject(pll.ObjectId, OpenMode.ForWrite) as Polyline;
330
+                        dgx.Erase();
331
+                    }
332
+                    trans.Commit();
333
+                    doclock.Dispose();
334
+                }
335
+            }
336
+        }
337
+
338
+        /// <summary>
339
+        /// 批量裁剪:将穿过封闭多边形的线裁剪,移除内部部分
340
+        /// </summary>
341
+        public List<Polyline> ClipLinesByPolygon(List<Polyline> lines, Polyline polygonBoundary, bool keepInside = false)
342
+        {
343
+            List<Polyline> allResults = new List<Polyline>();
344
+            Geometry ntsPolygon = ConvertToNtsPolygon(polygonBoundary);
345
+
346
+            if (ntsPolygon == null)
347
+                return allResults;
348
+
349
+            foreach (Polyline line in lines)
350
+            {
351
+                Geometry ntsLine = ConvertToNtsLineString(line);
352
+                if (ntsLine == null)
353
+                    continue;
354
+
355
+                Geometry resultGeometry = (Geometry)(keepInside ?
356
+                    ntsLine.Intersection(ntsPolygon) :
357
+                    ntsLine.Difference(ntsPolygon));
358
+
359
+                if (resultGeometry != null && !resultGeometry.IsEmpty)
360
+                {
361
+                    allResults.AddRange(ConvertToAcadPolylines(resultGeometry));
362
+                }
363
+            }
364
+
365
+            return allResults;
366
+        }
367
+
368
+        /// <summary>
369
+        /// 将 AutoCAD Polyline 转换为 NetTopologySuite LineString
370
+        /// </summary>
371
+        private LineString ConvertToNtsLineString(Polyline polyline)
372
+        {
373
+            if (polyline == null || polyline.NumberOfVertices < 2)
374
+                return null;
375
+
376
+            List<Coordinate> coordinates = new List<Coordinate>();
377
+
378
+            for (int i = 0; i < polyline.NumberOfVertices; i++)
379
+            {
380
+                Point3d pt = polyline.GetPoint3dAt(i);
381
+                coordinates.Add(new Coordinate(pt.X, pt.Y, pt.Z));
382
+            }
383
+
384
+            // 如果是闭合多段线,需要添加起点作为终点
385
+            if (polyline.Closed && coordinates.Count > 1)
386
+            {
387
+                coordinates.Add(coordinates[0]);
388
+            }
389
+
390
+            var geometryFactory = new GeometryFactory();
391
+            return (LineString)geometryFactory.CreateLineString(coordinates.ToArray());
392
+        }
393
+
394
+        /// <summary>
395
+        /// 将AutoCAD多段线转换为NTS多边形
396
+        /// </summary>
397
+        private Polygon ConvertToNtsPolygon(Polyline polyline)
398
+        {
399
+            var coordinates = new List<Coordinate>();
400
+            List<Point3d> pts = new List<Point3d>();
401
+            for (int i = 0; i < polyline.NumberOfVertices; i++)
402
+            {
403
+                Point3d point = polyline.GetPoint3dAt(i);
404
+                coordinates.Add(new Coordinate(point.X, point.Y));
405
+                pts.Add(point);
406
+            }
407
+            coordinates.Add(new Coordinate(coordinates[0].X, coordinates[0].Y));
408
+            if (pts[0].DistanceTo(pts[pts.Count - 1]) < 0.01)
409
+                coordinates.RemoveAt(coordinates.Count - 2);
410
+            var geometryFactory = new GeometryFactory();
411
+            return (Polygon)geometryFactory.CreatePolygon(coordinates.ToArray());
412
+        }
413
+
414
+        private List<Point3d> GetIntersections(Polyline pll1, Polyline pll2)
415
+        {
416
+            List<Point3d> result = new List<Point3d>();
417
+
418
+            // 创建临时副本
419
+            using (Polyline tempLine1 = (Polyline)pll1.Clone())
420
+            using (Polyline tempLine2 = (Polyline)pll2.Clone())
421
+            {
422
+
423
+                // 计算平移向量(以线1起点为基准,移动至原点)
424
+                Vector3d translation = -tempLine1.StartPoint.GetAsVector();
425
+                Matrix3d translateMatrix = Matrix3d.Displacement(translation);
426
+
427
+                // 应用平移变换
428
+                tempLine1.TransformBy(translateMatrix);
429
+                tempLine2.TransformBy(translateMatrix);
430
+
431
+                Point3dCollection translatedPoints = new Point3dCollection();
432
+                var plane = new Plane(Point3d.Origin, Vector3d.ZAxis);
433
+                tempLine1.IntersectWith(tempLine2, Intersect.OnBothOperands, plane, translatedPoints, IntPtr.Zero, IntPtr.Zero);
434
+
435
+                // 计算逆平移矩阵
436
+                Matrix3d inverseMatrix = Matrix3d.Displacement(-translation);
437
+                if (translatedPoints.Count > 0)
438
+                {
439
+                    // 获取平移后的交点
440
+                    foreach (Point3d item in translatedPoints)
441
+                    {
442
+                        // 恢复交点坐标
443
+                        var pt = item.TransformBy(inverseMatrix);
444
+                        var pt1 = pll1.GetClosestPointTo(pt, false);
445
+                        result.Add(pt1);
446
+                    }
447
+                    translatedPoints.Dispose();
448
+                }
449
+                tempLine1.Dispose();
450
+                tempLine2.Dispose();
451
+            }
452
+            return result;
453
+        }
454
+
455
+        private List<Polyline> ConvertToAcadPolylines(Geometry geometry)
456
+        {
457
+            List<Polyline> results = new List<Polyline>();
458
+
459
+            if (geometry is LineString lineString)
460
+            {
461
+                Polyline pl = CreatePolylineFromCoordinates(lineString.Coordinates);
462
+                if (pl != null)
463
+                    results.Add(pl);
464
+            }
465
+            else if (geometry is MultiLineString multiLineString)
466
+            {
467
+                for (int i = 0; i < multiLineString.NumGeometries; i++)
468
+                {
469
+                    LineString ls = multiLineString.GetGeometryN(i) as LineString;
470
+                    if (ls != null)
471
+                    {
472
+                        Polyline pl = CreatePolylineFromCoordinates(ls.Coordinates);
473
+                        if (pl != null)
474
+                            results.Add(pl);
475
+                    }
476
+                }
477
+            }
478
+
479
+            return results;
480
+        }
481
+
482
+        /// <summary>
483
+        /// 从坐标数组创建 AutoCAD Polyline
484
+        /// </summary>
485
+        private Polyline CreatePolylineFromCoordinates(Coordinate[] coordinates)
486
+        {
487
+            if (coordinates == null || coordinates.Length < 2)
488
+                return null;
489
+
490
+            Polyline polyline = new Polyline();
491
+
492
+            for (int i = 0; i < coordinates.Length; i++)
493
+            {
494
+                Coordinate coord = coordinates[i];
495
+                polyline.AddVertexAt(i, new Point2d(coord.X, coord.Y), 0, 0, 0);
496
+            }
497
+            return polyline;
498
+        }
499
+
500
+        private void ZoomView(Editor edit, Point3d pt1, Point3d pt2)
501
+        {
502
+            var x_min = Math.Min(pt1.X, pt2.X);
503
+            var y_min = Math.Min(pt1.Y, pt2.Y);
504
+            ViewTableRecord currview1 = edit.GetCurrentView();
505
+            currview1.CenterPoint = new Point2d(Math.Abs((pt2.X - pt1.X) / 2) + x_min,
506
+                                                Math.Abs((pt2.Y - pt1.Y) / 2) + y_min);
507
+            currview1.Width = Math.Abs(pt2.X - pt1.X + 1);
508
+            currview1.Height = Math.Abs(pt2.Y - pt1.Y + 1);
509
+            edit.SetCurrentView(currview1);
510
+        }
511
+    }
512
+}

+ 639
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/Dgxinters.cs 查看文件

@@ -0,0 +1,639 @@
1
+using Autodesk.AutoCAD.ApplicationServices;
2
+using Autodesk.AutoCAD.DatabaseServices;
3
+using Autodesk.AutoCAD.EditorInput;
4
+using Autodesk.AutoCAD.Geometry;
5
+using System;
6
+using System.Collections.Generic;
7
+using System.Linq;
8
+using System.Text;
9
+using System.Threading.Tasks;
10
+
11
+namespace CADTools
12
+{
13
+    class Dgxinters
14
+    {
15
+        public struct SQX
16
+        {
17
+            public Polyline pll;
18
+            public List<Point3d> intersepts;
19
+        }
20
+
21
+        public void Interdgx()
22
+        {
23
+            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
24
+            //输入等高距
25
+            PromptDoubleOptions opts = new PromptDoubleOptions("\n请输入等高距: ");
26
+            opts.AllowNegative = false;  // 不允许负数
27
+            opts.AllowZero = false;     // 不允许0
28
+            opts.DefaultValue = Properties.Settings.Default.dgj;     // 默认值
29
+            PromptDoubleResult res = ed.GetDouble(opts);
30
+            if (res.Status != PromptStatus.OK)
31
+            {
32
+                ed.WriteMessage("\n操作取消。");
33
+                return;
34
+            }
35
+            double dgj = res.Value;
36
+            Properties.Settings.Default.dgj = dgj;
37
+
38
+            Line jigl1 = Fzx();
39
+            Line jigl2 = Fzx();
40
+            List<Point3d> ptonline = new List<Point3d>();//两辅助拉线之间的线段上的点
41
+
42
+            Point3dCollection ptcoll = new Point3dCollection();
43
+            var plane = new Plane(Point3d.Origin, Vector3d.ZAxis);
44
+            ptcoll.Add(jigl1.StartPoint);
45
+            ptcoll.Add(jigl1.EndPoint);
46
+            TypedValue[] value = new TypedValue[]
47
+                {
48
+                new TypedValue((int)DxfCode.Start,"LWPOLYLINE"),
49
+                };//设置筛选条件
50
+            SelectionFilter filter = new SelectionFilter(value);
51
+            // 要求在图形区域中手动选择对象
52
+            PromptSelectionResult psr = ed.SelectFence(ptcoll, filter);
53
+            if (psr.Status == PromptStatus.OK)
54
+            {
55
+                SelectionSet ss = psr.Value;
56
+                ObjectIdCollection idcoll = new ObjectIdCollection(ss.GetObjectIds());
57
+                List<Polyline> dgx = new List<Polyline>();
58
+                List<Polyline> dgx_sqxs = new List<Polyline>();
59
+                for (int i = 0; i < idcoll.Count; i++)
60
+                {
61
+                    Database db = HostApplicationServices.WorkingDatabase;
62
+                    Entity ent = null;
63
+                    DocumentLock doclock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
64
+                    using (Transaction tr = db.TransactionManager.StartTransaction())
65
+                    {
66
+                        ent = (Polyline)tr.GetObject(idcoll[i], OpenMode.ForWrite, true);
67
+                        doclock.Dispose();
68
+                        Polyline temp = (Polyline)BasicFunction.GetDBObject(idcoll[i]);
69
+                        if (temp.Layer == "8120" || temp.Layer == "jqx" || temp.Layer == "JQX")
70
+                            dgx.Add(temp);
71
+                        else
72
+                        {
73
+                            dgx_sqxs.Add(temp);
74
+                            temp.Erase();
75
+                        }
76
+                        tr.Commit();
77
+                    }
78
+                }
79
+                //按高程排序
80
+                var dgx_ct = dgx.OrderBy(x => x.Elevation).ToList();
81
+                var dgx_sqx = dgx_sqxs.OrderBy(x => x.Elevation).ToList();
82
+                //记录首曲线以及首曲线与拉线交点
83
+                List<SQX> sqxlist = new List<SQX>();
84
+                for (int i = 0; i < dgx_sqx.Count; i++)
85
+                {
86
+                    List<Point3d> itsresult1 = new List<Point3d>();
87
+                    List<Point3d> itsresult2 = new List<Point3d>();
88
+                    itsresult1 = GetIntersections(dgx_sqx[i], jigl1);
89
+                    itsresult2 = GetIntersections(dgx_sqx[i], jigl2);
90
+                    Point3d start = new Point3d();
91
+                    Point3d end = new Point3d();
92
+                    SQX temp = new SQX();
93
+                    temp.intersepts = new List<Point3d>();
94
+                    if (itsresult1.Count != 0)
95
+                    {
96
+                        start = new Point3d(itsresult1[0].X, itsresult1[0].Y, dgx_sqx[i].Elevation);
97
+                        temp.intersepts.Add(start);
98
+                    }
99
+                    if (itsresult2.Count != 0)
100
+                    {
101
+                        end = new Point3d(itsresult2[0].X, itsresult2[0].Y, dgx_sqx[i].Elevation);
102
+                        temp.intersepts.Add(end);
103
+                    }
104
+                    temp.pll = dgx_sqx[i];
105
+                    sqxlist.Add(temp);
106
+                }
107
+                //获取计曲线与拉线交点
108
+                for (int i = 0; i < dgx_ct.Count - 1; i++)
109
+                {
110
+                    List<Point3d> itsresult1 = new List<Point3d>();
111
+                    List<Point3d> itsresult2 = new List<Point3d>();
112
+                    itsresult1 = GetIntersections(dgx_ct[i], jigl1);
113
+                    itsresult2 = GetIntersections(dgx_ct[i], jigl2);
114
+                    Point3d start = new Point3d(itsresult1[0].X, itsresult1[0].Y, dgx_ct[i].Elevation);
115
+                    Point3d end = new Point3d(itsresult2[0].X, itsresult2[0].Y, dgx_ct[i].Elevation);
116
+                    //List<Point3d> pts1 = GetPtsBetweenpts(dgx_ct[i], start, end);
117
+                    Polyline pl1 = GetPlBetweenpts(dgx_ct[i], start, end);
118
+
119
+                    List<Point3d> itsresult3 = new List<Point3d>();
120
+                    List<Point3d> itsresult4 = new List<Point3d>();
121
+                    itsresult3 = GetIntersections(dgx_ct[i + 1], jigl1);
122
+                    itsresult4 = GetIntersections(dgx_ct[i + 1], jigl2);
123
+                    Point3d start1 = new Point3d(itsresult3[0].X, itsresult3[0].Y, dgx_ct[i + 1].Elevation);
124
+                    Point3d end1 = new Point3d(itsresult4[0].X, itsresult4[0].Y, dgx_ct[i + 1].Elevation);
125
+                    List<Point3d> linearinterpt = new List<Point3d>();
126
+                    Polyline pl2 = GetPlBetweenpts(dgx_ct[i + 1], start1, end1);
127
+
128
+                    double gcc = dgx_ct[i + 1].Elevation - dgx_ct[i].Elevation;
129
+                    int count = (int)(gcc / dgj - 1);
130
+                    Document doc = Application.DocumentManager.MdiActiveDocument;
131
+                    Database db = doc.Database;
132
+                    using (Transaction tr = db.TransactionManager.StartTransaction())
133
+                    {
134
+                        // 执行内插
135
+                        List<Polyline> newContours = InterpolateContours(pl1, pl2, count);
136
+
137
+                        // 将新等高线添加到图形
138
+                        BlockTableRecord btr = (BlockTableRecord)tr.GetObject(db.CurrentSpaceId, OpenMode.ForWrite);
139
+                        LayerTableRecord layer = (LayerTableRecord)tr.GetObject(db.Clayer, OpenMode.ForRead);
140
+                        if (dgx_sqxs.Count == 0)
141
+                        {
142
+                            foreach (Polyline contour in newContours)
143
+                            {
144
+                                btr.AppendEntity(contour);
145
+                                tr.AddNewlyCreatedDBObject(contour, true);
146
+                            }
147
+                        }
148
+                        else
149
+                        {
150
+                            foreach (Polyline contour in newContours)
151
+                            {
152
+                                Selesqx(contour, ed, btr, tr, sqxlist);
153
+                            }
154
+                        }
155
+                        tr.Commit();
156
+                        ed.WriteMessage($"\n成功创建 {newContours.Count} 条内插等高线。");
157
+                    }
158
+                }
159
+            }
160
+            else
161
+                ed.WriteMessage("\n未选中等高线!");
162
+        }
163
+
164
+        public static List<Polyline> InterpolateContours(Polyline lowerContour,Polyline upperContour,int numberOfInterpolations)
165
+        {
166
+            List<Polyline> interpolatedContours = new List<Polyline>();
167
+
168
+            // 检查曲线方向,必要时反转其中一条
169
+            if (!CheckContourDirections(lowerContour, upperContour))
170
+            {
171
+                upperContour = ReversePolyline(upperContour);
172
+            }
173
+
174
+            // 初始化起点
175
+            Point3d A = lowerContour.GetPoint3dAt(0);
176
+            Point3d B = upperContour.GetPoint3dAt(0);
177
+            Line l = new Line(A, B);
178
+
179
+            int i = 0, j = 0;
180
+            int m = lowerContour.NumberOfVertices - 1;
181
+            int n = upperContour.NumberOfVertices - 1;
182
+
183
+            // 存储所有插值点
184
+            List<Point3d>[] allInterpolatedPoints = new List<Point3d>[numberOfInterpolations];
185
+            for (int k = 0; k < numberOfInterpolations; k++)
186
+            {
187
+                allInterpolatedPoints[k] = new List<Point3d>();
188
+            }
189
+
190
+            while (i < m && j < n)
191
+            {
192
+                //在当前AB辅助线上插值
193
+                for (int L = 1; L <= numberOfInterpolations; L++)
194
+                {
195
+                    double ratio = (double)L / (numberOfInterpolations + 1);
196
+                    Point3d interpolatedPoint = InterpolatePoint(A, B, ratio);
197
+                    if (!allInterpolatedPoints[L - 1].Contains(interpolatedPoint))
198
+                        allInterpolatedPoints[L - 1].Add(interpolatedPoint);
199
+                }
200
+
201
+                //寻找最大角点
202
+                int k1 = FindMaxAnglePoint(lowerContour, i, A, B);
203
+                int k2 = FindMaxAnglePoint(upperContour, j, A, B);
204
+
205
+                //比较角度并选择辅助线
206
+                double angle1 = CalculateAngle(lowerContour.GetPoint3dAt(k1), A, B);
207
+                double angle2 = CalculateAngle(upperContour.GetPoint3dAt(k2), A, B);
208
+
209
+                if (angle1 > angle2)
210
+                {
211
+                    // 选择lowerContour上的点
212
+                    //if (CheckNoIntersection(lowerContour, i, k1, B))
213
+                    for (int x = i + 1; x <= k1; x++)
214
+                    {
215
+                        //for (int x = i + 1; x <= k1; x++)
216
+                        if (CheckNoIntersection(lowerContour, x, k1, B))
217
+                        {
218
+                            Point3d P = lowerContour.GetPoint3dAt(x);
219
+                            for (int L = 1; L <= numberOfInterpolations; L++)
220
+                            {
221
+                                double ratio = (double)L / (numberOfInterpolations + 1);
222
+                                Point3d interpolatedPoint = InterpolatePoint(P, B, ratio);
223
+                                if (!allInterpolatedPoints[L - 1].Contains(interpolatedPoint))
224
+                                    allInterpolatedPoints[L - 1].Add(interpolatedPoint);
225
+                            }
226
+                        }
227
+                        //i = k1;
228
+                        //A = lowerContour.GetPoint3dAt(i);
229
+                    }
230
+                    i = k1;
231
+                    A = lowerContour.GetPoint3dAt(i);
232
+                }
233
+                else
234
+                {
235
+                    // 选择upperContour上的点
236
+                    //if (CheckNoIntersection(upperContour, j, k2, A))
237
+                    for (int y = j + 2; y <= k2; y++)
238
+                    {
239
+                        //for (int y = j + 1; y <= k2; y++)
240
+                        if (CheckNoIntersection(upperContour, y, k2, A))
241
+                        {
242
+                            Point3d Q = upperContour.GetPoint3dAt(y);
243
+                            for (int L = 1; L <= numberOfInterpolations; L++)
244
+                            {
245
+                                double ratio = (double)L / (numberOfInterpolations + 1);
246
+                                Point3d interpolatedPoint = InterpolatePoint(A, Q, ratio);
247
+                                if (!allInterpolatedPoints[L - 1].Contains(interpolatedPoint))
248
+                                    allInterpolatedPoints[L - 1].Add(interpolatedPoint);
249
+                                Document doc = Application.DocumentManager.MdiActiveDocument;
250
+                                Database db = doc.Database;
251
+                            }
252
+                        }
253
+                        //j = k2;
254
+                        //B = upperContour.GetPoint3dAt(j);
255
+                    }
256
+                    j = k2;
257
+                    B = upperContour.GetPoint3dAt(j);
258
+                }
259
+            }
260
+
261
+            // 处理剩余点
262
+            while (i < m)
263
+            {
264
+                i++;
265
+                Point3d P = lowerContour.GetPoint3dAt(i);
266
+                for (int L = 1; L <= numberOfInterpolations; L++)
267
+                {
268
+                    double ratio = (double)L / (numberOfInterpolations + 1);
269
+                    Point3d interpolatedPoint = InterpolatePoint(P, B, ratio);
270
+                    if (!allInterpolatedPoints[L - 1].Contains(interpolatedPoint))
271
+                        allInterpolatedPoints[L - 1].Add(interpolatedPoint);
272
+                }
273
+            }
274
+
275
+            while (j < n)
276
+            {
277
+                j++;
278
+                Point3d Q = upperContour.GetPoint3dAt(j);
279
+                for (int L = 1; L <= numberOfInterpolations; L++)
280
+                {
281
+                    double ratio = (double)L / (numberOfInterpolations + 1);
282
+                    Point3d interpolatedPoint = InterpolatePoint(A, Q, ratio);
283
+                    if (!allInterpolatedPoints[L - 1].Contains(interpolatedPoint))
284
+                        allInterpolatedPoints[L - 1].Add(interpolatedPoint);
285
+                }
286
+            }
287
+
288
+            // 创建插值后的等高线
289
+            for (int L = 0; L < numberOfInterpolations; L++)
290
+            {
291
+                Polyline newContour = new Polyline();
292
+                for (int idx = 0; idx < allInterpolatedPoints[L].Count; idx++)
293
+                {
294
+                    Point3d pt = allInterpolatedPoints[L][idx];
295
+                    newContour.AddVertexAt(idx, new Point2d(pt.X, pt.Y), 0, 0, 0);
296
+                }
297
+
298
+                // 设置高程
299
+                double elevation = lowerContour.Elevation +
300
+                                 (upperContour.Elevation - lowerContour.Elevation) *
301
+                                 (double)(L + 1) / (numberOfInterpolations + 1);
302
+                newContour.Elevation = elevation;
303
+                Polyline smoothpl = Smooth(newContour);
304
+                interpolatedContours.Add(smoothpl);
305
+            }
306
+
307
+            return interpolatedContours;
308
+        }
309
+
310
+        // 检查两条等高线方向是否一致
311
+        private static bool CheckContourDirections(Polyline pline1, Polyline pline2)
312
+        {
313
+            bool result;
314
+            Point3d pl1st = pline1.StartPoint;
315
+            Point3d pl2st = pline2.StartPoint;
316
+            Point3d pl2ed = pline2.EndPoint;
317
+            Line l1 = new Line(pl1st, pl2st);
318
+            Line l2 = new Line(pl1st, pl2ed);
319
+            if (l1.Length < l2.Length)
320
+                result = true;
321
+            else
322
+                result = false;
323
+            return result;
324
+
325
+        }
326
+
327
+        // 反转多段线顶点顺序
328
+        private static Polyline ReversePolyline(Polyline pline)
329
+        {
330
+            Polyline reversed = new Polyline();
331
+            for (int i = pline.NumberOfVertices - 1; i >= 0; i--)
332
+            {
333
+                Point3d pt = pline.GetPoint3dAt(i);
334
+                reversed.AddVertexAt(reversed.NumberOfVertices,
335
+                                   new Point2d(pt.X, pt.Y), 0, 0, 0);
336
+            }
337
+            reversed.Elevation = pline.Elevation;
338
+            return reversed;
339
+        }
340
+
341
+        // 在两点之间插值
342
+        private static Point3d InterpolatePoint(Point3d pt1, Point3d pt2, double ratio)
343
+        {
344
+            return new Point3d(
345
+                pt1.X + ratio * (pt2.X - pt1.X),
346
+                pt1.Y + ratio * (pt2.Y - pt1.Y),
347
+                pt1.Z + ratio * (pt2.Z - pt1.Z));
348
+        }
349
+
350
+        // 寻找最大角点
351
+        private static int FindMaxAnglePoint(Polyline pline, int startIdx, Point3d A, Point3d B)
352
+        {
353
+            int maxIndex = startIdx;
354
+            double maxAngle = 0;
355
+
356
+            for (int i = startIdx + 1; i < pline.NumberOfVertices; i++)
357
+            {
358
+                Point3d P = pline.GetPoint3dAt(i);
359
+                double angle = CalculateAngle(P, A, B);
360
+
361
+                if (angle > maxAngle)
362
+                {
363
+                    maxAngle = angle;
364
+                    maxIndex = i;
365
+                }
366
+            }
367
+
368
+            return maxIndex;
369
+        }
370
+
371
+        // 计算角度(使用余弦定理)
372
+        private static double CalculateAngle(Point3d P, Point3d A, Point3d B)
373
+        {
374
+            Vector3d PA = A - P;
375
+            Vector3d PB = B - P;
376
+
377
+            double dotProduct = PA.DotProduct(PB);
378
+            double magnitudePA = PA.Length;
379
+            double magnitudePB = PB.Length;
380
+
381
+            // 避免除以零
382
+            if (magnitudePA < 1e-9 || magnitudePB < 1e-9)
383
+                return 0;
384
+
385
+            double cosTheta = dotProduct / (magnitudePA * magnitudePB);
386
+            cosTheta = Math.Max(-1, Math.Min(1, cosTheta)); // 确保在[-1,1]范围内
387
+
388
+            return Math.Acos(cosTheta);
389
+        }
390
+
391
+        // 检查辅助线是否与曲线相交
392
+        private static bool CheckNoIntersection(Polyline pline, int startIdx, int endIdx, Point3d point)
393
+        {
394
+            //LineSegment3d testSegment = new LineSegment3d(
395
+            //    pline.GetPoint3dAt(startIdx), point);
396
+
397
+            //for (int i = 0; i < pline.NumberOfVertices - 1; i++)
398
+            //{
399
+            //    if (i == startIdx) continue;
400
+
401
+            //    LineSegment3d plineSegment = new LineSegment3d(
402
+            //        pline.GetPoint3dAt(i), pline.GetPoint3dAt(i + 1));
403
+
404
+            //    Point3d intersection = new Point3d();
405
+            //    if (testSegment.IntersectWith(plineSegment, out intersection))
406
+            //    {
407
+            //        return false;
408
+            //    }
409
+            //}
410
+            Line line = new Line(point, pline.GetPoint3dAt(startIdx));
411
+            List<Point3d> pts = GetIntersections(pline, line);
412
+            if (pts.Count > 1)
413
+                return false;
414
+
415
+            return true;
416
+        }
417
+
418
+        private static void Selesqx(Polyline pll, Editor ed, BlockTableRecord btr, Transaction tr, List<SQX> sqxlist)
419
+        {
420
+            for (int i = 0; i < sqxlist.Count; i++)
421
+            {
422
+                if(sqxlist[i].pll.Elevation==pll.Elevation)
423
+                {
424
+                    for (int j = 0; j < sqxlist[i].intersepts.Count; j++)
425
+                    {
426
+                        Polyline pl_Clone = (Polyline)sqxlist[i].pll.Clone();
427
+                        Point3dCollection splitpts = new Point3dCollection(sqxlist[i].intersepts.OrderBy(x=>sqxlist[i].pll.GetParameterAtPoint(x)).ToArray());
428
+                        var splitpl = pl_Clone.GetSplitCurves(splitpts);
429
+                        if (splitpl.Count == 2)
430
+                        {
431
+                            Polyline pllsplit1 = (Polyline)splitpl[0];
432
+                            Polyline pllsplit2 = (Polyline)splitpl[1];
433
+                            Polyline plladd;
434
+                            if (pllsplit1.Length < pllsplit2.Length)
435
+                                plladd = pllsplit2;
436
+                            else
437
+                                plladd = pllsplit1;
438
+                            Polyline pll_new = new Polyline();
439
+                            if (plladd.EndPoint != sqxlist[i].intersepts[0])
440
+                                plladd.ReverseCurve();
441
+                            Line line3 = new Line(plladd.EndPoint, pll.StartPoint);
442
+                            Line line4 = new Line(plladd.EndPoint, pll.EndPoint);
443
+                            if (line3.Length > line4.Length)
444
+                                pll.ReverseCurve();
445
+                            int ptnum = pll.NumberOfVertices + plladd.NumberOfVertices - 1;
446
+                            for (int l = 0; l < ptnum - 1; l++)
447
+                            {
448
+                                if (l < plladd.NumberOfVertices - 1)
449
+                                    pll_new.AddVertexAt(l, plladd.GetPoint2dAt(l), 0, sqxlist[i].pll.ConstantWidth, sqxlist[i].pll.ConstantWidth);
450
+                                else
451
+                                    pll_new.AddVertexAt(l, pll.GetPoint2dAt(l - plladd.NumberOfVertices + 2), 0, sqxlist[i].pll.ConstantWidth, sqxlist[i].pll.ConstantWidth);
452
+                            }
453
+                            pll_new.Elevation = pl_Clone.Elevation;
454
+                            Polyline smoothpl = Smooth(pll_new);
455
+                            btr.AppendEntity(smoothpl);
456
+                            tr.AddNewlyCreatedDBObject(smoothpl, true);
457
+
458
+                        }
459
+                        else if (splitpl.Count > 2)
460
+                        {
461
+                            Polyline pll_split1 = (Polyline)splitpl[0];
462
+                            Polyline pll_split2 = (Polyline)splitpl[1];
463
+                            Polyline pll_split3 = (Polyline)splitpl[2];
464
+                            Polyline pll_new = new Polyline();
465
+                            Line line1 = new Line(pll_split2.StartPoint,pll.StartPoint);
466
+                            Line line2 = new Line(pll_split2.StartPoint,pll.EndPoint);
467
+                            if (line1.Length > line2.Length)
468
+                                pll.ReverseCurve();
469
+                            int ptnum = pll.NumberOfVertices + pll_split1.NumberOfVertices + +pll_split3.NumberOfVertices - 4;
470
+                            for (int l = 0; l < ptnum; l++)
471
+                            {
472
+                                if (l < pll_split1.NumberOfVertices - 1)
473
+                                    pll_new.AddVertexAt(l, pll_split1.GetPoint2dAt(l), 0, sqxlist[i].pll.ConstantWidth, sqxlist[i].pll.ConstantWidth);
474
+                                else if(l<pll.NumberOfVertices + pll_split1.NumberOfVertices - 3&&l>= pll_split1.NumberOfVertices-1)
475
+                                    pll_new.AddVertexAt(l, pll.GetPoint2dAt(l - pll_split1.NumberOfVertices + 2), 0, sqxlist[i].pll.ConstantWidth, sqxlist[i].pll.ConstantWidth);
476
+                                else
477
+                                    pll_new.AddVertexAt(l, pll_split3.GetPoint2dAt(l - pll.NumberOfVertices - pll_split1.NumberOfVertices + 4), 0, sqxlist[i].pll.ConstantWidth, sqxlist[i].pll.ConstantWidth);
478
+                            }
479
+                            pll_new.Elevation = pl_Clone.Elevation;
480
+                            Polyline smoothpl = Smooth(pll_new);
481
+                            btr.AppendEntity(smoothpl);
482
+                            tr.AddNewlyCreatedDBObject(smoothpl, true);
483
+                        }
484
+                    }
485
+                }
486
+            }
487
+        }
488
+        
489
+        private static Polyline Smooth(Polyline pl)
490
+        {
491
+            Point3dCollection ptcoll = new Point3dCollection();
492
+            for (int i = 0; i < pl.NumberOfVertices; i++)
493
+            {
494
+                ptcoll.Add(pl.GetPoint3dAt(i));
495
+            }
496
+            Spline spline = new Spline(ptcoll, 3, 0.01);
497
+            spline.SetDatabaseDefaults();
498
+            Polyline pl_smooth = new Polyline();
499
+            pl_smooth.SetDatabaseDefaults();
500
+            int ptnum = pl.NumberOfVertices - 1;
501
+            for (int i = 0; i <= ptnum; i++)
502
+            {
503
+                double param = spline.StartParam +(spline.EndParam - spline.StartParam) * i / ptnum;
504
+                Point3d pt = spline.GetPointAtParameter(param);
505
+                pl_smooth.AddVertexAt(pl_smooth.NumberOfVertices, new Point2d(pt.X, pt.Y), 0, 0, 0);
506
+            }
507
+            pl_smooth.Elevation = pl.Elevation;
508
+            return pl_smooth;
509
+        }
510
+
511
+        //辅助线
512
+        private static Line Fzx()
513
+        {
514
+            Document doc = Application.DocumentManager.MdiActiveDocument;
515
+            Line jigl = new Line();
516
+
517
+            ObjectId jigid = new ObjectId();
518
+            PromptPointResult pPtRes;
519
+            PromptPointOptions pPtOpts = new PromptPointOptions("");
520
+            pPtOpts.Message = "选择起点\n ";
521
+            pPtRes = doc.Editor.GetPoint(pPtOpts);
522
+            Point3d ptStart = pPtRes.Value;
523
+
524
+            if (pPtRes.Status == PromptStatus.OK)
525
+            {
526
+                LineJig lJig = new LineJig(ptStart);
527
+                PromptResult PR = doc.Editor.Drag(lJig);
528
+                if (PR.Status == PromptStatus.OK)
529
+                {
530
+                    //jigid = BasicFunction.AddObj(doc, lJig.line_1);
531
+                    jigl = lJig.line_1;
532
+                }
533
+            }
534
+            return jigl;
535
+        }
536
+
537
+        private static Polyline GetPlBetweenpts(Polyline pll, Point3d start, Point3d end)
538
+        {
539
+            Polyline result = new Polyline();
540
+            Polyline copy_pll = (Polyline)pll.Clone();
541
+            Point3d start1 = pll.GetClosestPointTo(start,false);
542
+            double test = pll.GetParameterAtPoint(start);
543
+            Point3d end1 = pll.GetClosestPointTo(end, false);
544
+            double test2 = pll.GetParameterAtPoint(end);
545
+            if (test > test2)
546
+            {
547
+                Point3d temp = end1;
548
+                end1 = start1;
549
+                start1 = temp;
550
+            }
551
+            Point3dCollection pts = new Point3dCollection(new Point3d[] { start1, end1 });
552
+            var split = copy_pll.GetSplitCurves(pts);
553
+            //foreach (var item in split)
554
+            //{
555
+            result = (Polyline)split[1];
556
+            //if (pts.Contains(pll_temp.StartPoint) && pts.Contains(pll_temp.EndPoint))
557
+            //{
558
+            //    result = pll_temp;
559
+            //}
560
+            //}
561
+            return result;
562
+        }
563
+
564
+        /// <summary>
565
+        /// 为保证精度,将待获取相交情况的线移到原点处再进行相交检查
566
+        /// </summary>
567
+        private static List<Point3d> GetIntersections(Polyline pll, Line line)
568
+        {
569
+            List<Point3d> result = new List<Point3d>();
570
+
571
+            // 创建临时副本
572
+            Polyline tempLine1 = (Polyline)pll.Clone();
573
+            Line tempLine2 = (Line)line.Clone();
574
+
575
+            // 计算平移向量(以线1起点为基准,移动至原点)
576
+            Vector3d translation = -tempLine1.StartPoint.GetAsVector();
577
+            Matrix3d translateMatrix = Matrix3d.Displacement(translation);
578
+
579
+            // 应用平移变换
580
+            tempLine1.TransformBy(translateMatrix);
581
+            tempLine2.TransformBy(translateMatrix);
582
+
583
+            Point3dCollection translatedPoints = new Point3dCollection();
584
+            var plane = new Plane(Point3d.Origin, Vector3d.ZAxis);
585
+            tempLine2.IntersectWith(tempLine1, Intersect.OnBothOperands, plane, translatedPoints, IntPtr.Zero, IntPtr.Zero);
586
+
587
+            // 计算逆平移矩阵
588
+            Matrix3d inverseMatrix = Matrix3d.Displacement(-translation);
589
+            if (translatedPoints.Count > 0)
590
+            {
591
+                // 获取平移后的交点
592
+                foreach (Point3d item in translatedPoints)
593
+                {
594
+                    // 恢复交点坐标
595
+                    var pt = item.TransformBy(inverseMatrix);
596
+                    result.Add(pt);
597
+                }
598
+            }
599
+            return result;
600
+        }
601
+
602
+        private static List<Point3d> GetIntersections(Polyline pll1, Polyline pll2)
603
+        {
604
+            List<Point3d> result = new List<Point3d>();
605
+
606
+            // 创建临时副本
607
+            Polyline tempLine1 = (Polyline)pll1.Clone();
608
+            Polyline tempLine2 = (Polyline)pll2.Clone();
609
+
610
+            // 计算平移向量(以线1起点为基准,移动至原点)
611
+            Vector3d translation = -tempLine1.StartPoint.GetAsVector();
612
+            Matrix3d translateMatrix = Matrix3d.Displacement(translation);
613
+
614
+            // 应用平移变换
615
+            tempLine1.TransformBy(translateMatrix);
616
+            tempLine2.TransformBy(translateMatrix);
617
+
618
+            Point3dCollection translatedPoints = new Point3dCollection();
619
+            var plane = new Plane(Point3d.Origin, Vector3d.ZAxis);
620
+            tempLine1.IntersectWith(tempLine2, Intersect.OnBothOperands, plane, translatedPoints, IntPtr.Zero, IntPtr.Zero);
621
+
622
+            // 计算逆平移矩阵
623
+            Matrix3d inverseMatrix = Matrix3d.Displacement(-translation);
624
+            if (translatedPoints.Count > 0)
625
+            {
626
+                // 获取平移后的交点
627
+                foreach (Point3d item in translatedPoints)
628
+                {
629
+                    // 恢复交点坐标
630
+                    var pt = item.TransformBy(inverseMatrix);
631
+                    result.Add(pt);
632
+                }
633
+            }
634
+            return result;
635
+        }
636
+
637
+        
638
+    }
639
+}

+ 617
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/Dgxthrorvrd.cs 查看文件

@@ -0,0 +1,617 @@
1
+using Autodesk.AutoCAD.ApplicationServices;
2
+using Autodesk.AutoCAD.DatabaseServices;
3
+using Autodesk.AutoCAD.EditorInput;
4
+using Autodesk.AutoCAD.Geometry;
5
+using System;
6
+using System.Collections.Generic;
7
+using System.Linq;
8
+using System.Text;
9
+using System.Threading.Tasks;
10
+
11
+namespace CADTools
12
+{
13
+    class Dgxthrorvrd
14
+    {
15
+        public static List<string> dgxlist;
16
+        public static List<string> rvrdlist;
17
+        public static List<string> houselist;
18
+        public static int blc;
19
+
20
+
21
+        public void DgxCut()
22
+        {
23
+            string dgxname = "";
24
+            Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
25
+            Database db = Autodesk.AutoCAD.DatabaseServices.HostApplicationServices.WorkingDatabase;
26
+
27
+            for (int i = 0; i < dgxlist.Count; i++)
28
+            {
29
+                if (i == 0)
30
+                    dgxname = dgxlist[i];
31
+                else
32
+                    dgxname = dgxname + "," + dgxlist[i];
33
+            }
34
+            TypedValue[] value = new TypedValue[]
35
+            {
36
+                    new TypedValue((int)DxfCode.LayerName,dgxname)
37
+            };
38
+            SelectionFilter filter = new SelectionFilter(value);
39
+            //dynamic acadApp = Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication;
40
+            //acadApp.ZoomExtents();
41
+            PromptSelectionResult psr = ed.SelectAll(filter);
42
+            if (psr.Status == PromptStatus.OK)
43
+            {
44
+                SelectionSet ss = psr.Value;
45
+                ObjectIdCollection idcoll = new ObjectIdCollection(ss.GetObjectIds());
46
+                for (int ii = 0; ii < idcoll.Count; ii++)
47
+                {
48
+                    Polyline pll = new Polyline();
49
+                    DocumentLock doclock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
50
+                    using (Transaction trans = db.TransactionManager.StartTransaction())
51
+                    {
52
+                        Entity ent = trans.GetObject(idcoll[ii], OpenMode.ForWrite) as Entity;
53
+                        if (ent is Polyline)
54
+                            pll = (Polyline)ent;
55
+                        trans.Commit();
56
+                    }
57
+                    doclock.Dispose();
58
+                    if (pll.Database != null)
59
+                        Intersectcheck(pll, ed);
60
+                }
61
+            }
62
+            dgxlist.Clear();
63
+            if (rvrdlist != null)
64
+                rvrdlist.Clear();
65
+            if (houselist != null)
66
+                houselist.Clear();
67
+        }
68
+
69
+        private void Intersectcheck(Polyline pll, Editor ed)
70
+        {
71
+            var plane = new Plane(Point3d.Origin, Vector3d.ZAxis);
72
+            List<Point3d> pts = new List<Point3d>();
73
+            List<Point3d> pts1 = new List<Point3d>();
74
+            Point3dCollection kz_pts = new Point3dCollection();
75
+            string rvrdname = "";
76
+            string kzname = "";
77
+            //为坎子让出的长度
78
+            double cut_dist = 0.5;
79
+            if (blc == 1000)
80
+                cut_dist = cut_dist * 2;
81
+            if (blc == 2000)
82
+                cut_dist = cut_dist * 4;
83
+            if (blc == 5000)
84
+                cut_dist = cut_dist * 10;
85
+            if (blc == 10000)
86
+                cut_dist = cut_dist * 20;
87
+
88
+            Database db = Autodesk.AutoCAD.DatabaseServices.HostApplicationServices.WorkingDatabase;
89
+            //using (Transaction trans = db.TransactionManager.StartTransaction())
90
+            //{
91
+            //Entity ent = trans.GetObject(id, OpenMode.ForWrite) as Entity;
92
+            //Polyline pll = new Polyline();
93
+            //if (ent is Polyline)
94
+            //    pll = (Polyline)ent;
95
+            //else
96
+            //    return;
97
+            //添加道路河流的图层名并搜索相应图层上的实体
98
+            if (rvrdlist != null)
99
+            {
100
+                //if (kzlist != null)
101
+                //{
102
+                //    rvrdlist.AddRange(kzlist);
103
+                //}
104
+                //Point3dCollection ptcoll = new Point3dCollection();
105
+                //for (int i = 0; i < pll.NumberOfVertices; i++)
106
+                //{
107
+                //    ptcoll.Add(pll.GetPoint3dAt(i));
108
+                //}
109
+
110
+                rvrdname = string.Join(",", rvrdlist.Distinct());
111
+
112
+                TypedValue[] value = new TypedValue[]
113
+                {
114
+                        new TypedValue((int)DxfCode.LayerName,rvrdname)
115
+                };
116
+                SelectionFilter filter = new SelectionFilter(value);
117
+                ZoomView(ed, pll.Bounds.Value.MinPoint, pll.Bounds.Value.MaxPoint);
118
+                //PromptSelectionResult psr = ed.SelectFence(ptcoll, filter);
119
+                PromptSelectionResult psr = ed.SelectCrossingWindow(pll.Bounds.Value.MinPoint, pll.Bounds.Value.MaxPoint, filter);
120
+                if (psr.Status == PromptStatus.OK)
121
+                {
122
+                    SelectionSet ss = psr.Value;
123
+                    ObjectIdCollection idcoll = new ObjectIdCollection(ss.GetObjectIds());
124
+                    for (int i = 0; i < idcoll.Count; i++)
125
+                    {
126
+                        Polyline pll_rvrd = new Polyline();
127
+                        DocumentLock doclock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
128
+                        using (Transaction trans = db.TransactionManager.StartTransaction())
129
+                        {
130
+                            Entity ent1 = trans.GetObject(idcoll[i], OpenMode.ForWrite) as Entity;
131
+                            if (ent1 is Polyline)
132
+                                pll_rvrd = (Polyline)ent1;
133
+                            trans.Commit();
134
+                        }
135
+                        doclock.Dispose();
136
+                        if (pll_rvrd.Database != null)
137
+                        {
138
+                            List<Point3d> intersectionPoints = GetIntersections(pll, pll_rvrd);
139
+                            //Point3dCollection intersectionPoints = new Point3dCollection();
140
+                            //pll.IntersectWith(pll_rvrd, Intersect.OnBothOperands, plane, intersectionPoints, IntPtr.Zero, IntPtr.Zero);
141
+
142
+                            if (intersectionPoints.Count > 0)
143
+                            {
144
+                                try
145
+                                {
146
+                                    foreach (Point3d pt in intersectionPoints)
147
+                                    {
148
+                                        double param = pll.GetParameterAtPoint(pt);
149
+                                        double dist = pll.GetDistanceAtParameter(param);
150
+
151
+                                        // 检查是否与已有点的距离小于0.01
152
+                                        if (!pts.Any(p => Math.Abs(pll.GetDistAtPoint(p) - dist) < 0.01))
153
+                                        {
154
+                                            pts.Add(pt);
155
+                                        }
156
+                                    }
157
+                                }
158
+                                catch
159
+                                {
160
+                                    continue;
161
+                                }
162
+                            }
163
+                        }
164
+                    }
165
+                }
166
+                //SelectionFilter filter = new SelectionFilter(value);
167
+                //PromptSelectionResult psr = ed.SelectAll(filter);
168
+                //if (psr.Status == PromptStatus.OK)
169
+                //{
170
+                //    //创建新图层
171
+                //    //LayerControl layerscontrol = new LayerControl();
172
+                //    //string layname = "待删除等高线";
173
+                //    //if (!layerscontrol.haslayername(layname))
174
+                //    //{
175
+                //    //    colorgb col = new colorgb(255, 0, 255);
176
+                //    //    layerscontrol.creatlayer(layname, col);
177
+                //    //    layerscontrol.movelayertofront(layname);
178
+                //    //}
179
+                //    //else
180
+                //    //    layerscontrol.movelayertofront(layname);
181
+
182
+                //    SelectionSet ss = psr.Value;
183
+                //    ObjectIdCollection idcoll = new ObjectIdCollection(ss.GetObjectIds());
184
+                //    for (int i = 0; i < idcoll.Count; i++)
185
+                //    {
186
+                //        Entity ent1 = trans.GetObject(idcoll[i], OpenMode.ForWrite) as Entity;
187
+                //        Polyline pll_rvrd = new Polyline();
188
+                //        if (ent is Polyline)
189
+                //            pll_rvrd = (Polyline)ent;
190
+                //        else
191
+                //            continue;
192
+                //        Point3dCollection intersectionPoints = new Point3dCollection();
193
+                //        pll.IntersectWith(pll_rvrd, Intersect.OnBothOperands, plane, intersectionPoints, IntPtr.Zero, IntPtr.Zero);
194
+                //        if (intersectionPoints.Count > 0)
195
+                //        {
196
+                //            foreach (Point3d pt in intersectionPoints)
197
+                //            {
198
+                //                pts.Add(pt);
199
+                //            }
200
+                //        }
201
+                //    }
202
+                //}
203
+            }
204
+
205
+
206
+
207
+            //添加坎子图层名并搜索相应图层上的实体
208
+            //if (kzlist != null)
209
+            //{
210
+            //    for (int i = 0; i < kzlist.Count; i++)
211
+            //    {
212
+            //        if (i == 0)
213
+            //            kzname = kzlist[i];
214
+            //        else
215
+            //            kzname = kzname + "," + kzlist[i];
216
+            //    }
217
+            //    TypedValue[] value_kz = new TypedValue[]
218
+            //    {
219
+            //        new TypedValue((int)DxfCode.LayerName,kzname)
220
+            //    };
221
+            //    SelectionFilter filter_kz = new SelectionFilter(value_kz);
222
+            //    PromptSelectionResult psr_kz = ed.SelectAll(filter_kz);
223
+            //    if (psr_kz.Status == PromptStatus.OK)
224
+            //    {
225
+            //        SelectionSet ss = psr_kz.Value;
226
+            //        ObjectIdCollection idcoll = new ObjectIdCollection(ss.GetObjectIds());
227
+            //        for (int i = 0; i < idcoll.Count; i++)
228
+            //        {
229
+            //            Polyline pll_rvrd = new Polyline();
230
+            //            DocumentLock doclock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
231
+            //            using (Transaction trans = db.TransactionManager.StartTransaction())
232
+            //            {
233
+            //                pll_rvrd = trans.GetObject(idcoll[i], OpenMode.ForWrite) as Polyline;
234
+            //                trans.Commit();
235
+            //            }
236
+            //            doclock.Dispose();
237
+            //            //Point3dCollection intersectionPoints = new Point3dCollection();
238
+            //            //pll.IntersectWith(pll_rvrd, Intersect.OnBothOperands, plane, intersectionPoints, IntPtr.Zero, IntPtr.Zero);
239
+            //            List<Point3d> intersectionPoints = GetIntersections(pll, pll_rvrd);
240
+            //            if (intersectionPoints.Count > 0)
241
+            //            {
242
+            //                try
243
+            //                {
244
+            //                    foreach (Point3d pt in intersectionPoints)
245
+            //                    {
246
+            //                        double param = pll.GetParameterAtPoint(pt);
247
+            //                        double dist = pll.GetDistanceAtParameter(param);
248
+
249
+            //                        // 检查是否与已有点的距离小于0.01
250
+            //                        if (!pts1.Any(p => Math.Abs(pll.GetDistAtPoint(p) - dist) < 0.01))
251
+            //                        {
252
+            //                            pts1.Add(pt);
253
+            //                        }
254
+            //                    }
255
+            //                }
256
+            //                catch
257
+            //                {
258
+            //                    continue;
259
+            //                }
260
+            //            }
261
+            //        }
262
+            //        #region
263
+            //        //if (pts.Count > 0)
264
+            //        //{
265
+            //        //    //按参数值排序交点
266
+            //        //    List<double> paramList = new List<double>();
267
+            //        //    foreach (Point3d breakPoint in pts)
268
+            //        //    {
269
+            //        //        double param = pll.GetParameterAtPoint(breakPoint);
270
+            //        //        paramList.Add(param);
271
+            //        //    }
272
+            //        //    paramList.Sort();
273
+
274
+            //        //    //存储分割后的多段线
275
+            //        //    List<Polyline> newPlls = new List<Polyline>();
276
+
277
+            //        //    // 初始化第一条多段线
278
+            //        //    Polyline currentPline = new Polyline();
279
+            //        //    currentPline.SetDatabaseDefaults();
280
+            //        //    currentPline.Layer = pll.Layer;
281
+            //        //    currentPline.Color = pll.Color;
282
+
283
+            //        //    // 遍历多段线的节点
284
+            //        //    for (int i = 0; i < pll.NumberOfVertices; i++)
285
+            //        //    {
286
+            //        //        Point2d point = pll.GetPoint2dAt(i);
287
+            //        //        double bulge = pll.GetBulgeAt(i);
288
+
289
+            //        //        // 添加节点到当前多段线
290
+            //        //        currentPline.AddVertexAt(currentPline.NumberOfVertices, point, bulge, 0, 0);
291
+
292
+            //        //        // 检查是否需要分割
293
+            //        //        if (paramList.Count > 0 && i == (int)paramList[0])
294
+            //        //        {
295
+            //        //            // 检查当前节点和下一个节点之间是否有交点
296
+            //        //            while (paramList.Count > 0 && paramList[0] >= i && paramList[0] < i + 1)
297
+            //        //            {
298
+            //        //                // 计算交点处的精确位置
299
+            //        //                double param = paramList[0];
300
+            //        //                double dist = pll.GetDistanceAtParameter(param)- cut_dist;
301
+            //        //                Point3d splitPoint3d = pll.GetPointAtDist(dist);
302
+            //        //                Point2d splitPoint = new Point2d(splitPoint3d.X, splitPoint3d.Y);
303
+            //        //                kz_pts.Add(splitPoint3d);
304
+
305
+            //        //                // 添加当前多段线到结果列表
306
+            //        //                currentPline.AddVertexAt(currentPline.NumberOfVertices, splitPoint, 0, 0, 0);
307
+            //        //                BlockTable bt = (BlockTable)(trans.GetObject(db.BlockTableId, OpenMode.ForRead));
308
+            //        //                BlockTableRecord btr = (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
309
+            //        //                btr.AppendEntity(currentPline);
310
+            //        //                trans.AddNewlyCreatedDBObject(currentPline, true);
311
+            //        //                newPlls.Add(currentPline);
312
+
313
+            //        //                // 初始化下一条多段线
314
+            //        //                currentPline = new Polyline();
315
+            //        //                currentPline.SetDatabaseDefaults();
316
+            //        //                currentPline.Layer = pll.Layer;
317
+            //        //                currentPline.Color = pll.Color;
318
+
319
+            //        //                // 添加分割点作为下一条多段线的起点
320
+            //        //                double dist1 = pll.GetDistanceAtParameter(param) + cut_dist;
321
+            //        //                Point3d splitPoint3d1 = pll.GetPointAtDist(dist1);
322
+            //        //                Point2d splitPoint1 = new Point2d(splitPoint3d1.X, splitPoint3d1.Y);
323
+            //        //                kz_pts.Add(splitPoint3d1);
324
+            //        //                currentPline.AddVertexAt(0, splitPoint1, 0, 0, 0);
325
+
326
+            //        //                // 移除已处理的交点
327
+            //        //                paramList.RemoveAt(0);
328
+            //        //            }
329
+            //        //        }
330
+            //        //    }
331
+
332
+            //        //    if (currentPline.NumberOfVertices > 0)
333
+            //        //    {
334
+            //        //        BlockTable bt = (BlockTable)(trans.GetObject(db.BlockTableId, OpenMode.ForRead));
335
+            //        //        BlockTableRecord btr = (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
336
+            //        //        btr.AppendEntity(currentPline);
337
+            //        //        trans.AddNewlyCreatedDBObject(currentPline, true);
338
+            //        //        newPlls.Add(currentPline);
339
+            //        //    }
340
+            //        //    pll.Erase();
341
+
342
+
343
+            //        //    for (int i = 0; i < newPlls.Count; i++)
344
+            //        //    {
345
+            //        //        if (kz_pts.Contains(newPlls[i].StartPoint) &&
346
+            //        //            kz_pts.Contains(newPlls[i].EndPoint) &&
347
+            //        //            i % 2 == 1)
348
+            //        //            newPlls[i].Layer = "待删除等高线";
349
+            //        //        else if (newPlls.Count == 2)
350
+            //        //        {
351
+            //        //            if (newPlls[0].Length < newPlls[1].Length)
352
+            //        //                newPlls[0].Layer = "待删除等高线";
353
+            //        //            else
354
+            //        //                newPlls[1].Layer = "待删除等高线";
355
+            //        //        }
356
+            //        //    }
357
+            //        //}
358
+            //        #endregion
359
+            //    }
360
+            //}
361
+
362
+
363
+
364
+            if (pts.Count > 0)
365
+            {
366
+                //创建新图层
367
+                LayerControl layerscontrol = new LayerControl();
368
+                string layname = "待删除等高线";
369
+                if (!layerscontrol.haslayername(layname))
370
+                {
371
+                    colorgb col = new colorgb(255, 0, 255);
372
+                    layerscontrol.creatlayer(layname, col);
373
+                    layerscontrol.movelayertofront(layname);
374
+                }
375
+                else
376
+                    layerscontrol.movelayertofront(layname);
377
+                var ptssorted = pts.OrderBy(p => pll.GetDistAtPoint(p)).ToList();
378
+                Point3dCollection ptcoll = new Point3dCollection();
379
+                foreach (var item in ptssorted)
380
+                {
381
+                    ptcoll.Add(item);
382
+                }
383
+                var splitlines = pll.GetSplitCurves(ptcoll);
384
+                List<Polyline> split_pls = new List<Polyline>();
385
+                for (int i = 0; i < splitlines.Count; i++)
386
+                {
387
+                    split_pls.Add((Polyline)splitlines[i]);
388
+                }
389
+                var split_plssorted = split_pls.OrderBy(p => pll.GetDistAtPoint(p.StartPoint)).ToList();
390
+                for (int i = 0; i < split_plssorted.Count; i++)
391
+                {
392
+                    if (i % 2 != 0 && i != 0)
393
+                    {
394
+                        DocumentLock doclock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
395
+                        using (Transaction trans = db.TransactionManager.StartTransaction())
396
+                        {
397
+                            BlockTable bt = (BlockTable)(trans.GetObject(db.BlockTableId, OpenMode.ForRead));
398
+                            BlockTableRecord btr = (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
399
+                            btr.AppendEntity(split_plssorted[i]);
400
+                            trans.AddNewlyCreatedDBObject(split_plssorted[i], true);
401
+                            split_plssorted[i].Layer = "待删除等高线";
402
+                            trans.Commit();
403
+                        }
404
+                        doclock.Dispose();
405
+                    }
406
+                    else
407
+                    {
408
+                        DocumentLock doclock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
409
+                        using (Transaction trans = db.TransactionManager.StartTransaction())
410
+                        {
411
+                            BlockTable bt = (BlockTable)(trans.GetObject(db.BlockTableId, OpenMode.ForRead));
412
+                            BlockTableRecord btr = (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
413
+                            btr.AppendEntity(split_plssorted[i]);
414
+                            trans.AddNewlyCreatedDBObject(split_plssorted[i], true);
415
+                            split_plssorted[i].Layer = pll.Layer;
416
+                            trans.Commit();
417
+                        }
418
+                        doclock.Dispose();
419
+                    }
420
+
421
+
422
+                    //按参数值排序交点
423
+                    //List<double> paramList = new List<double>();
424
+                    //List<double> kzparam = new List<double>();
425
+                    //foreach (Point3d breakPoint in pts)
426
+                    //{
427
+                    //    double param = pll.GetParameterAtPoint(breakPoint);
428
+                    //    if (pts1.Contains(breakPoint))
429
+                    //        kzparam.Add(param);
430
+                    //    paramList.Add(param);
431
+                    //}
432
+                    //paramList.Sort();
433
+
434
+                    //存储分割后的多段线
435
+                    //List<Polyline> newPlls = new List<Polyline>();
436
+
437
+                    // 初始化第一条多段线
438
+                    //Polyline currentPline = new Polyline();
439
+                    //currentPline.SetDatabaseDefaults();
440
+                    //currentPline.Layer = pll.Layer;
441
+                    //currentPline.Color = pll.Color;
442
+
443
+                    // 遍历多段线的节点
444
+                    #region
445
+                    //for (int i = 0; i < pll.NumberOfVertices; i++)
446
+                    //{
447
+                    //    Point2d point = pll.GetPoint2dAt(i);
448
+                    //    double bulge = pll.GetBulgeAt(i);
449
+
450
+                    //    // 添加节点到当前多段线
451
+                    //    currentPline.AddVertexAt(currentPline.NumberOfVertices, point, bulge, 0, 0);
452
+
453
+                    //    // 检查是否需要分割
454
+                    //    if (paramList.Count > 0 && i == (int)paramList[0])
455
+                    //    {
456
+                    //        // 检查当前节点和下一个节点之间是否有交点
457
+                    //        while (paramList.Count > 0 && paramList[0] >= i && paramList[0] < i + 1)
458
+                    //        {
459
+                    //            // 计算交点处的精确位置
460
+                    //            double param = paramList[0];
461
+                    //            double dist;
462
+                    //            if (kzparam.Contains(param))
463
+                    //            {
464
+                    //                dist = pll.GetDistanceAtParameter(param) - cut_dist;
465
+                    //                kz_pts.Add(pll.GetPointAtDist(dist));
466
+                    //            }
467
+                    //            else
468
+                    //                dist = pll.GetDistanceAtParameter(param);
469
+                    //            Point3d splitPoint3d = pll.GetPointAtDist(dist);
470
+                    //            Point2d splitPoint = new Point2d(splitPoint3d.X, splitPoint3d.Y);
471
+
472
+                    //            // 添加当前多段线到结果列表
473
+                    //            currentPline.AddVertexAt(currentPline.NumberOfVertices, splitPoint, 0, 0, 0);
474
+                    //            DocumentLock doclock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
475
+                    //            using (Transaction trans = db.TransactionManager.StartTransaction())
476
+                    //            {
477
+                    //                BlockTable bt = (BlockTable)(trans.GetObject(db.BlockTableId, OpenMode.ForRead));
478
+                    //                BlockTableRecord btr = (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
479
+                    //                btr.AppendEntity(currentPline);
480
+                    //                trans.AddNewlyCreatedDBObject(currentPline, true);
481
+                    //                trans.Commit();
482
+                    //            }
483
+                    //            doclock.Dispose();
484
+                    //            newPlls.Add(currentPline);
485
+
486
+                    //            // 初始化下一条多段线
487
+                    //            currentPline = new Polyline();
488
+                    //            currentPline.SetDatabaseDefaults();
489
+                    //            currentPline.Layer = pll.Layer;
490
+                    //            currentPline.Color = pll.Color;
491
+
492
+                    //            // 添加分割点作为下一条多段线的起点
493
+                    //            if (kzparam.Contains(param))
494
+                    //            {
495
+                    //                double dist1 = pll.GetDistanceAtParameter(param) + cut_dist;
496
+                    //                Point3d splitPoint3d1 = pll.GetPointAtDist(dist1);
497
+                    //                Point2d splitPoint1 = new Point2d(splitPoint3d1.X, splitPoint3d1.Y);
498
+                    //                kz_pts.Add(splitPoint3d1);
499
+                    //                currentPline.AddVertexAt(0, splitPoint1, 0, 0, 0);
500
+                    //            }
501
+                    //            else
502
+                    //                currentPline.AddVertexAt(0, splitPoint, 0, 0, 0);
503
+
504
+                    //            // 移除已处理的交点
505
+                    //            paramList.RemoveAt(0);
506
+                    //        }
507
+                    //    }
508
+                    //}
509
+
510
+                    //if (currentPline.NumberOfVertices > 0)
511
+                    //{
512
+                    //    DocumentLock doclock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
513
+                    //    using (Transaction trans = db.TransactionManager.StartTransaction())
514
+                    //    {
515
+                    //        BlockTable bt = (BlockTable)(trans.GetObject(db.BlockTableId, OpenMode.ForRead));
516
+                    //        BlockTableRecord btr = (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
517
+                    //        btr.AppendEntity(currentPline);
518
+                    //        trans.AddNewlyCreatedDBObject(currentPline, true);
519
+                    //        trans.Commit();
520
+                    //    }
521
+                    //    doclock.Dispose();
522
+                    //    newPlls.Add(currentPline);
523
+                    //}
524
+                    //pll.Erase();
525
+                    #endregion
526
+
527
+                    //for (int i = 0; i < newPlls.Count; i++)
528
+                    //{
529
+                    //    if (newPlls.Count == 2)
530
+                    //    {
531
+                    //        if (newPlls[0].Length < newPlls[1].Length)
532
+                    //            newPlls[0].Layer = "待删除等高线";
533
+                    //        else
534
+                    //            newPlls[1].Layer = "待删除等高线";
535
+                    //    }
536
+                    //    else if (pts.Contains(newPlls[i].StartPoint) &&
537
+                    //        pts.Contains(newPlls[i].EndPoint) &&
538
+                    //        i % 2 == 1)
539
+                    //        newPlls[i].Layer = "待删除等高线";
540
+                    //    else if (kz_pts.Contains(newPlls[i].StartPoint) &&
541
+                    //        kz_pts.Contains(newPlls[i].EndPoint) &&
542
+                    //        i % 2 == 1)
543
+                    //        newPlls[i].Layer = "待删除等高线";
544
+                    //}
545
+                }
546
+                DocumentLock doclock1 = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
547
+                using (Transaction trans = db.TransactionManager.StartTransaction())
548
+                {
549
+                    Polyline pl = trans.GetObject(pll.ObjectId, OpenMode.ForWrite) as Polyline;
550
+                    pl.Erase();
551
+                    trans.Commit();
552
+                }
553
+                doclock1.Dispose();
554
+                //    trans.Commit();
555
+                //}
556
+            }
557
+        }
558
+
559
+        /// <summary>
560
+        /// 缩放视图以便搜索
561
+        /// </summary>
562
+        private void ZoomView(Editor edit, Point3d pt1, Point3d pt2)
563
+        {
564
+            var x_min = Math.Min(pt1.X, pt2.X);
565
+            var y_min = Math.Min(pt1.Y, pt2.Y);
566
+            using (ViewTableRecord currview1 = edit.GetCurrentView())
567
+            {
568
+                currview1.CenterPoint = new Point2d(Math.Abs((pt2.X - pt1.X) / 2) + x_min,
569
+                                                    Math.Abs((pt2.Y - pt1.Y) / 2) + y_min);
570
+                currview1.Width = Math.Abs(pt2.X - pt1.X + 1);
571
+                currview1.Height = Math.Abs(pt2.Y - pt1.Y + 1);
572
+                edit.SetCurrentView(currview1);
573
+            }
574
+        }
575
+
576
+        private List<Point3d> GetIntersections(Polyline pll1, Polyline pll2)
577
+        {
578
+            List<Point3d> result = new List<Point3d>();
579
+
580
+            // 创建临时副本
581
+            using (Polyline tempLine1 = (Polyline)pll1.Clone())
582
+            using (Polyline tempLine2 = (Polyline)pll2.Clone())
583
+            {
584
+
585
+                // 计算平移向量(以线1起点为基准,移动至原点)
586
+                Vector3d translation = -tempLine1.StartPoint.GetAsVector();
587
+                Matrix3d translateMatrix = Matrix3d.Displacement(translation);
588
+
589
+                // 应用平移变换
590
+                tempLine1.TransformBy(translateMatrix);
591
+                tempLine2.TransformBy(translateMatrix);
592
+
593
+                Point3dCollection translatedPoints = new Point3dCollection();
594
+                var plane = new Plane(Point3d.Origin, Vector3d.ZAxis);
595
+                tempLine1.IntersectWith(tempLine2, Intersect.OnBothOperands,plane, translatedPoints, IntPtr.Zero, IntPtr.Zero);
596
+
597
+                // 计算逆平移矩阵
598
+                Matrix3d inverseMatrix = Matrix3d.Displacement(-translation);
599
+                if (translatedPoints.Count > 0)
600
+                {
601
+                    // 获取平移后的交点
602
+                    foreach (Point3d item in translatedPoints)
603
+                    {
604
+                        // 恢复交点坐标
605
+                        var pt = item.TransformBy(inverseMatrix);
606
+                        var pt1 = pll1.GetClosestPointTo(pt, false);
607
+                        result.Add(pt1);
608
+                    }
609
+                    translatedPoints.Dispose();
610
+                }
611
+                tempLine1.Dispose();
612
+                tempLine2.Dispose();
613
+            }
614
+            return result;
615
+        }
616
+    }
617
+}

+ 198
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/Dgxthrorvrd_Form.Designer.cs 查看文件

@@ -0,0 +1,198 @@
1
+
2
+namespace CADTools
3
+{
4
+    partial class Dgxthrorvrd_Form
5
+    {
6
+        /// <summary>
7
+        /// Required designer variable.
8
+        /// </summary>
9
+        private System.ComponentModel.IContainer components = null;
10
+
11
+        /// <summary>
12
+        /// Clean up any resources being used.
13
+        /// </summary>
14
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
15
+        protected override void Dispose(bool disposing)
16
+        {
17
+            if (disposing && (components != null))
18
+            {
19
+                components.Dispose();
20
+            }
21
+            base.Dispose(disposing);
22
+        }
23
+
24
+        #region Windows Form Designer generated code
25
+
26
+        /// <summary>
27
+        /// Required method for Designer support - do not modify
28
+        /// the contents of this method with the code editor.
29
+        /// </summary>
30
+        private void InitializeComponent()
31
+        {
32
+            this.label1 = new System.Windows.Forms.Label();
33
+            this.label2 = new System.Windows.Forms.Label();
34
+            this.checkedListBox_dgx = new System.Windows.Forms.CheckedListBox();
35
+            this.checkedListBox_rvrd = new System.Windows.Forms.CheckedListBox();
36
+            this.button_OK = new System.Windows.Forms.Button();
37
+            this.button_Cancel = new System.Windows.Forms.Button();
38
+            this.label3 = new System.Windows.Forms.Label();
39
+            this.checkedListBox_fw = new System.Windows.Forms.CheckedListBox();
40
+            this.label4 = new System.Windows.Forms.Label();
41
+            this.comboBox_blc = new System.Windows.Forms.ComboBox();
42
+            this.label5 = new System.Windows.Forms.Label();
43
+            this.textBox_yz = new System.Windows.Forms.TextBox();
44
+            this.SuspendLayout();
45
+            // 
46
+            // label1
47
+            // 
48
+            this.label1.AutoSize = true;
49
+            this.label1.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
50
+            this.label1.Location = new System.Drawing.Point(44, 75);
51
+            this.label1.Name = "label1";
52
+            this.label1.Size = new System.Drawing.Size(127, 15);
53
+            this.label1.TabIndex = 0;
54
+            this.label1.Text = "等高线所在图层:";
55
+            // 
56
+            // label2
57
+            // 
58
+            this.label2.AutoSize = true;
59
+            this.label2.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
60
+            this.label2.Location = new System.Drawing.Point(206, 75);
61
+            this.label2.Name = "label2";
62
+            this.label2.Size = new System.Drawing.Size(142, 15);
63
+            this.label2.TabIndex = 1;
64
+            this.label2.Text = "河流道路所在图层:";
65
+            // 
66
+            // checkedListBox_dgx
67
+            // 
68
+            this.checkedListBox_dgx.FormattingEnabled = true;
69
+            this.checkedListBox_dgx.Location = new System.Drawing.Point(47, 103);
70
+            this.checkedListBox_dgx.Name = "checkedListBox_dgx";
71
+            this.checkedListBox_dgx.Size = new System.Drawing.Size(124, 164);
72
+            this.checkedListBox_dgx.TabIndex = 2;
73
+            // 
74
+            // checkedListBox_rvrd
75
+            // 
76
+            this.checkedListBox_rvrd.FormattingEnabled = true;
77
+            this.checkedListBox_rvrd.Location = new System.Drawing.Point(221, 103);
78
+            this.checkedListBox_rvrd.Name = "checkedListBox_rvrd";
79
+            this.checkedListBox_rvrd.Size = new System.Drawing.Size(124, 164);
80
+            this.checkedListBox_rvrd.TabIndex = 3;
81
+            // 
82
+            // button_OK
83
+            // 
84
+            this.button_OK.Location = new System.Drawing.Point(175, 295);
85
+            this.button_OK.Name = "button_OK";
86
+            this.button_OK.Size = new System.Drawing.Size(75, 31);
87
+            this.button_OK.TabIndex = 4;
88
+            this.button_OK.Text = "确 认";
89
+            this.button_OK.UseVisualStyleBackColor = true;
90
+            this.button_OK.Click += new System.EventHandler(this.button_OK_Click);
91
+            // 
92
+            // button_Cancel
93
+            // 
94
+            this.button_Cancel.Location = new System.Drawing.Point(333, 295);
95
+            this.button_Cancel.Name = "button_Cancel";
96
+            this.button_Cancel.Size = new System.Drawing.Size(75, 30);
97
+            this.button_Cancel.TabIndex = 5;
98
+            this.button_Cancel.Text = "取 消";
99
+            this.button_Cancel.UseVisualStyleBackColor = true;
100
+            // 
101
+            // label3
102
+            // 
103
+            this.label3.AutoSize = true;
104
+            this.label3.Location = new System.Drawing.Point(385, 75);
105
+            this.label3.Name = "label3";
106
+            this.label3.Size = new System.Drawing.Size(112, 15);
107
+            this.label3.TabIndex = 6;
108
+            this.label3.Text = "房屋所在图层:";
109
+            // 
110
+            // checkedListBox_fw
111
+            // 
112
+            this.checkedListBox_fw.FormattingEnabled = true;
113
+            this.checkedListBox_fw.Location = new System.Drawing.Point(388, 103);
114
+            this.checkedListBox_fw.Name = "checkedListBox_fw";
115
+            this.checkedListBox_fw.Size = new System.Drawing.Size(124, 164);
116
+            this.checkedListBox_fw.TabIndex = 7;
117
+            // 
118
+            // label4
119
+            // 
120
+            this.label4.AutoSize = true;
121
+            this.label4.Location = new System.Drawing.Point(47, 26);
122
+            this.label4.Name = "label4";
123
+            this.label4.Size = new System.Drawing.Size(67, 15);
124
+            this.label4.TabIndex = 8;
125
+            this.label4.Text = "比例尺:";
126
+            // 
127
+            // comboBox_blc
128
+            // 
129
+            this.comboBox_blc.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
130
+            this.comboBox_blc.FormattingEnabled = true;
131
+            this.comboBox_blc.Items.AddRange(new object[] {
132
+            "1:500",
133
+            "1:1000",
134
+            "1:2000",
135
+            "1:5000",
136
+            "1:10000"});
137
+            this.comboBox_blc.Location = new System.Drawing.Point(120, 23);
138
+            this.comboBox_blc.Name = "comboBox_blc";
139
+            this.comboBox_blc.Size = new System.Drawing.Size(156, 23);
140
+            this.comboBox_blc.TabIndex = 9;
141
+            // 
142
+            // label5
143
+            // 
144
+            this.label5.AutoSize = true;
145
+            this.label5.Location = new System.Drawing.Point(333, 26);
146
+            this.label5.Name = "label5";
147
+            this.label5.Size = new System.Drawing.Size(82, 15);
148
+            this.label5.TabIndex = 10;
149
+            this.label5.Text = "裁剪阈值:";
150
+            // 
151
+            // textBox_yz
152
+            // 
153
+            this.textBox_yz.Location = new System.Drawing.Point(421, 21);
154
+            this.textBox_yz.Name = "textBox_yz";
155
+            this.textBox_yz.Size = new System.Drawing.Size(100, 25);
156
+            this.textBox_yz.TabIndex = 11;
157
+            // 
158
+            // Dgxthrorvrd_Form
159
+            // 
160
+            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
161
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
162
+            this.ClientSize = new System.Drawing.Size(598, 349);
163
+            this.Controls.Add(this.textBox_yz);
164
+            this.Controls.Add(this.label5);
165
+            this.Controls.Add(this.comboBox_blc);
166
+            this.Controls.Add(this.label4);
167
+            this.Controls.Add(this.checkedListBox_fw);
168
+            this.Controls.Add(this.label3);
169
+            this.Controls.Add(this.button_Cancel);
170
+            this.Controls.Add(this.button_OK);
171
+            this.Controls.Add(this.checkedListBox_rvrd);
172
+            this.Controls.Add(this.checkedListBox_dgx);
173
+            this.Controls.Add(this.label2);
174
+            this.Controls.Add(this.label1);
175
+            this.Name = "Dgxthrorvrd_Form";
176
+            this.Text = "过河流道路的等高线裁剪";
177
+            this.Load += new System.EventHandler(this.Dgxthrorvrd_Form_Load);
178
+            this.ResumeLayout(false);
179
+            this.PerformLayout();
180
+
181
+        }
182
+
183
+        #endregion
184
+
185
+        private System.Windows.Forms.Label label1;
186
+        private System.Windows.Forms.Label label2;
187
+        private System.Windows.Forms.CheckedListBox checkedListBox_dgx;
188
+        private System.Windows.Forms.CheckedListBox checkedListBox_rvrd;
189
+        private System.Windows.Forms.Button button_OK;
190
+        private System.Windows.Forms.Button button_Cancel;
191
+        private System.Windows.Forms.Label label3;
192
+        private System.Windows.Forms.CheckedListBox checkedListBox_fw;
193
+        private System.Windows.Forms.Label label4;
194
+        private System.Windows.Forms.ComboBox comboBox_blc;
195
+        private System.Windows.Forms.Label label5;
196
+        private System.Windows.Forms.TextBox textBox_yz;
197
+    }
198
+}

+ 108
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/Dgxthrorvrd_Form.cs 查看文件

@@ -0,0 +1,108 @@
1
+using Autodesk.AutoCAD.DatabaseServices;
2
+using System;
3
+using System.Collections.Generic;
4
+using System.ComponentModel;
5
+using System.Data;
6
+using System.Drawing;
7
+using System.Linq;
8
+using System.Text;
9
+using System.Threading.Tasks;
10
+using System.Windows.Forms;
11
+
12
+namespace CADTools
13
+{
14
+    public partial class Dgxthrorvrd_Form : Form
15
+    {
16
+        public Dgxthrorvrd_Form()
17
+        {
18
+            InitializeComponent();
19
+        }
20
+
21
+        private void Dgxthrorvrd_Form_Load(object sender, EventArgs e)
22
+        {
23
+            Database database = Autodesk.AutoCAD.DatabaseServices.HostApplicationServices.WorkingDatabase;
24
+            using (Transaction traction = database.TransactionManager.StartTransaction())
25
+            {
26
+                //存放所有图层名
27
+                List<string> alllayername = new List<string>();
28
+                LayerTable layertable = traction.GetObject(database.LayerTableId, OpenMode.ForRead) as LayerTable;
29
+                foreach (ObjectId objid in layertable)
30
+                {
31
+                    LayerTableRecord layertablerecord = traction.GetObject(objid, OpenMode.ForRead) as LayerTableRecord;
32
+                    alllayername.Add(layertablerecord.Name);
33
+                }
34
+                alllayername.Sort();
35
+
36
+                for (int i = 0; i < alllayername.Count; i++)
37
+                {
38
+                    this.checkedListBox_dgx.Items.Add(alllayername[i]);
39
+                    this.checkedListBox_rvrd.Items.Add(alllayername[i]);
40
+                    this.checkedListBox_fw.Items.Add(alllayername[i]);
41
+                }
42
+            }
43
+        }
44
+
45
+        private void button_OK_Click(object sender, EventArgs e)
46
+        {
47
+            if (comboBox_blc.SelectedItem == null)
48
+            {
49
+                MessageBox.Show("请选择比例尺!", "提示");
50
+                return;
51
+            }
52
+            if (checkedListBox_dgx.CheckedItems.Count == 0)
53
+            {
54
+                MessageBox.Show("等高线图层不能为空!", "提示");
55
+                return;
56
+            }
57
+            if (textBox_yz.Text=="")
58
+            {
59
+                MessageBox.Show("阈值不能为空!", "提示");
60
+                return;
61
+            }
62
+            if (checkedListBox_rvrd.CheckedItems.Count == 0&&
63
+                checkedListBox_fw.CheckedItems.Count == 0)
64
+            {
65
+                MessageBox.Show("河流道路图层和房屋图层不能都为空!", "提示");
66
+                return;
67
+            }
68
+            List<string> dgx = new List<string>();//存放等高线
69
+            List<string> rvrd = new List<string>();//存放河流道路图层
70
+            List<string> house = new List<string>();//存放房屋图层
71
+
72
+            for (int i = 0; i < checkedListBox_dgx.CheckedItems.Count; i++)
73
+            {
74
+                dgx.Add(checkedListBox_dgx.CheckedItems[i].ToString());
75
+            }
76
+            if (checkedListBox_rvrd.CheckedItems.Count != 0)
77
+            {
78
+                for (int i = 0; i < checkedListBox_rvrd.CheckedItems.Count; i++)
79
+                {
80
+                    rvrd.Add(checkedListBox_rvrd.CheckedItems[i].ToString());
81
+                }
82
+                //Dgxthrorvrd.rvrdlist = rvrd;
83
+                DgxCrossrvrd.rvrdlist = rvrd;
84
+            }
85
+            if (checkedListBox_fw.CheckedItems.Count != 0)
86
+            {
87
+                for (int i = 0; i < checkedListBox_fw.CheckedItems.Count; i++)
88
+                {
89
+                    house.Add(checkedListBox_fw.CheckedItems[i].ToString());
90
+                }
91
+                //Dgxthrorvrd.houselist = house;
92
+                DgxCrossrvrd.houselist = house;
93
+            }
94
+            //Dgxthrorvrd.dgxlist = dgx;
95
+            //Dgxthrorvrd.blc = Convert.ToInt32(comboBox_blc.SelectedItem.ToString().Split(':')[1]);
96
+            //Dgxthrorvrd cutdgx = new Dgxthrorvrd();
97
+            //cutdgx.DgxCut();
98
+            DgxCrossrvrd.dgxlist = dgx;
99
+            DgxCrossrvrd.blc = Convert.ToInt32(comboBox_blc.SelectedItem.ToString().Split(':')[1]);
100
+            DgxCrossrvrd.yz = Convert.ToDouble(textBox_yz.Text);
101
+            DgxCrossrvrd cutdgx = new DgxCrossrvrd();
102
+            cutdgx.DgxCut();
103
+            this.Close();
104
+        }
105
+
106
+
107
+    }
108
+}

+ 120
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/Dgxthrorvrd_Form.resx 查看文件

@@ -0,0 +1,120 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<root>
3
+  <!-- 
4
+    Microsoft ResX Schema 
5
+    
6
+    Version 2.0
7
+    
8
+    The primary goals of this format is to allow a simple XML format 
9
+    that is mostly human readable. The generation and parsing of the 
10
+    various data types are done through the TypeConverter classes 
11
+    associated with the data types.
12
+    
13
+    Example:
14
+    
15
+    ... ado.net/XML headers & schema ...
16
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
17
+    <resheader name="version">2.0</resheader>
18
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
19
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
20
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
21
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
22
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
24
+    </data>
25
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
26
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
27
+        <comment>This is a comment</comment>
28
+    </data>
29
+                
30
+    There are any number of "resheader" rows that contain simple 
31
+    name/value pairs.
32
+    
33
+    Each data row contains a name, and value. The row also contains a 
34
+    type or mimetype. Type corresponds to a .NET class that support 
35
+    text/value conversion through the TypeConverter architecture. 
36
+    Classes that don't support this are serialized and stored with the 
37
+    mimetype set.
38
+    
39
+    The mimetype is used for serialized objects, and tells the 
40
+    ResXResourceReader how to depersist the object. This is currently not 
41
+    extensible. For a given mimetype the value must be set accordingly:
42
+    
43
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
44
+    that the ResXResourceWriter will generate, however the reader can 
45
+    read any of the formats listed below.
46
+    
47
+    mimetype: application/x-microsoft.net.object.binary.base64
48
+    value   : The object must be serialized with 
49
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
50
+            : and then encoded with base64 encoding.
51
+    
52
+    mimetype: application/x-microsoft.net.object.soap.base64
53
+    value   : The object must be serialized with 
54
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
55
+            : and then encoded with base64 encoding.
56
+
57
+    mimetype: application/x-microsoft.net.object.bytearray.base64
58
+    value   : The object must be serialized into a byte array 
59
+            : using a System.ComponentModel.TypeConverter
60
+            : and then encoded with base64 encoding.
61
+    -->
62
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
64
+    <xsd:element name="root" msdata:IsDataSet="true">
65
+      <xsd:complexType>
66
+        <xsd:choice maxOccurs="unbounded">
67
+          <xsd:element name="metadata">
68
+            <xsd:complexType>
69
+              <xsd:sequence>
70
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
71
+              </xsd:sequence>
72
+              <xsd:attribute name="name" use="required" type="xsd:string" />
73
+              <xsd:attribute name="type" type="xsd:string" />
74
+              <xsd:attribute name="mimetype" type="xsd:string" />
75
+              <xsd:attribute ref="xml:space" />
76
+            </xsd:complexType>
77
+          </xsd:element>
78
+          <xsd:element name="assembly">
79
+            <xsd:complexType>
80
+              <xsd:attribute name="alias" type="xsd:string" />
81
+              <xsd:attribute name="name" type="xsd:string" />
82
+            </xsd:complexType>
83
+          </xsd:element>
84
+          <xsd:element name="data">
85
+            <xsd:complexType>
86
+              <xsd:sequence>
87
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
88
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
89
+              </xsd:sequence>
90
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
91
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
92
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
93
+              <xsd:attribute ref="xml:space" />
94
+            </xsd:complexType>
95
+          </xsd:element>
96
+          <xsd:element name="resheader">
97
+            <xsd:complexType>
98
+              <xsd:sequence>
99
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
100
+              </xsd:sequence>
101
+              <xsd:attribute name="name" type="xsd:string" use="required" />
102
+            </xsd:complexType>
103
+          </xsd:element>
104
+        </xsd:choice>
105
+      </xsd:complexType>
106
+    </xsd:element>
107
+  </xsd:schema>
108
+  <resheader name="resmimetype">
109
+    <value>text/microsoft-resx</value>
110
+  </resheader>
111
+  <resheader name="version">
112
+    <value>2.0</value>
113
+  </resheader>
114
+  <resheader name="reader">
115
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116
+  </resheader>
117
+  <resheader name="writer">
118
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119
+  </resheader>
120
+</root>

+ 295
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/ElePtCheck.cs 查看文件

@@ -0,0 +1,295 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Threading.Tasks;
6
+
7
+using Autodesk.AutoCAD.ApplicationServices;
8
+using Autodesk.AutoCAD.DatabaseServices;
9
+using Autodesk.AutoCAD.EditorInput;
10
+using System.Collections;
11
+using Autodesk.AutoCAD.Geometry;
12
+
13
+namespace CADTools
14
+{
15
+    public struct points
16
+    {
17
+        public Point3d pt;
18
+        public ObjectId objID;
19
+    }
20
+
21
+    class ElePtCheck
22
+    {
23
+        public static int blc;//比例尺
24
+        public static string EleLayerName;//高程点图层名
25
+
26
+        public double radius;//半径
27
+        //public double length;//搜索半径
28
+
29
+        int j = 0;//记录错误点个数
30
+
31
+        //存放所有高程点数组
32
+        public List<points> pointarrlist = new List<points>();
33
+        //存放有问题的高程点数组
34
+        public List<points> errorpointarrlist = new List<points>();
35
+
36
+
37
+
38
+        /// <summary>
39
+        /// 检查错误的高程点并画圆标记
40
+        /// </summary>
41
+        public void pointcheck()
42
+        {
43
+            double flagradius = 4.0 * blc / 1000;//画圆标记半径
44
+
45
+            if (blc == 500)
46
+            {
47
+                radius = 1.5;
48
+            }
49
+            else if (blc == 1000)
50
+            {
51
+                radius = 2.5;
52
+            }
53
+            else if (blc == 2000)
54
+            {
55
+                radius = 4;
56
+            }
57
+            else if (blc == 5000)
58
+            {
59
+                radius = 10.5;
60
+            }
61
+            //外切圆半径
62
+            //length = radius * Math.Pow(2, 0.5);
63
+
64
+
65
+            //检查高程点与注记是否一致或为零
66
+            check();
67
+
68
+            //创建存放错误点的图层
69
+            LayerControl layerscontrol = new LayerControl();
70
+            string layname = "错误高程点";
71
+            if (!layerscontrol.haslayername(layname))
72
+            {
73
+                colorgb col = new colorgb(255, 0, 255);
74
+                layerscontrol.creatlayer(layname, col);
75
+                layerscontrol.movelayertofront(layname);
76
+            }
77
+            else
78
+                layerscontrol.movelayertofront(layname);
79
+
80
+            //创建错误点标记的图层
81
+            LayerControl layerscontrol1 = new LayerControl();
82
+            string layname1 = "错误高程点标记";
83
+            if (!layerscontrol1.haslayername(layname1))
84
+            {
85
+                colorgb col = new colorgb(0, 225, 255);
86
+                layerscontrol1.creatlayer(layname1, col);
87
+                layerscontrol1.movelayertofront(layname1);
88
+            }
89
+            else
90
+                layerscontrol1.movelayertofront(layname1);
91
+
92
+            Database database = HostApplicationServices.WorkingDatabase;
93
+            Document doc = Application.DocumentManager.MdiActiveDocument;
94
+            Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
95
+            using (Transaction traction = database.TransactionManager.StartTransaction())
96
+            {
97
+                DocumentLock documentlock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
98
+                BlockTable blocktable = traction.GetObject(database.BlockTableId,OpenMode.ForWrite) as BlockTable;
99
+                
100
+                for (int i = 0; i < errorpointarrlist.Count; i++)
101
+                {
102
+                    BasicFunction functions = new BasicFunction();
103
+                    BlockReference blr= traction.GetObject(errorpointarrlist[i].objID,OpenMode.ForWrite)as BlockReference;
104
+                    blr.Layer = "错误高程点";
105
+                    functions.makeflag(errorpointarrlist[i].pt.X, errorpointarrlist[i].pt.Y, 0, flagradius, "错误高程点标记");
106
+
107
+                    Point3d p1 = new Point3d(errorpointarrlist[i].pt.X - radius, errorpointarrlist[i].pt.Y - radius, 0);
108
+                    Point3d p2 = new Point3d(errorpointarrlist[i].pt.X + radius, errorpointarrlist[i].pt.Y + radius, 0);
109
+                    TypedValue[] typedvalue = new TypedValue[2];
110
+
111
+                    typedvalue.SetValue(new TypedValue((int)DxfCode.Start, "Text"), 0);
112
+                    typedvalue.SetValue(new TypedValue((int)DxfCode.LayerName, EleLayerName), 1);
113
+
114
+                    SelectionFilter filter = new SelectionFilter(typedvalue);
115
+                    PromptSelectionResult psr = editor.SelectCrossingWindow(p1, p2, filter);
116
+
117
+                    if (psr.Status == PromptStatus.OK)
118
+                    {
119
+                        SelectionSet set = psr.Value;
120
+                        ObjectId[] objs = new ObjectId[set.Count];
121
+                        objs = set.GetObjectIds();
122
+                        for (int ii = 0; ii < objs.Length; ii++)
123
+                        {
124
+                            DBText Text = (DBText)traction.GetObject(objs[ii], OpenMode.ForWrite);
125
+                            Text.Layer = "错误高程点";
126
+                        }
127
+                    }
128
+                }
129
+
130
+                traction.Commit();
131
+                documentlock.Dispose();
132
+                traction.Dispose();
133
+            }
134
+
135
+            editor.WriteMessage("\n共有" + j + "处错误");
136
+        }
137
+
138
+        /// <summary>
139
+        /// 检查高程点与注记是否一致或为零
140
+        /// </summary>
141
+        private void check()
142
+        {
143
+            string LayerName = EleLayerName;
144
+            getptInLayer(LayerName);
145
+
146
+            if (pointarrlist == null)
147
+                return;
148
+            Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
149
+            for (int i = 0; i < pointarrlist.Count; i++)
150
+            {
151
+                Point3d pt = pointarrlist[i].pt;
152
+                string getword = GetTxt(pt, LayerName);
153
+                if (pt.Z == 0)
154
+                {
155
+                    errorpointarrlist.Add(pointarrlist[i]);
156
+                    j++;
157
+                }
158
+                if(getword==null)
159
+                {
160
+                    errorpointarrlist.Add(pointarrlist[i]);
161
+                    j++;
162
+                }
163
+                else if (!getword.Contains('.') || getword.Contains(".0"))
164
+                {
165
+                    errorpointarrlist.Add(pointarrlist[i]);
166
+                    j++;
167
+                }
168
+                else
169
+                {
170
+                    if (pt.Z.ToString("f1") == getword && pt.Z % (blc / 1000) != 0)
171
+                    {
172
+                        continue;
173
+                    }
174
+                    else
175
+                    {
176
+                        errorpointarrlist.Add(pointarrlist[i]);
177
+                        j++;
178
+                    }
179
+                }
180
+            }
181
+        }
182
+
183
+
184
+        /// <summary>
185
+        /// 获取图层上高程点坐标
186
+        /// </summary>
187
+        private void getptInLayer(string LayerName)
188
+        {
189
+            Document document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
190
+            Database db = HostApplicationServices.WorkingDatabase;
191
+            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
192
+            
193
+            TypedValue[] value = new TypedValue[]
194
+            {
195
+                new TypedValue((int)DxfCode.LayerName,LayerName),
196
+                new TypedValue((int)DxfCode.Start,"Insert")
197
+            };//设置筛选条件
198
+            SelectionFilter filter = new SelectionFilter(value);
199
+
200
+            //选择区域中全部对象
201
+            //PromptSelectionResult psr = ed.SelectAll(filter);
202
+            // 要求在图形区域中手动选择对象
203
+            PromptSelectionResult psr = ed.GetSelection(filter);
204
+
205
+
206
+            if (psr.Status == PromptStatus.OK)
207
+            {
208
+                using (Transaction transaction = db.TransactionManager.StartTransaction())
209
+                {
210
+                    SelectionSet ss = psr.Value;
211
+                    ObjectId[] ids = ss.GetObjectIds();
212
+
213
+                    points ptlist = new points();
214
+                    foreach (ObjectId etId in ids)
215
+                    {
216
+                        BlockReference blr = transaction.GetObject(etId, OpenMode.ForRead) as BlockReference;
217
+                        ptlist.pt = blr.Position;
218
+                        ptlist.objID = blr.Id;
219
+                        pointarrlist.Add(ptlist);
220
+                    }
221
+
222
+                    transaction.Commit();
223
+                }
224
+            }
225
+        }
226
+
227
+        /// <summary>
228
+        /// 筛选坐标点附近文字信息
229
+        /// </summary>
230
+        private static String GetTxt(Point3d pt, string LayerName)
231
+        {
232
+            ObjectId[] objss = null;//文本对象的ID数组
233
+            Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
234
+
235
+            TypedValue[] val = new TypedValue[] 
236
+            { new TypedValue(0, "TEXT"),
237
+              new TypedValue((int)DxfCode.LayerName,LayerName)
238
+            };//需要筛选的类型值
239
+            SelectionFilter fil = new SelectionFilter(val);//选择过滤器
240
+            PromptSelectionResult pro = ed.SelectCrossingWindow(new Point3d(pt.X - 4.0 * blc / 2000, pt.Y - 4.0 * blc / 2000, 0),
241
+                new Point3d(pt.X + 4.0 * blc / 2000, pt.Y + 4.0 * blc / 2000, 0), fil);
242
+            //PromptSelectionResult pro = ed.SelectAll(fil);//获取结果
243
+            SelectionSet ss = pro.Value;//赋值给选择集
244
+            String txt = null;
245
+
246
+            if (ss != null)
247
+            {
248
+                objss = ss.GetObjectIds();//将选择集内对象ID赋值给ID数组
249
+                if (objss.Length > 1)
250
+                {
251
+                    for (int i = 0; i < objss.Length; i++)
252
+                    {
253
+                        DBText buftext = GetDBObject(objss[i]) as DBText;
254
+                        if (pt.Z.ToString("f1") == buftext.TextString)
255
+                            txt = buftext.TextString;
256
+                    }
257
+                }
258
+                else
259
+                {
260
+                    DBText buftext = GetDBObject(objss[0]) as DBText;
261
+                    txt = buftext.TextString;
262
+                }
263
+            }
264
+            else
265
+                txt = txt+"";
266
+            //for (int i = 0; i < objss.Length; i++)
267
+            //{
268
+            //    DBText buftext = GetDBObject(objss[i]) as DBText;//遍历数组ID将对象赋值给单行文本
269
+            //    Point3d po = buftext.Position;//获取单行文本的坐标点
270
+            //    if (Math.Sqrt((po.X - x) * (po.X - x) + (po.Y - y) * (po.Y - y)) < 10)
271
+            //    {
272
+            //        txt = buftext.TextString;//筛选出的单行文本对象
273
+            //    }
274
+            //    else
275
+            //        continue;
276
+            //}
277
+            return txt;
278
+        }
279
+
280
+        private static Entity GetDBObject(ObjectId i)
281
+        {
282
+            Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
283
+            Database db = doc.Database;
284
+            Entity ent = null;
285
+            using (Transaction tr = db.TransactionManager.StartTransaction())
286
+            {
287
+                ent = (Entity)tr.GetObject(i, OpenMode.ForRead, true);
288
+                tr.Commit();
289
+            }
290
+            return ent;
291
+        }
292
+
293
+        }
294
+    }
295
+

+ 124
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/EleRd.Designer.cs 查看文件

@@ -0,0 +1,124 @@
1
+
2
+namespace CADTools
3
+{
4
+    partial class EleRd
5
+    {
6
+        /// <summary>
7
+        /// Required designer variable.
8
+        /// </summary>
9
+        private System.ComponentModel.IContainer components = null;
10
+
11
+        /// <summary>
12
+        /// Clean up any resources being used.
13
+        /// </summary>
14
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
15
+        protected override void Dispose(bool disposing)
16
+        {
17
+            if (disposing && (components != null))
18
+            {
19
+                components.Dispose();
20
+            }
21
+            base.Dispose(disposing);
22
+        }
23
+
24
+        #region Windows Form Designer generated code
25
+
26
+        /// <summary>
27
+        /// Required method for Designer support - do not modify
28
+        /// the contents of this method with the code editor.
29
+        /// </summary>
30
+        private void InitializeComponent()
31
+        {
32
+            this.comboBox_sqx = new System.Windows.Forms.ComboBox();
33
+            this.label1 = new System.Windows.Forms.Label();
34
+            this.comboBox_jqx = new System.Windows.Forms.ComboBox();
35
+            this.label2 = new System.Windows.Forms.Label();
36
+            this.btn_Cancel = new System.Windows.Forms.Button();
37
+            this.btn_OK = new System.Windows.Forms.Button();
38
+            this.SuspendLayout();
39
+            // 
40
+            // comboBox_sqx
41
+            // 
42
+            this.comboBox_sqx.FormattingEnabled = true;
43
+            this.comboBox_sqx.Location = new System.Drawing.Point(155, 80);
44
+            this.comboBox_sqx.Name = "comboBox_sqx";
45
+            this.comboBox_sqx.Size = new System.Drawing.Size(160, 23);
46
+            this.comboBox_sqx.TabIndex = 67;
47
+            // 
48
+            // label1
49
+            // 
50
+            this.label1.AutoSize = true;
51
+            this.label1.Location = new System.Drawing.Point(52, 83);
52
+            this.label1.Name = "label1";
53
+            this.label1.Size = new System.Drawing.Size(97, 15);
54
+            this.label1.TabIndex = 66;
55
+            this.label1.Text = "首曲线图层:";
56
+            // 
57
+            // comboBox_jqx
58
+            // 
59
+            this.comboBox_jqx.FormattingEnabled = true;
60
+            this.comboBox_jqx.Location = new System.Drawing.Point(155, 34);
61
+            this.comboBox_jqx.Name = "comboBox_jqx";
62
+            this.comboBox_jqx.Size = new System.Drawing.Size(160, 23);
63
+            this.comboBox_jqx.TabIndex = 65;
64
+            // 
65
+            // label2
66
+            // 
67
+            this.label2.AutoSize = true;
68
+            this.label2.Location = new System.Drawing.Point(52, 37);
69
+            this.label2.Name = "label2";
70
+            this.label2.Size = new System.Drawing.Size(97, 15);
71
+            this.label2.TabIndex = 64;
72
+            this.label2.Text = "计曲线图层:";
73
+            // 
74
+            // btn_Cancel
75
+            // 
76
+            this.btn_Cancel.Location = new System.Drawing.Point(215, 124);
77
+            this.btn_Cancel.Margin = new System.Windows.Forms.Padding(4);
78
+            this.btn_Cancel.Name = "btn_Cancel";
79
+            this.btn_Cancel.Size = new System.Drawing.Size(100, 29);
80
+            this.btn_Cancel.TabIndex = 63;
81
+            this.btn_Cancel.Text = "取 消";
82
+            this.btn_Cancel.UseVisualStyleBackColor = true;
83
+            this.btn_Cancel.Click += new System.EventHandler(this.btn_Cancel_Click);
84
+            // 
85
+            // btn_OK
86
+            // 
87
+            this.btn_OK.Location = new System.Drawing.Point(52, 124);
88
+            this.btn_OK.Margin = new System.Windows.Forms.Padding(4);
89
+            this.btn_OK.Name = "btn_OK";
90
+            this.btn_OK.Size = new System.Drawing.Size(100, 29);
91
+            this.btn_OK.TabIndex = 62;
92
+            this.btn_OK.Text = "确 定";
93
+            this.btn_OK.UseVisualStyleBackColor = true;
94
+            this.btn_OK.Click += new System.EventHandler(this.btn_OK_Click);
95
+            // 
96
+            // EleRd
97
+            // 
98
+            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
99
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
100
+            this.ClientSize = new System.Drawing.Size(380, 184);
101
+            this.Controls.Add(this.comboBox_sqx);
102
+            this.Controls.Add(this.label1);
103
+            this.Controls.Add(this.comboBox_jqx);
104
+            this.Controls.Add(this.label2);
105
+            this.Controls.Add(this.btn_Cancel);
106
+            this.Controls.Add(this.btn_OK);
107
+            this.Name = "EleRd";
108
+            this.Text = "等高线高程取整";
109
+            this.Load += new System.EventHandler(this.EleRd_Load);
110
+            this.ResumeLayout(false);
111
+            this.PerformLayout();
112
+
113
+        }
114
+
115
+        #endregion
116
+
117
+        private System.Windows.Forms.ComboBox comboBox_sqx;
118
+        private System.Windows.Forms.Label label1;
119
+        private System.Windows.Forms.ComboBox comboBox_jqx;
120
+        private System.Windows.Forms.Label label2;
121
+        private System.Windows.Forms.Button btn_Cancel;
122
+        private System.Windows.Forms.Button btn_OK;
123
+    }
124
+}

+ 85
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/EleRd.cs 查看文件

@@ -0,0 +1,85 @@
1
+using Autodesk.AutoCAD.DatabaseServices;
2
+using System;
3
+using System.Collections.Generic;
4
+using System.ComponentModel;
5
+using System.Data;
6
+using System.Drawing;
7
+using System.Linq;
8
+using System.Text;
9
+using System.Threading.Tasks;
10
+using System.Windows.Forms;
11
+
12
+namespace CADTools
13
+{
14
+    public partial class EleRd : Form
15
+    {
16
+        public EleRd()
17
+        {
18
+            InitializeComponent();
19
+        }
20
+
21
+        private void EleRd_Load(object sender, EventArgs e)
22
+        {
23
+            this.comboBox_jqx.DropDownStyle = ComboBoxStyle.DropDownList;
24
+            this.comboBox_sqx.DropDownStyle = ComboBoxStyle.DropDownList;
25
+
26
+            //自动填充下拉框
27
+            Database database = Autodesk.AutoCAD.DatabaseServices.HostApplicationServices.WorkingDatabase;
28
+            using (Transaction traction = database.TransactionManager.StartTransaction())
29
+            {
30
+                //存放所有图层名
31
+                List<string> alllayername = new List<string>();
32
+                LayerTable layertable = traction.GetObject(database.LayerTableId, OpenMode.ForRead) as LayerTable;
33
+                foreach (ObjectId objid in layertable)
34
+                {
35
+                    LayerTableRecord layertablerecord = traction.GetObject(objid, OpenMode.ForRead) as LayerTableRecord;
36
+                    alllayername.Add(layertablerecord.Name);
37
+                }
38
+
39
+                alllayername.Sort();
40
+
41
+                for (int i = 0; i < alllayername.Count; i++)
42
+                {
43
+                    this.comboBox_jqx.Items.Add(alllayername[i]);
44
+                    this.comboBox_sqx.Items.Add(alllayername[i]);
45
+                }
46
+
47
+                if (alllayername.Contains("8110"))
48
+                {
49
+                    int index = alllayername.IndexOf("8110");
50
+                    this.comboBox_sqx.SelectedIndex = index;
51
+                }
52
+                if (alllayername.Contains("8120"))
53
+                {
54
+                    int index = alllayername.IndexOf("8120");
55
+                    this.comboBox_jqx.SelectedIndex = index;
56
+                }
57
+                traction.Commit();
58
+            }
59
+        }
60
+
61
+        private void btn_OK_Click(object sender, EventArgs e)
62
+        {
63
+            if (comboBox_sqx.Text == "")
64
+            {
65
+                Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("请选择首曲线");
66
+                return;
67
+            }
68
+            if (comboBox_sqx.Text == "")
69
+            {
70
+                Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("请选择计曲线");
71
+                return;
72
+            }
73
+            EleRound.jqx = comboBox_jqx.Text;
74
+            EleRound.sqx = comboBox_sqx.Text;
75
+            this.Close();
76
+            EleRound elerd = new EleRound();
77
+            elerd.eleround();
78
+        }
79
+
80
+        private void btn_Cancel_Click(object sender, EventArgs e)
81
+        {
82
+            this.Close();
83
+        }
84
+    }
85
+}

+ 120
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/EleRd.resx 查看文件

@@ -0,0 +1,120 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<root>
3
+  <!-- 
4
+    Microsoft ResX Schema 
5
+    
6
+    Version 2.0
7
+    
8
+    The primary goals of this format is to allow a simple XML format 
9
+    that is mostly human readable. The generation and parsing of the 
10
+    various data types are done through the TypeConverter classes 
11
+    associated with the data types.
12
+    
13
+    Example:
14
+    
15
+    ... ado.net/XML headers & schema ...
16
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
17
+    <resheader name="version">2.0</resheader>
18
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
19
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
20
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
21
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
22
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
24
+    </data>
25
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
26
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
27
+        <comment>This is a comment</comment>
28
+    </data>
29
+                
30
+    There are any number of "resheader" rows that contain simple 
31
+    name/value pairs.
32
+    
33
+    Each data row contains a name, and value. The row also contains a 
34
+    type or mimetype. Type corresponds to a .NET class that support 
35
+    text/value conversion through the TypeConverter architecture. 
36
+    Classes that don't support this are serialized and stored with the 
37
+    mimetype set.
38
+    
39
+    The mimetype is used for serialized objects, and tells the 
40
+    ResXResourceReader how to depersist the object. This is currently not 
41
+    extensible. For a given mimetype the value must be set accordingly:
42
+    
43
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
44
+    that the ResXResourceWriter will generate, however the reader can 
45
+    read any of the formats listed below.
46
+    
47
+    mimetype: application/x-microsoft.net.object.binary.base64
48
+    value   : The object must be serialized with 
49
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
50
+            : and then encoded with base64 encoding.
51
+    
52
+    mimetype: application/x-microsoft.net.object.soap.base64
53
+    value   : The object must be serialized with 
54
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
55
+            : and then encoded with base64 encoding.
56
+
57
+    mimetype: application/x-microsoft.net.object.bytearray.base64
58
+    value   : The object must be serialized into a byte array 
59
+            : using a System.ComponentModel.TypeConverter
60
+            : and then encoded with base64 encoding.
61
+    -->
62
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
64
+    <xsd:element name="root" msdata:IsDataSet="true">
65
+      <xsd:complexType>
66
+        <xsd:choice maxOccurs="unbounded">
67
+          <xsd:element name="metadata">
68
+            <xsd:complexType>
69
+              <xsd:sequence>
70
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
71
+              </xsd:sequence>
72
+              <xsd:attribute name="name" use="required" type="xsd:string" />
73
+              <xsd:attribute name="type" type="xsd:string" />
74
+              <xsd:attribute name="mimetype" type="xsd:string" />
75
+              <xsd:attribute ref="xml:space" />
76
+            </xsd:complexType>
77
+          </xsd:element>
78
+          <xsd:element name="assembly">
79
+            <xsd:complexType>
80
+              <xsd:attribute name="alias" type="xsd:string" />
81
+              <xsd:attribute name="name" type="xsd:string" />
82
+            </xsd:complexType>
83
+          </xsd:element>
84
+          <xsd:element name="data">
85
+            <xsd:complexType>
86
+              <xsd:sequence>
87
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
88
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
89
+              </xsd:sequence>
90
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
91
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
92
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
93
+              <xsd:attribute ref="xml:space" />
94
+            </xsd:complexType>
95
+          </xsd:element>
96
+          <xsd:element name="resheader">
97
+            <xsd:complexType>
98
+              <xsd:sequence>
99
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
100
+              </xsd:sequence>
101
+              <xsd:attribute name="name" type="xsd:string" use="required" />
102
+            </xsd:complexType>
103
+          </xsd:element>
104
+        </xsd:choice>
105
+      </xsd:complexType>
106
+    </xsd:element>
107
+  </xsd:schema>
108
+  <resheader name="resmimetype">
109
+    <value>text/microsoft-resx</value>
110
+  </resheader>
111
+  <resheader name="version">
112
+    <value>2.0</value>
113
+  </resheader>
114
+  <resheader name="reader">
115
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116
+  </resheader>
117
+  <resheader name="writer">
118
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119
+  </resheader>
120
+</root>

+ 71
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/EleRound.cs 查看文件

@@ -0,0 +1,71 @@
1
+using Autodesk.AutoCAD.DatabaseServices;
2
+using Autodesk.AutoCAD.Geometry;
3
+using Autodesk.AutoCAD.ApplicationServices;
4
+using Autodesk.AutoCAD.EditorInput;
5
+using System.Windows.Forms;
6
+
7
+using System;
8
+using System.Collections.Generic;
9
+using System.Linq;
10
+using System.Text;
11
+using System.Threading.Tasks;
12
+
13
+namespace CADTools
14
+{
15
+    class EleRound
16
+    {
17
+        public static string jqx;
18
+        public static string sqx;
19
+        public void eleround()
20
+        {
21
+            Database db = HostApplicationServices.WorkingDatabase;
22
+            Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
23
+
24
+            string lyrname = jqx + "," + sqx;
25
+            //选择要取整等高线
26
+            TypedValue[] value = new TypedValue[]
27
+            {
28
+                new TypedValue((int)DxfCode.LayerName,lyrname),
29
+                new TypedValue((int)DxfCode.Start,"LWPOLYLINE")
30
+            };//设置筛选条件
31
+            SelectionFilter filter = new SelectionFilter(value);//选择区域中全部对象
32
+            //PromptSelectionResult psr = ed.SelectAll(filter);// 要求在图形区域中手动选择对象
33
+            PromptSelectionResult psr = ed.GetSelection(filter);
34
+
35
+            if (psr.Status == PromptStatus.OK)
36
+            {
37
+                int elelines = 0;
38
+                SelectionSet ss = psr.Value;
39
+                if (ss == null)
40
+                    return;
41
+                ObjectIdCollection idcoll1 = new ObjectIdCollection(ss.GetObjectIds());
42
+                for (int i = 0; i < idcoll1.Count; i++)
43
+                {
44
+                    DocumentLock doclock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
45
+                    using (Transaction trans = db.TransactionManager.StartTransaction())
46
+                    {
47
+                        BlockTable bt = (BlockTable)trans.GetObject(db.BlockTableId, OpenMode.ForRead);
48
+                        BlockTableRecord btr = (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
49
+                        Polyline pll = (Polyline)idcoll1[i].GetObject(OpenMode.ForWrite);
50
+                        if ((Math.Round(pll.Elevation, 4, MidpointRounding.AwayFromZero) != Math.Truncate((Math.Round(pll.Elevation, 4, MidpointRounding.AwayFromZero)))))
51
+                        {
52
+                            LayerControl layerscontrol = new LayerControl();
53
+                            string layname = "已修改";
54
+                            if (layerscontrol.haslayername(layname) == false)
55
+                            {
56
+                                colorgb col = new colorgb(255, 0, 0);
57
+                                layerscontrol.creatlayer(layname, col);
58
+                            }
59
+                            pll.Elevation = Math.Round(pll.Elevation, 0, MidpointRounding.AwayFromZero);
60
+                            pll.Layer = "已修改";
61
+                            elelines++;
62
+                        }
63
+                        trans.Commit();
64
+                    }
65
+                    doclock.Dispose();
66
+                }
67
+                ed.WriteMessage("\n" + "已修改" + elelines.ToString() + "条高程非整数等高线");
68
+            }
69
+        }
70
+    }
71
+}

+ 161
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/EleptDenck.cs 查看文件

@@ -0,0 +1,161 @@
1
+using Autodesk.AutoCAD.ApplicationServices;
2
+using Autodesk.AutoCAD.DatabaseServices;
3
+using Autodesk.AutoCAD.EditorInput;
4
+using Autodesk.AutoCAD.Geometry;
5
+using System;
6
+using System.Collections.Generic;
7
+using System.Linq;
8
+using System.Text;
9
+using System.Threading.Tasks;
10
+
11
+namespace CADTools
12
+{
13
+    class EleptDenck
14
+    {
15
+        public static string ptlayer;
16
+        public static string tklayer;
17
+        public static double density;
18
+        public static int flag;
19
+        public void Ptdensity()
20
+        {
21
+            ObjectId[] ids = TKget();
22
+
23
+            Database db = HostApplicationServices.WorkingDatabase;
24
+            Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
25
+
26
+
27
+            for (int i = 0; i < ids.Length; i++)
28
+            {
29
+                Entity current_entity = BasicFunction.GetDBObject(ids[i]);
30
+                ZoomToExtent(current_entity.GeometricExtents);
31
+                ViewTableRecord acView = editor.GetCurrentView();
32
+                Point3dCollection ptcoll = new Point3dCollection();
33
+                using (Transaction trans = db.TransactionManager.StartTransaction())
34
+                {
35
+                    Polyline pll = (Polyline)trans.GetObject(ids[i], OpenMode.ForRead);
36
+                    for (int j = 0; j < pll.NumberOfVertices; j++)
37
+                    {
38
+                        ptcoll.Add(pll.GetPoint3dAt(j));
39
+                    }
40
+                    trans.Commit();
41
+                }
42
+
43
+                TypedValue[] typedvalue = new TypedValue[2];
44
+                typedvalue.SetValue(new TypedValue((int)DxfCode.LayerName, ptlayer), 0);
45
+                typedvalue.SetValue(new TypedValue((int)DxfCode.Start, "Insert"), 1);
46
+                SelectionFilter selectionfilter = new SelectionFilter(typedvalue);
47
+                PromptSelectionResult psr = editor.SelectCrossingPolygon(ptcoll, selectionfilter);
48
+                int ptnums = 0;
49
+                if (psr.Status == PromptStatus.OK)
50
+                {
51
+                    SelectionSet selectionset = psr.Value;
52
+                    ptnums = selectionset.Count;
53
+                }
54
+                DocumentLock doclock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
55
+                using (Transaction trans = db.TransactionManager.StartTransaction())
56
+                {
57
+                    Polyline pll = (Polyline)trans.GetObject(ids[i], OpenMode.ForWrite);
58
+                    if (ptnums < density && flag == 1)
59
+                    {
60
+                        LayerControl layerscontrol = new LayerControl();
61
+                        string layname = "小于密度";
62
+                        if (!layerscontrol.haslayername(layname))
63
+                        {
64
+                            colorgb col = new colorgb(255, 0, 0);
65
+                            layerscontrol.creatlayer(layname, col);
66
+                            pll.Layer = "小于密度";
67
+                        }
68
+                        else
69
+                            pll.Layer = "小于密度";
70
+                        pll.Color = Autodesk.AutoCAD.Colors.Color.FromColorIndex(Autodesk.AutoCAD.Colors.ColorMethod.ByLayer,256);
71
+                    }
72
+                    if (ptnums > density && flag == 2)
73
+                    {
74
+                        LayerControl layerscontrol = new LayerControl();
75
+                        string layname = "大于密度";
76
+                        if (!layerscontrol.haslayername(layname))
77
+                        {
78
+                            colorgb col = new colorgb(255, 0, 0);
79
+                            layerscontrol.creatlayer(layname, col);
80
+                            pll.Layer = "大于密度";
81
+                        }
82
+                        else
83
+                            pll.Layer = "大于密度";
84
+                        pll.Color = Autodesk.AutoCAD.Colors.Color.FromColorIndex(Autodesk.AutoCAD.Colors.ColorMethod.ByLayer, 256);
85
+                    }
86
+                    if (flag == 3)
87
+                    {
88
+                        if (ptnums < density || ptnums > density)
89
+                        {
90
+                            LayerControl layerscontrol = new LayerControl();
91
+                            string layname = "不等于密度";
92
+                            if (!layerscontrol.haslayername(layname))
93
+                            {
94
+                                colorgb col = new colorgb(255, 0, 0);
95
+                                layerscontrol.creatlayer(layname, col);
96
+                                pll.Layer = "不等于密度";
97
+                            }
98
+                            else
99
+                                pll.Layer = "不等于密度";
100
+                            pll.Color = Autodesk.AutoCAD.Colors.Color.FromColorIndex(Autodesk.AutoCAD.Colors.ColorMethod.ByLayer, 256);
101
+                        }
102
+                    }
103
+                    trans.Commit();
104
+                }
105
+                doclock.Dispose();
106
+
107
+            }
108
+        }
109
+
110
+        private static ObjectId[] TKget()
111
+        {
112
+            Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor; 
113
+            TypedValue[] typedvalue = new TypedValue[1];
114
+            typedvalue.SetValue(new TypedValue((int)DxfCode.LayerName, tklayer), 0);
115
+           
116
+            SelectionFilter selectionfilter = new SelectionFilter(typedvalue);
117
+            PromptSelectionResult psr = editor.SelectAll(selectionfilter);
118
+            SelectionSet selectionset = psr.Value;
119
+            ObjectId[] obj = new ObjectId[selectionset.Count];
120
+
121
+            if (psr.Status == PromptStatus.OK)
122
+            {
123
+                obj = selectionset.GetObjectIds();
124
+            }
125
+            return obj;
126
+        }
127
+
128
+        public static void ZoomToExtent(Extents3d extent)
129
+        {
130
+            try
131
+            {
132
+                Point3d pMin = extent.MinPoint;
133
+                Point3d pMax = extent.MaxPoint;
134
+                //获取当前文档及数据库
135
+                Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
136
+                Database acCurDb = acDoc.Database;
137
+
138
+                // 启动事务
139
+                using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
140
+                {
141
+                    ViewTableRecord acView = acDoc.Editor.GetCurrentView();
142
+                    //设置视图的高
143
+                    acView.Height = Math.Abs(pMin.Y - pMax.Y);
144
+                    //设置视图的宽
145
+                    acView.Width = Math.Abs(pMin.X - pMax.X);
146
+                    // 设置视图中心
147
+                    acView.CenterPoint = new Point2d((pMin.X + pMax.X) / 2, (pMin.Y + pMax.Y) / 2);
148
+                    // 更新当前视图
149
+                    acDoc.Editor.SetCurrentView(acView);
150
+                    // 提交更改
151
+                    acTrans.Commit(); 
152
+                }
153
+            }
154
+            catch (Exception)
155
+            {
156
+
157
+                throw;
158
+            }
159
+        }
160
+    }
161
+}

+ 170
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/EleptDensity.Designer.cs 查看文件

@@ -0,0 +1,170 @@
1
+
2
+namespace CADTools
3
+{
4
+    partial class EleptDensity
5
+    {
6
+        /// <summary>
7
+        /// Required designer variable.
8
+        /// </summary>
9
+        private System.ComponentModel.IContainer components = null;
10
+
11
+        /// <summary>
12
+        /// Clean up any resources being used.
13
+        /// </summary>
14
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
15
+        protected override void Dispose(bool disposing)
16
+        {
17
+            if (disposing && (components != null))
18
+            {
19
+                components.Dispose();
20
+            }
21
+            base.Dispose(disposing);
22
+        }
23
+
24
+        #region Windows Form Designer generated code
25
+
26
+        /// <summary>
27
+        /// Required method for Designer support - do not modify
28
+        /// the contents of this method with the code editor.
29
+        /// </summary>
30
+        private void InitializeComponent()
31
+        {
32
+            this.label1 = new System.Windows.Forms.Label();
33
+            this.label2 = new System.Windows.Forms.Label();
34
+            this.comboBox_ptLayer = new System.Windows.Forms.ComboBox();
35
+            this.comboBox_gw = new System.Windows.Forms.ComboBox();
36
+            this.button_ok = new System.Windows.Forms.Button();
37
+            this.button_cancel = new System.Windows.Forms.Button();
38
+            this.label3 = new System.Windows.Forms.Label();
39
+            this.textBox_density = new System.Windows.Forms.TextBox();
40
+            this.checkBox_upon = new System.Windows.Forms.CheckBox();
41
+            this.checkBox_below = new System.Windows.Forms.CheckBox();
42
+            this.SuspendLayout();
43
+            // 
44
+            // label1
45
+            // 
46
+            this.label1.AutoSize = true;
47
+            this.label1.Location = new System.Drawing.Point(51, 26);
48
+            this.label1.Name = "label1";
49
+            this.label1.Size = new System.Drawing.Size(127, 15);
50
+            this.label1.TabIndex = 0;
51
+            this.label1.Text = "高程点所在图层:";
52
+            // 
53
+            // label2
54
+            // 
55
+            this.label2.AutoSize = true;
56
+            this.label2.Location = new System.Drawing.Point(66, 75);
57
+            this.label2.Name = "label2";
58
+            this.label2.Size = new System.Drawing.Size(112, 15);
59
+            this.label2.TabIndex = 1;
60
+            this.label2.Text = "格网所在图层:";
61
+            // 
62
+            // comboBox_ptLayer
63
+            // 
64
+            this.comboBox_ptLayer.FormattingEnabled = true;
65
+            this.comboBox_ptLayer.Location = new System.Drawing.Point(184, 23);
66
+            this.comboBox_ptLayer.Name = "comboBox_ptLayer";
67
+            this.comboBox_ptLayer.Size = new System.Drawing.Size(197, 23);
68
+            this.comboBox_ptLayer.TabIndex = 2;
69
+            // 
70
+            // comboBox_gw
71
+            // 
72
+            this.comboBox_gw.FormattingEnabled = true;
73
+            this.comboBox_gw.Location = new System.Drawing.Point(184, 72);
74
+            this.comboBox_gw.Name = "comboBox_gw";
75
+            this.comboBox_gw.Size = new System.Drawing.Size(197, 23);
76
+            this.comboBox_gw.TabIndex = 3;
77
+            // 
78
+            // button_ok
79
+            // 
80
+            this.button_ok.Location = new System.Drawing.Point(99, 167);
81
+            this.button_ok.Name = "button_ok";
82
+            this.button_ok.Size = new System.Drawing.Size(75, 29);
83
+            this.button_ok.TabIndex = 6;
84
+            this.button_ok.Text = "确 定";
85
+            this.button_ok.UseVisualStyleBackColor = true;
86
+            this.button_ok.Click += new System.EventHandler(this.button_ok_Click);
87
+            // 
88
+            // button_cancel
89
+            // 
90
+            this.button_cancel.Location = new System.Drawing.Point(289, 167);
91
+            this.button_cancel.Name = "button_cancel";
92
+            this.button_cancel.Size = new System.Drawing.Size(75, 29);
93
+            this.button_cancel.TabIndex = 7;
94
+            this.button_cancel.Text = "取 消";
95
+            this.button_cancel.UseVisualStyleBackColor = true;
96
+            this.button_cancel.Click += new System.EventHandler(this.button_cancel_Click);
97
+            // 
98
+            // label3
99
+            // 
100
+            this.label3.AutoSize = true;
101
+            this.label3.Location = new System.Drawing.Point(45, 128);
102
+            this.label3.Name = "label3";
103
+            this.label3.Size = new System.Drawing.Size(52, 15);
104
+            this.label3.TabIndex = 8;
105
+            this.label3.Text = "密度:";
106
+            // 
107
+            // textBox_density
108
+            // 
109
+            this.textBox_density.Location = new System.Drawing.Point(103, 122);
110
+            this.textBox_density.Name = "textBox_density";
111
+            this.textBox_density.Size = new System.Drawing.Size(100, 25);
112
+            this.textBox_density.TabIndex = 9;
113
+            // 
114
+            // checkBox_upon
115
+            // 
116
+            this.checkBox_upon.AutoSize = true;
117
+            this.checkBox_upon.Location = new System.Drawing.Point(345, 124);
118
+            this.checkBox_upon.Name = "checkBox_upon";
119
+            this.checkBox_upon.Size = new System.Drawing.Size(89, 19);
120
+            this.checkBox_upon.TabIndex = 10;
121
+            this.checkBox_upon.Text = "大于密度";
122
+            this.checkBox_upon.UseVisualStyleBackColor = true;
123
+            // 
124
+            // checkBox_below
125
+            // 
126
+            this.checkBox_below.AutoSize = true;
127
+            this.checkBox_below.Location = new System.Drawing.Point(235, 124);
128
+            this.checkBox_below.Name = "checkBox_below";
129
+            this.checkBox_below.Size = new System.Drawing.Size(89, 19);
130
+            this.checkBox_below.TabIndex = 11;
131
+            this.checkBox_below.Text = "小于密度";
132
+            this.checkBox_below.UseVisualStyleBackColor = true;
133
+            // 
134
+            // EleptDensity
135
+            // 
136
+            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
137
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
138
+            this.ClientSize = new System.Drawing.Size(468, 219);
139
+            this.Controls.Add(this.checkBox_below);
140
+            this.Controls.Add(this.checkBox_upon);
141
+            this.Controls.Add(this.textBox_density);
142
+            this.Controls.Add(this.label3);
143
+            this.Controls.Add(this.button_cancel);
144
+            this.Controls.Add(this.button_ok);
145
+            this.Controls.Add(this.comboBox_gw);
146
+            this.Controls.Add(this.comboBox_ptLayer);
147
+            this.Controls.Add(this.label2);
148
+            this.Controls.Add(this.label1);
149
+            this.Name = "EleptDensity";
150
+            this.Text = "高程点密度检查";
151
+            this.Load += new System.EventHandler(this.EleptDensity_Load);
152
+            this.ResumeLayout(false);
153
+            this.PerformLayout();
154
+
155
+        }
156
+
157
+        #endregion
158
+
159
+        private System.Windows.Forms.Label label1;
160
+        private System.Windows.Forms.Label label2;
161
+        private System.Windows.Forms.ComboBox comboBox_ptLayer;
162
+        private System.Windows.Forms.ComboBox comboBox_gw;
163
+        private System.Windows.Forms.Button button_ok;
164
+        private System.Windows.Forms.Button button_cancel;
165
+        private System.Windows.Forms.Label label3;
166
+        private System.Windows.Forms.TextBox textBox_density;
167
+        private System.Windows.Forms.CheckBox checkBox_upon;
168
+        private System.Windows.Forms.CheckBox checkBox_below;
169
+    }
170
+}

+ 100
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/EleptDensity.cs 查看文件

@@ -0,0 +1,100 @@
1
+using Autodesk.AutoCAD.DatabaseServices;
2
+using System;
3
+using System.Collections.Generic;
4
+using System.ComponentModel;
5
+using System.Data;
6
+using System.Drawing;
7
+using System.Linq;
8
+using System.Text;
9
+using System.Threading.Tasks;
10
+using System.Windows.Forms;
11
+
12
+namespace CADTools
13
+{
14
+    public partial class EleptDensity : Form
15
+    {
16
+        public EleptDensity()
17
+        {
18
+            InitializeComponent();
19
+        }
20
+
21
+        private void EleptDensity_Load(object sender, EventArgs e)
22
+        {
23
+            this.comboBox_ptLayer.DropDownStyle = ComboBoxStyle.DropDownList;
24
+            this.comboBox_gw.DropDownStyle = ComboBoxStyle.DropDownList;
25
+
26
+            this.MaximizeBox = false;
27
+            this.StartPosition = FormStartPosition.CenterScreen;
28
+
29
+            //自动填充下拉框
30
+            Database database = Autodesk.AutoCAD.DatabaseServices.HostApplicationServices.WorkingDatabase;
31
+            using (Transaction traction = database.TransactionManager.StartTransaction())
32
+            {
33
+                //存放所有图层名
34
+                List<string> alllayername = new List<string>();
35
+                LayerTable layertable = traction.GetObject(database.LayerTableId, OpenMode.ForRead) as LayerTable;
36
+                foreach (ObjectId objid in layertable)
37
+                {
38
+                    LayerTableRecord layertablerecord = traction.GetObject(objid, OpenMode.ForRead) as LayerTableRecord;
39
+                    alllayername.Add(layertablerecord.Name);
40
+                }
41
+                alllayername.Sort();
42
+
43
+                for (int i = 0; i < alllayername.Count; i++)
44
+                {
45
+                    this.comboBox_ptLayer.Items.Add(alllayername[i]);
46
+                    this.comboBox_gw.Items.Add(alllayername[i]);
47
+                }
48
+
49
+                if (alllayername.Contains("8300"))
50
+                {
51
+                    int index = alllayername.IndexOf("8300");
52
+                    this.comboBox_ptLayer.SelectedIndex = index;
53
+                }
54
+                traction.Commit();
55
+            }
56
+        }
57
+
58
+        private void button_cancel_Click(object sender, EventArgs e)
59
+        {
60
+            this.Close();
61
+        }
62
+
63
+        private void button_ok_Click(object sender, EventArgs e)
64
+        {
65
+            if(comboBox_ptLayer.Text == "")
66
+            { 
67
+                MessageBox.Show("请选择高程点所在图层!");
68
+                return;
69
+            }
70
+            if (comboBox_gw.Text == "")
71
+            { 
72
+                MessageBox.Show("请选择格网所在图层!");
73
+                return;
74
+            }
75
+            if (textBox_density.Text == "")
76
+            {
77
+                MessageBox.Show("请输入密度!");
78
+                return;
79
+            }
80
+            EleptDenck.ptlayer = comboBox_ptLayer.Text;
81
+            EleptDenck.tklayer = comboBox_gw.Text;
82
+            EleptDenck.density = Convert.ToDouble(textBox_density.Text);
83
+            if(checkBox_below.Checked && !checkBox_upon.Checked)
84
+                EleptDenck.flag = 1;
85
+            else if (!checkBox_below.Checked && checkBox_upon.Checked)
86
+                EleptDenck.flag = 2;
87
+            else if(checkBox_below.Checked && checkBox_upon.Checked)
88
+                EleptDenck.flag = 3;
89
+            else if(!checkBox_below.Checked && !checkBox_upon.Checked)
90
+            { 
91
+                MessageBox.Show("请选择“大于密度”/“小于密度”!");
92
+                return;
93
+            }
94
+
95
+            EleptDenck denck = new EleptDenck();
96
+            denck.Ptdensity();
97
+            this.Close();
98
+        }
99
+    }
100
+}

+ 120
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/EleptDensity.resx 查看文件

@@ -0,0 +1,120 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<root>
3
+  <!-- 
4
+    Microsoft ResX Schema 
5
+    
6
+    Version 2.0
7
+    
8
+    The primary goals of this format is to allow a simple XML format 
9
+    that is mostly human readable. The generation and parsing of the 
10
+    various data types are done through the TypeConverter classes 
11
+    associated with the data types.
12
+    
13
+    Example:
14
+    
15
+    ... ado.net/XML headers & schema ...
16
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
17
+    <resheader name="version">2.0</resheader>
18
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
19
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
20
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
21
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
22
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
24
+    </data>
25
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
26
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
27
+        <comment>This is a comment</comment>
28
+    </data>
29
+                
30
+    There are any number of "resheader" rows that contain simple 
31
+    name/value pairs.
32
+    
33
+    Each data row contains a name, and value. The row also contains a 
34
+    type or mimetype. Type corresponds to a .NET class that support 
35
+    text/value conversion through the TypeConverter architecture. 
36
+    Classes that don't support this are serialized and stored with the 
37
+    mimetype set.
38
+    
39
+    The mimetype is used for serialized objects, and tells the 
40
+    ResXResourceReader how to depersist the object. This is currently not 
41
+    extensible. For a given mimetype the value must be set accordingly:
42
+    
43
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
44
+    that the ResXResourceWriter will generate, however the reader can 
45
+    read any of the formats listed below.
46
+    
47
+    mimetype: application/x-microsoft.net.object.binary.base64
48
+    value   : The object must be serialized with 
49
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
50
+            : and then encoded with base64 encoding.
51
+    
52
+    mimetype: application/x-microsoft.net.object.soap.base64
53
+    value   : The object must be serialized with 
54
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
55
+            : and then encoded with base64 encoding.
56
+
57
+    mimetype: application/x-microsoft.net.object.bytearray.base64
58
+    value   : The object must be serialized into a byte array 
59
+            : using a System.ComponentModel.TypeConverter
60
+            : and then encoded with base64 encoding.
61
+    -->
62
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
64
+    <xsd:element name="root" msdata:IsDataSet="true">
65
+      <xsd:complexType>
66
+        <xsd:choice maxOccurs="unbounded">
67
+          <xsd:element name="metadata">
68
+            <xsd:complexType>
69
+              <xsd:sequence>
70
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
71
+              </xsd:sequence>
72
+              <xsd:attribute name="name" use="required" type="xsd:string" />
73
+              <xsd:attribute name="type" type="xsd:string" />
74
+              <xsd:attribute name="mimetype" type="xsd:string" />
75
+              <xsd:attribute ref="xml:space" />
76
+            </xsd:complexType>
77
+          </xsd:element>
78
+          <xsd:element name="assembly">
79
+            <xsd:complexType>
80
+              <xsd:attribute name="alias" type="xsd:string" />
81
+              <xsd:attribute name="name" type="xsd:string" />
82
+            </xsd:complexType>
83
+          </xsd:element>
84
+          <xsd:element name="data">
85
+            <xsd:complexType>
86
+              <xsd:sequence>
87
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
88
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
89
+              </xsd:sequence>
90
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
91
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
92
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
93
+              <xsd:attribute ref="xml:space" />
94
+            </xsd:complexType>
95
+          </xsd:element>
96
+          <xsd:element name="resheader">
97
+            <xsd:complexType>
98
+              <xsd:sequence>
99
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
100
+              </xsd:sequence>
101
+              <xsd:attribute name="name" type="xsd:string" use="required" />
102
+            </xsd:complexType>
103
+          </xsd:element>
104
+        </xsd:choice>
105
+      </xsd:complexType>
106
+    </xsd:element>
107
+  </xsd:schema>
108
+  <resheader name="resmimetype">
109
+    <value>text/microsoft-resx</value>
110
+  </resheader>
111
+  <resheader name="version">
112
+    <value>2.0</value>
113
+  </resheader>
114
+  <resheader name="reader">
115
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116
+  </resheader>
117
+  <resheader name="writer">
118
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119
+  </resheader>
120
+</root>

+ 639
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/FeatureOverlap.cs 查看文件

@@ -0,0 +1,639 @@
1
+using Autodesk.AutoCAD.ApplicationServices;
2
+using Autodesk.AutoCAD.DatabaseServices;
3
+using Autodesk.AutoCAD.EditorInput;
4
+using Autodesk.AutoCAD.Geometry;
5
+using System;
6
+using System.Collections.Generic;
7
+using System.Linq;
8
+using System.Text;
9
+using System.Threading.Tasks;
10
+
11
+namespace CADTools
12
+{
13
+    class FeatureOverlap
14
+    {
15
+
16
+        //比例尺
17
+        public static int blc;
18
+        public static bool move;
19
+        //重叠地物数量
20
+        private int number = 0;
21
+        public void check()
22
+        {
23
+            LayerControl lc = new LayerControl();
24
+            if (lc.haslayername("地物重叠") == false)
25
+            {
26
+                lc.creatlayer("地物重叠", new colorgb(255, 0, 255));
27
+                lc.movelayertofront("地物重叠");
28
+            }
29
+            else
30
+            {
31
+                lc.movelayertofront("地物重叠");
32
+            }
33
+            //选择块
34
+            selecblock();
35
+            search(blocklist,entitylist);
36
+        }
37
+
38
+        /// <summary>
39
+        /// 定义一个块类,主要包括位置和名字
40
+        /// </summary>
41
+        public struct Block
42
+        {
43
+            public double x;
44
+            public double y;
45
+            public double z;
46
+            public string name;
47
+
48
+            public Block(double x, double y, double z, string name)
49
+            {
50
+                this.x = x;
51
+                this.y = y;
52
+                this.z = z;
53
+                this.name = name;
54
+            }
55
+        }
56
+
57
+        //块列表
58
+        private List<Block> blocklist = new List<Block>();
59
+        private List<Entity> entitylist = new List<Entity>();
60
+        private void selecblock()
61
+        {
62
+            Document document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
63
+            Database database = HostApplicationServices.WorkingDatabase;
64
+            DocumentLock documentlock = null;
65
+            Transaction traction = null;
66
+            try
67
+            {
68
+                traction = database.TransactionManager.StartTransaction();
69
+                documentlock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
70
+                BlockTable blocktable = traction.GetObject(database.BlockTableId,
71
+                                          OpenMode.ForRead) as BlockTable;
72
+                Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
73
+                TypedValue[] typedvalue = new TypedValue[1];
74
+                typedvalue.SetValue(new TypedValue((int)DxfCode.Start, "Insert"), 0);
75
+                SelectionFilter selectionfilter = new SelectionFilter(typedvalue);
76
+                PromptSelectionResult psr = editor.GetSelection(selectionfilter); ///手动选择块参照
77
+                //PromptSelectionResult psr = editor.SelectAll();
78
+                if (psr.Status == PromptStatus.OK)
79
+                {
80
+                    SelectionSet selectionset = psr.Value;
81
+                    ObjectId[] obj = new ObjectId[selectionset.Count];
82
+                    obj = selectionset.GetObjectIds();
83
+                    for (int i = 0; i < obj.Length; i++)
84
+                    {
85
+                        ObjectId objid = obj[i];
86
+                        Entity entity = (Entity)traction.GetObject(objid, OpenMode.ForWrite);
87
+                        if (entity is BlockReference)
88
+                        {
89
+                            BlockReference block = entity as BlockReference;
90
+                            ObjectId id = block.BlockTableRecord;
91
+                            BlockTableRecord blocktablerecord = traction.GetObject(id,
92
+                                                            OpenMode.ForRead) as BlockTableRecord;
93
+                            string blockname = blocktablerecord.Name.ToLower();
94
+                            Block blc = new Block();
95
+                            ///块参照的位置
96
+                            blc.x = block.Position.X;
97
+                            blc.y = block.Position.Y;
98
+                            blc.z = block.Position.Z;
99
+                            blc.name = blockname;
100
+                            ///块参照的名称
101
+                            switch (blockname)
102
+                            {
103
+                                case "gc028":
104
+                                case "gc090":
105
+                                case "gc110":
106
+                                case "gc111":
107
+                                case "gc119":
108
+                                case "gc120":
109
+                                case "gc121":
110
+                                case "gc122":
111
+                                case "gc124":
112
+                                case "gc125":
113
+                                case "gc126":
114
+                                case "gc143":
115
+                                case "gc144":
116
+                                case "gc145":
117
+                                case "gc160":
118
+                                case "gc163":
119
+                                case "gc164":
120
+                                case "gc165":
121
+                                case "gc200":
122
+                                case "gc205":
123
+                                case "gc206":
124
+                                case "gc207":
125
+                                case "gc208":
126
+                                case "gc210":
127
+                                case "gc211":
128
+                                case "gc213":
129
+                                case "gc246":
130
+                                case "gc251":
131
+                                case "gc253":
132
+                                case "gc254":
133
+                                case "gc319":
134
+                                case "gc320":
135
+                                case "gc322":
136
+                                case "gc323":
137
+                                case "gc325":
138
+                                case "gc326":
139
+                                    entitylist.Add(entity);
140
+                                    blocklist.Add(blc);
141
+                                    break;
142
+                                case "gc170":
143
+                                    if (block.Layer == "9000")
144
+                                    {
145
+                                        entitylist.Add(entity);
146
+                                        blocklist.Add(blc);
147
+                                    }
148
+                                    break;
149
+
150
+                                default:
151
+                                    break;
152
+                            }
153
+                        }
154
+                    }
155
+                    editor.WriteMessage("\n" + "选中块数量:" + blocklist.Count.ToString());
156
+                }
157
+                traction.Commit();
158
+            }
159
+            catch (Autodesk.AutoCAD.Runtime.Exception)
160
+            {
161
+                traction.Abort();
162
+                return;
163
+            }
164
+            finally
165
+            {
166
+                traction.Dispose();
167
+                documentlock.Dispose();
168
+            }
169
+        }
170
+
171
+
172
+        /// <summary>
173
+        /// 寻找与上面已选实体相交的那部分
174
+        /// </summary>
175
+        /// <param name="list"></param>
176
+        public void search(List<Block> list, List<Entity> list1)
177
+        {
178
+            Database database = HostApplicationServices.WorkingDatabase;
179
+            Transaction traction = null;
180
+            DocumentLock documentlock = null;
181
+            try
182
+            {
183
+                Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
184
+                for (int i = 0; i < list.Count; i++)
185
+                {
186
+                    double x = Math.Round((double)list[i].x, 3, MidpointRounding.AwayFromZero);
187
+                    double y = Math.Round((double)list[i].y, 3, MidpointRounding.AwayFromZero);
188
+                    Entity entity1 = list1[i];
189
+                    string name = list[i].name;
190
+                    rebound reb = get_boundary(name);
191
+                    double height = reb.height;
192
+                    double width = reb.width;
193
+                    int type = reb.type;
194
+                    ///按照比例尺决定大小
195
+                    if (blc == 1000)
196
+                    {
197
+                        height = height / 2;
198
+                        width = width / 2;
199
+                    }
200
+                    else if (blc == 500)
201
+                    {
202
+                        height = height / 4;
203
+                        width = width / 4;
204
+                    }
205
+                    else if (blc == 2000)
206
+                    {
207
+                        height = height * 1;
208
+                        width = width * 1;
209
+                    }
210
+                    ///是为了获得四个角,好框选整个图形
211
+                    Point3d p1 = new Point3d(x - width, y, 0);
212
+                    Point3d p2 = new Point3d(x + width, y, 0);
213
+                    Point3d p3 = new Point3d(x + width, y + height, 0);
214
+                    Point3d p4 = new Point3d(x - width, y + height, 0);
215
+                    if (type == 2)
216
+                    {
217
+                        p1 = new Point3d(x - width, y - height, 0);
218
+                        p2 = new Point3d(x + width, y - height, 0);
219
+                        p3 = new Point3d(x + width, y + height, 0);
220
+                        p4 = new Point3d(x - width, y + height, 0);
221
+                    }
222
+                    else if (type == 3)
223
+                    {
224
+                        p1 = new Point3d(x - width, y - height, 0);
225
+                        p2 = new Point3d(x + width, y - height, 0);
226
+                        p3 = new Point3d(x + width, y, 0);
227
+                        p4 = new Point3d(x - width, y, 0);
228
+                    }
229
+                    using (Transaction acTrans = database.TransactionManager.StartTransaction())
230
+                    {
231
+                        ViewTableRecord currview = editor.GetCurrentView();
232
+                        currview.CenterPoint = new Point2d(x, y);
233
+                        currview.ViewDirection = new Vector3d(0, 0, 1);
234
+                        currview.Width = 40;
235
+                        currview.Height = 40;
236
+                        editor.SetCurrentView(currview);
237
+                        acTrans.Commit();
238
+                    }
239
+
240
+                    PromptSelectionResult pselectresult = editor.SelectCrossingWindow(p1, p3);///框选范围内相交的实体
241
+                                                                                              ///如果有,按照类型对相交实体进行判断
242
+
243
+                    traction = database.TransactionManager.StartTransaction();
244
+                    documentlock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
245
+                    BlockTable blocktable = traction.GetObject(database.BlockTableId,
246
+                                                 OpenMode.ForRead) as BlockTable;
247
+                    BlockTableRecord blocktablerecord = traction.GetObject(blocktable[BlockTableRecord.ModelSpace],
248
+                                                    OpenMode.ForWrite) as BlockTableRecord;
249
+                    if (pselectresult.Status == PromptStatus.OK)
250
+                    {
251
+                        SelectionSet selectionset = pselectresult.Value;
252
+                        ObjectId[] obj = new ObjectId[selectionset.Count];
253
+                        obj = selectionset.GetObjectIds();
254
+                        int count = 0;
255
+                        for (int j = 0; j < obj.Length; j++)
256
+                        {
257
+                            ObjectId objid = obj[j];
258
+                            Entity entity = (Entity)traction.GetObject(objid, OpenMode.ForWrite);
259
+                            ///块参照
260
+                            if (entity is BlockReference)
261
+                            {
262
+                                BlockReference cblock = entity as BlockReference;
263
+                                ObjectId cid = cblock.BlockTableRecord;
264
+                                BlockTableRecord crecord = traction.GetObject(cid,
265
+                                                                OpenMode.ForRead) as BlockTableRecord;
266
+                                string blockname = crecord.Name.ToLower();
267
+                                if (blockname != "gc086")
268
+                                {
269
+                                    count++;
270
+                                }
271
+                            }
272
+                            ///文字
273
+                            else if (entity is DBText)
274
+                            {
275
+                                string layer = entity.Layer;
276
+                                if (layer != "0")
277
+                                {
278
+                                    if (entity1 is BlockReference)
279
+                                    {
280
+                                        BlockReference cblock = entity1 as BlockReference;
281
+                                        DBText txt = entity as DBText;
282
+                                        if (cblock.Position.Z.ToString("N1") != txt.TextString)
283
+                                            count++;
284
+                                    }
285
+                                }
286
+                            }
287
+                            ///线
288
+                            else if (entity is Polyline || entity is Polyline2d)
289
+                            {
290
+                                string layer = entity.Layer;
291
+                                if (layer == "4400" || layer == "6100" || layer == "4300" || layer == "2000")
292
+                                {
293
+                                    if (name != "gc200")
294
+                                    {
295
+                                        count++;
296
+                                    }
297
+                                }
298
+                            }
299
+
300
+                        }
301
+                        if (count > 1)
302
+                        {
303
+                            double height1 = 2 * height;
304
+                            Point3d orip = new Point3d(x, y, 0);
305
+                            Point3d newp = new Point3d(x, y + height1, 0);
306
+                            if (name == "gc120" || name == "gc119" || name == "gc126" || name == "gc123" || name == "gc325" || name == "gc205"
307
+                                     || name == "gc206" || name == "gc207" || name == "gc125" || name == "gc165" || name == "gc326" || name == "gc170"
308
+                                     || name == "gc160" || name == "gc246" || name == "gc208" || name == "gc121" || name == "gc163" || name == "gc164"
309
+                                     || name == "gc090" || name == "gc124" || name == "gc379")
310
+                            {
311
+                                if (entity1.IsWriteEnabled == true&&move)
312
+                                {
313
+                                    Move(entity1, orip, newp);
314
+                                    double px1 = p1.X;
315
+                                    double py1 = p1.Y;
316
+                                    double px2 = p2.X;
317
+                                    double py2 = p2.Y;
318
+                                    double px3 = p3.X;
319
+                                    double py3 = p3.Y;
320
+                                    double px4 = p4.X;
321
+                                    double py4 = p4.Y;
322
+                                    p1 = new Point3d(px1, py1 + height1, 0);
323
+                                    p2 = new Point3d(px2, py2 + height1, 0);
324
+                                    p3 = new Point3d(px3, py3 + height1, 0);
325
+                                    p4 = new Point3d(px4, py4 + height1, 0);
326
+                                    Point3dCollection coll = new Point3dCollection();
327
+                                    coll.Add(p1);
328
+                                    coll.Add(p2);
329
+                                    coll.Add(p3);
330
+                                    coll.Add(p4);
331
+                                    Polyline2d line2d = new Polyline2d(Poly2dType.SimplePoly, coll, 0, true, 0, 0, null);
332
+                                    line2d.SetDatabaseDefaults();
333
+                                    line2d.Layer = "地物重叠";
334
+                                    blocktablerecord.AppendEntity(line2d);
335
+                                    traction.AddNewlyCreatedDBObject(line2d, true);
336
+                                }
337
+                                else
338
+                                {
339
+                                    double px1 = p1.X;
340
+                                    double py1 = p1.Y;
341
+                                    double px2 = p2.X;
342
+                                    double py2 = p2.Y;
343
+                                    double px3 = p3.X;
344
+                                    double py3 = p3.Y;
345
+                                    double px4 = p4.X;
346
+                                    double py4 = p4.Y;
347
+                                    p1 = new Point3d(px1, py1, 0);
348
+                                    p2 = new Point3d(px2, py2, 0);
349
+                                    p3 = new Point3d(px3, py3, 0);
350
+                                    p4 = new Point3d(px4, py4, 0);
351
+                                    Point3dCollection coll = new Point3dCollection();
352
+                                    coll.Add(p1);
353
+                                    coll.Add(p2);
354
+                                    coll.Add(p3);
355
+                                    coll.Add(p4);
356
+                                    Polyline2d line2d = new Polyline2d(Poly2dType.SimplePoly, coll, 0, true, 0, 0, null);
357
+                                    line2d.SetDatabaseDefaults();
358
+                                    line2d.Layer = "地物重叠";
359
+                                    blocktablerecord.AppendEntity(line2d);
360
+                                    traction.AddNewlyCreatedDBObject(line2d, true);
361
+                                }
362
+                            }
363
+                            
364
+                            
365
+                            number++;
366
+                        }
367
+                    }
368
+                    traction.Commit();
369
+                }
370
+                editor.WriteMessage("\n");
371
+                editor.WriteMessage("检测到重叠地物:" + number);
372
+                editor.WriteMessage("\n");
373
+                number = 0;
374
+            }
375
+            catch (Autodesk.AutoCAD.Runtime.Exception)
376
+            {
377
+                traction.Abort();
378
+                return;
379
+            }
380
+            finally
381
+            {
382
+                if (documentlock != null)
383
+                {
384
+                    documentlock.Dispose();
385
+                }
386
+                if (traction != null)
387
+                {
388
+                    traction.Dispose();
389
+                }
390
+            }
391
+        }
392
+
393
+        /// <summary>
394
+        /// type=1表示图形为上半部分,type=2表示图形为上下两部分,type=3表示下半部分(中心点跟图形的关系)
395
+        /// </summary>
396
+        private struct rebound
397
+        {
398
+            public double height;
399
+            public double width;
400
+            public int type;
401
+
402
+            public rebound(double height, double width, int type)
403
+            {
404
+                this.height = height;
405
+                this.width = width;
406
+                this.type = type;
407
+            }
408
+        }
409
+
410
+        /// <summary>
411
+        /// 对每个地物图标的大小进行绘制
412
+        /// </summary>
413
+        /// <param name="name"></param>
414
+        /// <returns></returns>
415
+        private rebound get_boundary(string name)
416
+        {
417
+            double height = 0;
418
+            double width = 0;
419
+            int type = 0;
420
+
421
+            switch (name)
422
+            {
423
+                case "gc028":
424
+                    height = 5;
425
+                    width = 4;
426
+                    type = 2;
427
+                    break;
428
+                case "gc090":
429
+                    height = 2.5;
430
+                    width = 2.5;
431
+                    type = 2;
432
+                    break;
433
+                //case "gc110":
434
+                //    height = 4;
435
+                //    width = 4;
436
+                //    type = 2;
437
+                //    break;
438
+
439
+                //case "gc111":
440
+                //    height = 4;
441
+                //    width = 4;
442
+                //    type = 2;
443
+                //    break;
444
+
445
+                case "gc119":
446
+                    height = 2.6;
447
+                    width = 2.6;
448
+                    type = 1;
449
+                    break;
450
+                case "gc120":
451
+                    height = 5;
452
+                    width = 1;
453
+                    type = 1;
454
+                    break;
455
+                case "gc121":
456
+                    height = 1.1;
457
+                    width = 1.1;
458
+                    type = 2;
459
+                    break;
460
+                case "gc122":
461
+                    height = 2.1;
462
+                    width = 1.1;
463
+                    type = 2;
464
+                    break;
465
+                case "gc123":
466
+                    height = 4.2;
467
+                    width = 2.1;
468
+                    type = 2;
469
+                    break;
470
+                case "gc124":
471
+                    height = 3;
472
+                    width = 1.5;
473
+                    type = 1;
474
+                    break;
475
+                case "gc125":
476
+                    height = 3.8;
477
+                    width = 1.2;
478
+                    type = 2;
479
+                    break;
480
+                case "gc126":
481
+                    height = 2.5;
482
+                    width = 3;
483
+                    type = 2;
484
+                    break;
485
+                case "gc143":
486
+                    height = 6;
487
+                    width = 2;
488
+                    type = 1;
489
+                    break;
490
+                case "gc144":
491
+                    height = 6;
492
+                    width = 2;
493
+                    type = 1;
494
+                    break;
495
+                case "gc145":
496
+                    height = 6;
497
+                    width = 2;
498
+                    type = 1;
499
+                    break;
500
+                case "gc160":
501
+                    height = 4.7;
502
+                    width = 4.7;
503
+                    type = 2;
504
+                    break;
505
+                case "gc163":
506
+                    height = 0.6;
507
+                    width = 2.5;
508
+                    type = 2;
509
+                    break;
510
+                case "gc164":
511
+                    height = 0.7;
512
+                    width = 0.7;
513
+                    type = 2;
514
+                    break;
515
+                case "gc165":
516
+                    height = 5;
517
+                    width = 1;
518
+                    type = 2;
519
+                    break;
520
+                case "gc170":
521
+                    height = 1.1;
522
+                    width = 1.1;
523
+                    type = 2;
524
+                    break;
525
+                case "gc200":
526
+                    height = 1.5;
527
+                    width = 1.5;
528
+                    type = 2;
529
+                    break;
530
+                case "gc205":
531
+                    height = 5;
532
+                    width = 2;
533
+                    type = 1;
534
+                    break;
535
+                case "gc206":
536
+                    height = 5;
537
+                    width = 2;
538
+                    type = 1;
539
+                    break;
540
+                case "gc207":
541
+                    height = 4;
542
+                    width = 1;
543
+                    type = 2;
544
+                    break;
545
+                case "gc208":
546
+                    height = 1.6;
547
+                    width = 2.4;
548
+                    type = 2;
549
+                    break;
550
+                case "gc210":
551
+                    height = 6;
552
+                    width = 2.2;
553
+                    type = 1;
554
+                    break;
555
+                case "gc211":
556
+                    height = 3;
557
+                    width = 2.8;
558
+                    type = 3;
559
+                    break;
560
+                case "gc212":
561
+                    height = 5;
562
+                    width = 2.6;
563
+                    type = 1;
564
+                    break;
565
+                case "gc246":
566
+                    height = 6;
567
+                    width = 4;
568
+                    type = 1;
569
+                    break;
570
+                case "gc251":
571
+                    height = 1;
572
+                    width = 3.5;
573
+                    type = 2;
574
+                    break;
575
+                case "gc253":
576
+                    height = 0.7;
577
+                    width = 0.7;
578
+                    type = 2;
579
+                    break;
580
+                case "gc254":
581
+                    height = 3;
582
+                    width = 2.5;
583
+                    type = 2;
584
+                    break;
585
+                case "gc319":
586
+                    height = 6;
587
+                    width = 2;
588
+                    type = 1;
589
+                    break;
590
+                case "gc320":
591
+                    height = 6;
592
+                    width = 2;
593
+                    type = 1;
594
+                    break;
595
+                case "gc322":
596
+                    height = 6;
597
+                    width = 2;
598
+                    type = 1;
599
+                    break;
600
+                case "gc323":
601
+                    height = 4;
602
+                    width = 1.1;
603
+                    type = 1;
604
+                    break;
605
+                case "gc325":
606
+                    height = 5;
607
+                    width = 0.7;
608
+                    type = 1;
609
+                    break;
610
+                case "gc326":
611
+                    height = 1.6;
612
+                    width = 1.6;
613
+                    type = 2;
614
+                    break;
615
+
616
+                default:
617
+                    height = 2.5;
618
+                    width = 2;
619
+                    type = 2;
620
+                    break;
621
+            }
622
+            rebound rec = new rebound(height, width, type);
623
+            return rec;
624
+        }
625
+
626
+        /// <summary>
627
+        /// 指定基点与目标点移动实体
628
+        /// </summary>
629
+        /// <param name="ent">实体对象</param>
630
+        /// <param name="BasePt">基点</param>
631
+        /// <param name="TargetPt">目标点</param>
632
+        public static void Move(Entity ent, Point3d basePt, Point3d targetPt)
633
+        {
634
+            Vector3d vec = targetPt - basePt;
635
+            Matrix3d mt = Matrix3d.Displacement(vec);
636
+            ent.TransformBy(mt);
637
+        }
638
+    }
639
+}

+ 3
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/FodyWeavers.xml 查看文件

@@ -0,0 +1,3 @@
1
+<Weavers xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="FodyWeavers.xsd">
2
+  <Costura />
3
+</Weavers>

+ 111
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/FodyWeavers.xsd 查看文件

@@ -0,0 +1,111 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
3
+  <!-- This file was generated by Fody. Manual changes to this file will be lost when your project is rebuilt. -->
4
+  <xs:element name="Weavers">
5
+    <xs:complexType>
6
+      <xs:all>
7
+        <xs:element name="Costura" minOccurs="0" maxOccurs="1">
8
+          <xs:complexType>
9
+            <xs:all>
10
+              <xs:element minOccurs="0" maxOccurs="1" name="ExcludeAssemblies" type="xs:string">
11
+                <xs:annotation>
12
+                  <xs:documentation>A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with line breaks</xs:documentation>
13
+                </xs:annotation>
14
+              </xs:element>
15
+              <xs:element minOccurs="0" maxOccurs="1" name="IncludeAssemblies" type="xs:string">
16
+                <xs:annotation>
17
+                  <xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with line breaks.</xs:documentation>
18
+                </xs:annotation>
19
+              </xs:element>
20
+              <xs:element minOccurs="0" maxOccurs="1" name="Unmanaged32Assemblies" type="xs:string">
21
+                <xs:annotation>
22
+                  <xs:documentation>A list of unmanaged 32 bit assembly names to include, delimited with line breaks.</xs:documentation>
23
+                </xs:annotation>
24
+              </xs:element>
25
+              <xs:element minOccurs="0" maxOccurs="1" name="Unmanaged64Assemblies" type="xs:string">
26
+                <xs:annotation>
27
+                  <xs:documentation>A list of unmanaged 64 bit assembly names to include, delimited with line breaks.</xs:documentation>
28
+                </xs:annotation>
29
+              </xs:element>
30
+              <xs:element minOccurs="0" maxOccurs="1" name="PreloadOrder" type="xs:string">
31
+                <xs:annotation>
32
+                  <xs:documentation>The order of preloaded assemblies, delimited with line breaks.</xs:documentation>
33
+                </xs:annotation>
34
+              </xs:element>
35
+            </xs:all>
36
+            <xs:attribute name="CreateTemporaryAssemblies" type="xs:boolean">
37
+              <xs:annotation>
38
+                <xs:documentation>This will copy embedded files to disk before loading them into memory. This is helpful for some scenarios that expected an assembly to be loaded from a physical file.</xs:documentation>
39
+              </xs:annotation>
40
+            </xs:attribute>
41
+            <xs:attribute name="IncludeDebugSymbols" type="xs:boolean">
42
+              <xs:annotation>
43
+                <xs:documentation>Controls if .pdbs for reference assemblies are also embedded.</xs:documentation>
44
+              </xs:annotation>
45
+            </xs:attribute>
46
+            <xs:attribute name="DisableCompression" type="xs:boolean">
47
+              <xs:annotation>
48
+                <xs:documentation>Embedded assemblies are compressed by default, and uncompressed when they are loaded. You can turn compression off with this option.</xs:documentation>
49
+              </xs:annotation>
50
+            </xs:attribute>
51
+            <xs:attribute name="DisableCleanup" type="xs:boolean">
52
+              <xs:annotation>
53
+                <xs:documentation>As part of Costura, embedded assemblies are no longer included as part of the build. This cleanup can be turned off.</xs:documentation>
54
+              </xs:annotation>
55
+            </xs:attribute>
56
+            <xs:attribute name="LoadAtModuleInit" type="xs:boolean">
57
+              <xs:annotation>
58
+                <xs:documentation>Costura by default will load as part of the module initialization. This flag disables that behavior. Make sure you call CosturaUtility.Initialize() somewhere in your code.</xs:documentation>
59
+              </xs:annotation>
60
+            </xs:attribute>
61
+            <xs:attribute name="IgnoreSatelliteAssemblies" type="xs:boolean">
62
+              <xs:annotation>
63
+                <xs:documentation>Costura will by default use assemblies with a name like 'resources.dll' as a satellite resource and prepend the output path. This flag disables that behavior.</xs:documentation>
64
+              </xs:annotation>
65
+            </xs:attribute>
66
+            <xs:attribute name="ExcludeAssemblies" type="xs:string">
67
+              <xs:annotation>
68
+                <xs:documentation>A list of assembly names to exclude from the default action of "embed all Copy Local references", delimited with |</xs:documentation>
69
+              </xs:annotation>
70
+            </xs:attribute>
71
+            <xs:attribute name="IncludeAssemblies" type="xs:string">
72
+              <xs:annotation>
73
+                <xs:documentation>A list of assembly names to include from the default action of "embed all Copy Local references", delimited with |.</xs:documentation>
74
+              </xs:annotation>
75
+            </xs:attribute>
76
+            <xs:attribute name="Unmanaged32Assemblies" type="xs:string">
77
+              <xs:annotation>
78
+                <xs:documentation>A list of unmanaged 32 bit assembly names to include, delimited with |.</xs:documentation>
79
+              </xs:annotation>
80
+            </xs:attribute>
81
+            <xs:attribute name="Unmanaged64Assemblies" type="xs:string">
82
+              <xs:annotation>
83
+                <xs:documentation>A list of unmanaged 64 bit assembly names to include, delimited with |.</xs:documentation>
84
+              </xs:annotation>
85
+            </xs:attribute>
86
+            <xs:attribute name="PreloadOrder" type="xs:string">
87
+              <xs:annotation>
88
+                <xs:documentation>The order of preloaded assemblies, delimited with |.</xs:documentation>
89
+              </xs:annotation>
90
+            </xs:attribute>
91
+          </xs:complexType>
92
+        </xs:element>
93
+      </xs:all>
94
+      <xs:attribute name="VerifyAssembly" type="xs:boolean">
95
+        <xs:annotation>
96
+          <xs:documentation>'true' to run assembly verification (PEVerify) on the target assembly after all weavers have been executed.</xs:documentation>
97
+        </xs:annotation>
98
+      </xs:attribute>
99
+      <xs:attribute name="VerifyIgnoreCodes" type="xs:string">
100
+        <xs:annotation>
101
+          <xs:documentation>A comma-separated list of error codes that can be safely ignored in assembly verification.</xs:documentation>
102
+        </xs:annotation>
103
+      </xs:attribute>
104
+      <xs:attribute name="GenerateXsd" type="xs:boolean">
105
+        <xs:annotation>
106
+          <xs:documentation>'false' to turn off automatic generation of the XML Schema file.</xs:documentation>
107
+        </xs:annotation>
108
+      </xs:attribute>
109
+    </xs:complexType>
110
+  </xs:element>
111
+</xs:schema>

+ 136
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/GCDdelete_Form.Designer.cs 查看文件

@@ -0,0 +1,136 @@
1
+
2
+namespace CADTools
3
+{
4
+    partial class GCDdelete_Form
5
+    {
6
+        /// <summary>
7
+        /// Required designer variable.
8
+        /// </summary>
9
+        private System.ComponentModel.IContainer components = null;
10
+
11
+        /// <summary>
12
+        /// Clean up any resources being used.
13
+        /// </summary>
14
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
15
+        protected override void Dispose(bool disposing)
16
+        {
17
+            if (disposing && (components != null))
18
+            {
19
+                components.Dispose();
20
+            }
21
+            base.Dispose(disposing);
22
+        }
23
+
24
+        #region Windows Form Designer generated code
25
+
26
+        /// <summary>
27
+        /// Required method for Designer support - do not modify
28
+        /// the contents of this method with the code editor.
29
+        /// </summary>
30
+        private void InitializeComponent()
31
+        {
32
+            this.label1 = new System.Windows.Forms.Label();
33
+            this.comboBox1 = new System.Windows.Forms.ComboBox();
34
+            this.button1 = new System.Windows.Forms.Button();
35
+            this.label2 = new System.Windows.Forms.Label();
36
+            this.comboBox_blc = new System.Windows.Forms.ComboBox();
37
+            this.textBox_dgj = new System.Windows.Forms.TextBox();
38
+            this.label3 = new System.Windows.Forms.Label();
39
+            this.SuspendLayout();
40
+            // 
41
+            // label1
42
+            // 
43
+            this.label1.AutoSize = true;
44
+            this.label1.Location = new System.Drawing.Point(51, 85);
45
+            this.label1.Name = "label1";
46
+            this.label1.Size = new System.Drawing.Size(127, 15);
47
+            this.label1.TabIndex = 0;
48
+            this.label1.Text = "高程点所在图层:";
49
+            // 
50
+            // comboBox1
51
+            // 
52
+            this.comboBox1.FormattingEnabled = true;
53
+            this.comboBox1.Location = new System.Drawing.Point(184, 82);
54
+            this.comboBox1.Name = "comboBox1";
55
+            this.comboBox1.Size = new System.Drawing.Size(172, 23);
56
+            this.comboBox1.TabIndex = 1;
57
+            // 
58
+            // button1
59
+            // 
60
+            this.button1.Location = new System.Drawing.Point(175, 181);
61
+            this.button1.Name = "button1";
62
+            this.button1.Size = new System.Drawing.Size(67, 29);
63
+            this.button1.TabIndex = 2;
64
+            this.button1.Text = "确 定";
65
+            this.button1.UseVisualStyleBackColor = true;
66
+            this.button1.Click += new System.EventHandler(this.button1_Click);
67
+            // 
68
+            // label2
69
+            // 
70
+            this.label2.AutoSize = true;
71
+            this.label2.Location = new System.Drawing.Point(112, 41);
72
+            this.label2.Name = "label2";
73
+            this.label2.Size = new System.Drawing.Size(67, 15);
74
+            this.label2.TabIndex = 3;
75
+            this.label2.Text = "比例尺:";
76
+            // 
77
+            // comboBox_blc
78
+            // 
79
+            this.comboBox_blc.FormattingEnabled = true;
80
+            this.comboBox_blc.Items.AddRange(new object[] {
81
+            "1:500",
82
+            "1:2000",
83
+            "1:5000",
84
+            "1:10000"});
85
+            this.comboBox_blc.Location = new System.Drawing.Point(185, 38);
86
+            this.comboBox_blc.Name = "comboBox_blc";
87
+            this.comboBox_blc.Size = new System.Drawing.Size(172, 23);
88
+            this.comboBox_blc.TabIndex = 4;
89
+            // 
90
+            // textBox_dgj
91
+            // 
92
+            this.textBox_dgj.Location = new System.Drawing.Point(185, 128);
93
+            this.textBox_dgj.Name = "textBox_dgj";
94
+            this.textBox_dgj.Size = new System.Drawing.Size(100, 25);
95
+            this.textBox_dgj.TabIndex = 5;
96
+            // 
97
+            // label3
98
+            // 
99
+            this.label3.AutoSize = true;
100
+            this.label3.Location = new System.Drawing.Point(118, 131);
101
+            this.label3.Name = "label3";
102
+            this.label3.Size = new System.Drawing.Size(60, 15);
103
+            this.label3.TabIndex = 6;
104
+            this.label3.Text = "等高距:";
105
+            // 
106
+            // GCDdelete_Form
107
+            // 
108
+            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
109
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
110
+            this.ClientSize = new System.Drawing.Size(427, 237);
111
+            this.Controls.Add(this.label3);
112
+            this.Controls.Add(this.textBox_dgj);
113
+            this.Controls.Add(this.comboBox_blc);
114
+            this.Controls.Add(this.label2);
115
+            this.Controls.Add(this.button1);
116
+            this.Controls.Add(this.comboBox1);
117
+            this.Controls.Add(this.label1);
118
+            this.Name = "GCDdelete_Form";
119
+            this.Text = "删除整数值高程点";
120
+            this.Load += new System.EventHandler(this.GCDdelete_Form_Load);
121
+            this.ResumeLayout(false);
122
+            this.PerformLayout();
123
+
124
+        }
125
+
126
+        #endregion
127
+
128
+        private System.Windows.Forms.Label label1;
129
+        private System.Windows.Forms.ComboBox comboBox1;
130
+        private System.Windows.Forms.Button button1;
131
+        private System.Windows.Forms.Label label2;
132
+        private System.Windows.Forms.ComboBox comboBox_blc;
133
+        private System.Windows.Forms.TextBox textBox_dgj;
134
+        private System.Windows.Forms.Label label3;
135
+    }
136
+}

+ 177
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/GCDdelete_Form.cs 查看文件

@@ -0,0 +1,177 @@
1
+using Autodesk.AutoCAD.ApplicationServices;
2
+using Autodesk.AutoCAD.DatabaseServices;
3
+using Autodesk.AutoCAD.EditorInput;
4
+using Autodesk.AutoCAD.Geometry;
5
+using System;
6
+using System.Collections.Generic;
7
+using System.ComponentModel;
8
+using System.Data;
9
+using System.Drawing;
10
+using System.Linq;
11
+using System.Text;
12
+using System.Threading.Tasks;
13
+using System.Windows.Forms;
14
+
15
+namespace CADTools
16
+{
17
+    public partial class GCDdelete_Form : Form
18
+    {
19
+        public GCDdelete_Form()
20
+        {
21
+            InitializeComponent();
22
+        }
23
+        string lyr = "";
24
+        int blc = -999;
25
+
26
+        private void GCDdelete_Form_Load(object sender, EventArgs e)
27
+        {
28
+            this.comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
29
+            this.comboBox_blc.DropDownStyle = ComboBoxStyle.DropDownList;
30
+
31
+            //自动填充下拉框
32
+            Database database = Autodesk.AutoCAD.DatabaseServices.HostApplicationServices.WorkingDatabase;
33
+            using (Transaction traction = database.TransactionManager.StartTransaction())
34
+            {
35
+                //存放所有图层名
36
+                List<string> alllayername = new List<string>();
37
+                LayerTable layertable = traction.GetObject(database.LayerTableId, OpenMode.ForRead) as LayerTable;
38
+                foreach (ObjectId objid in layertable)
39
+                {
40
+                    LayerTableRecord layertablerecord = traction.GetObject(objid, OpenMode.ForRead) as LayerTableRecord;
41
+                    alllayername.Add(layertablerecord.Name);
42
+                }
43
+
44
+                alllayername.Sort();
45
+
46
+                for (int i = 0; i < alllayername.Count; i++)
47
+                {
48
+                    this.comboBox1.Items.Add(alllayername[i]);
49
+                }
50
+
51
+                if (alllayername.Contains("8300"))
52
+                {
53
+                    int index = alllayername.IndexOf("8300");
54
+                    this.comboBox1.SelectedIndex = index;
55
+                }
56
+                traction.Commit();
57
+            }
58
+        }
59
+
60
+        private void button1_Click(object sender, EventArgs e)
61
+        {
62
+            if (comboBox1.Text == "")
63
+            {
64
+                MessageBox.Show("请选择高程点所在图层!");
65
+                return;
66
+            }
67
+            if (comboBox_blc.Text == "")
68
+            {
69
+                MessageBox.Show("请选择比例尺!");
70
+                return;
71
+            }
72
+            if (textBox_dgj.Text == "")
73
+            {
74
+                MessageBox.Show("请输入等高距!");
75
+                return;
76
+            }
77
+            string blctext = comboBox_blc.Text;
78
+            int blcindex = blctext.LastIndexOf(':');
79
+            string strblc = blctext.Substring(blcindex + 1);
80
+            blc = Convert.ToInt32(strblc);
81
+            lyr = comboBox1.Text;
82
+            deletegcd();
83
+            this.Close();
84
+        }
85
+
86
+        private void deletegcd()
87
+        {
88
+            double dgj = Convert.ToDouble(textBox_dgj.Text);
89
+            Database db = Autodesk.AutoCAD.DatabaseServices.HostApplicationServices.WorkingDatabase;
90
+            Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
91
+            //获取高程点
92
+            TypedValue[] typedvalue = new TypedValue[1];
93
+            typedvalue.SetValue(new TypedValue((int)DxfCode.LayerName, lyr), 0);
94
+            SelectionFilter selectionfilter = new SelectionFilter(typedvalue);
95
+            PromptSelectionResult psr = ed.SelectAll(selectionfilter);
96
+
97
+            if (psr.Status == PromptStatus.OK)
98
+            {
99
+                LayerControl layerscontrol = new LayerControl();
100
+                string layname = "整数值高程点";
101
+                if (layerscontrol.haslayername(layname) == false)
102
+                {
103
+                    colorgb col = new colorgb(255, 255, 0);
104
+                    layerscontrol.creatlayer(layname, col);
105
+                }
106
+
107
+
108
+                SelectionSet selectionset = psr.Value;
109
+                ObjectId[] obj = new ObjectId[selectionset.Count];
110
+                obj = selectionset.GetObjectIds();
111
+                for (int i = 0; i < obj.Length; i++)
112
+                {
113
+                    DocumentLock doclock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
114
+                    using (Transaction tran = db.TransactionManager.StartTransaction())
115
+                    {
116
+                        ObjectId objid = obj[i];
117
+
118
+                        //找到实体获取并判断高程
119
+                        Entity entity = (Entity)tran.GetObject(objid, OpenMode.ForWrite);
120
+
121
+                        if (entity is DBText)
122
+                        {
123
+                            DBText bref = (DBText)entity;
124
+                            //double z = Math.Round(Convert.ToDouble(bref.TextString), 2, MidpointRounding.AwayFromZero);
125
+                            double z = Convert.ToDouble(bref.TextString);
126
+                            //判断四舍五入后是否为整数
127
+                            if (z % dgj == 0)
128
+                            {
129
+                                bref.Layer = "整数值高程点";
130
+                                //获取高程点
131
+                                Point3d p1 = new Point3d(bref.Position.X - 4 * blc / 2000, bref.Position.Y - 4 * blc / 2000, 0);
132
+                                Point3d p2 = new Point3d(bref.Position.X + 4 * blc / 2000, bref.Position.Y + 4 * blc / 2000, 0);
133
+                                TypedValue[] typedvalue1 = new TypedValue[2];
134
+
135
+                                typedvalue1.SetValue(new TypedValue((int)DxfCode.Start, "INSERT"), 0);
136
+                                typedvalue1.SetValue(new TypedValue((int)DxfCode.LayerName, lyr), 1);
137
+
138
+                                SelectionFilter filter1 = new SelectionFilter(typedvalue1);
139
+                                PromptSelectionResult psr1 = ed.SelectCrossingWindow(p2, p1, filter1);
140
+
141
+                                if (psr1.Status == PromptStatus.OK)
142
+                                {
143
+                                    SelectionSet ss = psr1.Value;
144
+                                    ObjectId[] objids = new ObjectId[ss.Count];
145
+                                    objids = ss.GetObjectIds();
146
+                                    for (int ii = 0; ii < objids.Length; ii++)
147
+                                    {
148
+                                        ObjectId objid1 = objids[ii];
149
+                                        Entity ent = (Entity)tran.GetObject(objid1, OpenMode.ForWrite);
150
+                                        if (ent is BlockReference)
151
+                                        {
152
+                                            BlockReference pt = (BlockReference)ent;
153
+                                            int ws = 0;
154
+                                            if(bref.TextString.Contains('.'))
155
+                                            {
156
+                                                ws = bref.TextString.Split('.')[1].Length;
157
+                                                if (bref.TextString.Split('.')[1].All(c => c == '0'))
158
+                                                    ws = 0;
159
+                                            }
160
+                                            double ele = Math.Round(pt.Position.Z, ws, MidpointRounding.AwayFromZero);
161
+                                            if (z == ele)
162
+                                                pt.Layer = "整数值高程点";
163
+                                        }
164
+                                    }
165
+                                }
166
+                            }
167
+                        }
168
+                        tran.Commit();
169
+                    }
170
+                    doclock.Dispose();
171
+                }
172
+                ed.WriteMessage("删除完成\n");
173
+            }
174
+        }
175
+    }
176
+
177
+}

+ 120
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/GCDdelete_Form.resx 查看文件

@@ -0,0 +1,120 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<root>
3
+  <!-- 
4
+    Microsoft ResX Schema 
5
+    
6
+    Version 2.0
7
+    
8
+    The primary goals of this format is to allow a simple XML format 
9
+    that is mostly human readable. The generation and parsing of the 
10
+    various data types are done through the TypeConverter classes 
11
+    associated with the data types.
12
+    
13
+    Example:
14
+    
15
+    ... ado.net/XML headers & schema ...
16
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
17
+    <resheader name="version">2.0</resheader>
18
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
19
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
20
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
21
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
22
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
24
+    </data>
25
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
26
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
27
+        <comment>This is a comment</comment>
28
+    </data>
29
+                
30
+    There are any number of "resheader" rows that contain simple 
31
+    name/value pairs.
32
+    
33
+    Each data row contains a name, and value. The row also contains a 
34
+    type or mimetype. Type corresponds to a .NET class that support 
35
+    text/value conversion through the TypeConverter architecture. 
36
+    Classes that don't support this are serialized and stored with the 
37
+    mimetype set.
38
+    
39
+    The mimetype is used for serialized objects, and tells the 
40
+    ResXResourceReader how to depersist the object. This is currently not 
41
+    extensible. For a given mimetype the value must be set accordingly:
42
+    
43
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
44
+    that the ResXResourceWriter will generate, however the reader can 
45
+    read any of the formats listed below.
46
+    
47
+    mimetype: application/x-microsoft.net.object.binary.base64
48
+    value   : The object must be serialized with 
49
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
50
+            : and then encoded with base64 encoding.
51
+    
52
+    mimetype: application/x-microsoft.net.object.soap.base64
53
+    value   : The object must be serialized with 
54
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
55
+            : and then encoded with base64 encoding.
56
+
57
+    mimetype: application/x-microsoft.net.object.bytearray.base64
58
+    value   : The object must be serialized into a byte array 
59
+            : using a System.ComponentModel.TypeConverter
60
+            : and then encoded with base64 encoding.
61
+    -->
62
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
64
+    <xsd:element name="root" msdata:IsDataSet="true">
65
+      <xsd:complexType>
66
+        <xsd:choice maxOccurs="unbounded">
67
+          <xsd:element name="metadata">
68
+            <xsd:complexType>
69
+              <xsd:sequence>
70
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
71
+              </xsd:sequence>
72
+              <xsd:attribute name="name" use="required" type="xsd:string" />
73
+              <xsd:attribute name="type" type="xsd:string" />
74
+              <xsd:attribute name="mimetype" type="xsd:string" />
75
+              <xsd:attribute ref="xml:space" />
76
+            </xsd:complexType>
77
+          </xsd:element>
78
+          <xsd:element name="assembly">
79
+            <xsd:complexType>
80
+              <xsd:attribute name="alias" type="xsd:string" />
81
+              <xsd:attribute name="name" type="xsd:string" />
82
+            </xsd:complexType>
83
+          </xsd:element>
84
+          <xsd:element name="data">
85
+            <xsd:complexType>
86
+              <xsd:sequence>
87
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
88
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
89
+              </xsd:sequence>
90
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
91
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
92
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
93
+              <xsd:attribute ref="xml:space" />
94
+            </xsd:complexType>
95
+          </xsd:element>
96
+          <xsd:element name="resheader">
97
+            <xsd:complexType>
98
+              <xsd:sequence>
99
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
100
+              </xsd:sequence>
101
+              <xsd:attribute name="name" type="xsd:string" use="required" />
102
+            </xsd:complexType>
103
+          </xsd:element>
104
+        </xsd:choice>
105
+      </xsd:complexType>
106
+    </xsd:element>
107
+  </xsd:schema>
108
+  <resheader name="resmimetype">
109
+    <value>text/microsoft-resx</value>
110
+  </resheader>
111
+  <resheader name="version">
112
+    <value>2.0</value>
113
+  </resheader>
114
+  <resheader name="reader">
115
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116
+  </resheader>
117
+  <resheader name="writer">
118
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119
+  </resheader>
120
+</root>

+ 126
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/Hierak.Designer.cs 查看文件

@@ -0,0 +1,126 @@
1
+
2
+namespace CADTools
3
+{
4
+    partial class Hierak
5
+    {
6
+        /// <summary>
7
+        /// Required designer variable.
8
+        /// </summary>
9
+        private System.ComponentModel.IContainer components = null;
10
+
11
+        /// <summary>
12
+        /// Clean up any resources being used.
13
+        /// </summary>
14
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
15
+        protected override void Dispose(bool disposing)
16
+        {
17
+            if (disposing && (components != null))
18
+            {
19
+                components.Dispose();
20
+            }
21
+            base.Dispose(disposing);
22
+        }
23
+
24
+        #region Windows Form Designer generated code
25
+
26
+        /// <summary>
27
+        /// Required method for Designer support - do not modify
28
+        /// the contents of this method with the code editor.
29
+        /// </summary>
30
+        private void InitializeComponent()
31
+        {
32
+            this.comboBox_CrtLayer = new System.Windows.Forms.ComboBox();
33
+            this.label_CrtLayer = new System.Windows.Forms.Label();
34
+            this.textBox_Gap = new System.Windows.Forms.TextBox();
35
+            this.label_Gap = new System.Windows.Forms.Label();
36
+            this.btn_Cancel = new System.Windows.Forms.Button();
37
+            this.btn_OK = new System.Windows.Forms.Button();
38
+            this.SuspendLayout();
39
+            // 
40
+            // comboBox_CrtLayer
41
+            // 
42
+            this.comboBox_CrtLayer.BackColor = System.Drawing.SystemColors.Window;
43
+            this.comboBox_CrtLayer.FormattingEnabled = true;
44
+            this.comboBox_CrtLayer.Location = new System.Drawing.Point(204, 40);
45
+            this.comboBox_CrtLayer.Name = "comboBox_CrtLayer";
46
+            this.comboBox_CrtLayer.Size = new System.Drawing.Size(169, 23);
47
+            this.comboBox_CrtLayer.TabIndex = 7;
48
+            // 
49
+            // label_CrtLayer
50
+            // 
51
+            this.label_CrtLayer.AutoSize = true;
52
+            this.label_CrtLayer.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
53
+            this.label_CrtLayer.Location = new System.Drawing.Point(75, 43);
54
+            this.label_CrtLayer.Name = "label_CrtLayer";
55
+            this.label_CrtLayer.Size = new System.Drawing.Size(112, 15);
56
+            this.label_CrtLayer.TabIndex = 6;
57
+            this.label_CrtLayer.Text = "等高线所在图层";
58
+            // 
59
+            // textBox_Gap
60
+            // 
61
+            this.textBox_Gap.Location = new System.Drawing.Point(204, 97);
62
+            this.textBox_Gap.Name = "textBox_Gap";
63
+            this.textBox_Gap.Size = new System.Drawing.Size(169, 25);
64
+            this.textBox_Gap.TabIndex = 5;
65
+            // 
66
+            // label_Gap
67
+            // 
68
+            this.label_Gap.AutoSize = true;
69
+            this.label_Gap.Font = new System.Drawing.Font("宋体", 9F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(134)));
70
+            this.label_Gap.Location = new System.Drawing.Point(135, 100);
71
+            this.label_Gap.Name = "label_Gap";
72
+            this.label_Gap.Size = new System.Drawing.Size(52, 15);
73
+            this.label_Gap.TabIndex = 4;
74
+            this.label_Gap.Text = "等高距";
75
+            // 
76
+            // btn_Cancel
77
+            // 
78
+            this.btn_Cancel.Location = new System.Drawing.Point(283, 149);
79
+            this.btn_Cancel.Margin = new System.Windows.Forms.Padding(4);
80
+            this.btn_Cancel.Name = "btn_Cancel";
81
+            this.btn_Cancel.Size = new System.Drawing.Size(100, 29);
82
+            this.btn_Cancel.TabIndex = 34;
83
+            this.btn_Cancel.Text = "取 消";
84
+            this.btn_Cancel.UseVisualStyleBackColor = true;
85
+            this.btn_Cancel.Click += new System.EventHandler(this.btn_Cancel_Click);
86
+            // 
87
+            // btn_OK
88
+            // 
89
+            this.btn_OK.Location = new System.Drawing.Point(117, 149);
90
+            this.btn_OK.Margin = new System.Windows.Forms.Padding(4);
91
+            this.btn_OK.Name = "btn_OK";
92
+            this.btn_OK.Size = new System.Drawing.Size(100, 29);
93
+            this.btn_OK.TabIndex = 33;
94
+            this.btn_OK.Text = "确 定";
95
+            this.btn_OK.UseVisualStyleBackColor = true;
96
+            this.btn_OK.Click += new System.EventHandler(this.btn_OK_Click);
97
+            // 
98
+            // Hierak
99
+            // 
100
+            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
101
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
102
+            this.ClientSize = new System.Drawing.Size(500, 219);
103
+            this.Controls.Add(this.btn_Cancel);
104
+            this.Controls.Add(this.btn_OK);
105
+            this.Controls.Add(this.comboBox_CrtLayer);
106
+            this.Controls.Add(this.label_CrtLayer);
107
+            this.Controls.Add(this.textBox_Gap);
108
+            this.Controls.Add(this.label_Gap);
109
+            this.Name = "Hierak";
110
+            this.Text = "等高线分层";
111
+            this.Load += new System.EventHandler(this.Hierak_Load);
112
+            this.ResumeLayout(false);
113
+            this.PerformLayout();
114
+
115
+        }
116
+
117
+        #endregion
118
+
119
+        private System.Windows.Forms.ComboBox comboBox_CrtLayer;
120
+        private System.Windows.Forms.Label label_CrtLayer;
121
+        private System.Windows.Forms.TextBox textBox_Gap;
122
+        private System.Windows.Forms.Label label_Gap;
123
+        private System.Windows.Forms.Button btn_Cancel;
124
+        private System.Windows.Forms.Button btn_OK;
125
+    }
126
+}

+ 87
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/Hierak.cs 查看文件

@@ -0,0 +1,87 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.ComponentModel;
4
+using System.Data;
5
+using System.Drawing;
6
+using System.Linq;
7
+using System.Text;
8
+using System.Threading.Tasks;
9
+using System.Windows.Forms;
10
+
11
+using Autodesk.AutoCAD.EditorInput;
12
+using Autodesk.AutoCAD.DatabaseServices;
13
+using Autodesk.AutoCAD.Geometry;
14
+
15
+namespace CADTools
16
+{
17
+    public partial class Hierak : Form
18
+    {
19
+        public Hierak()
20
+        {
21
+            InitializeComponent();
22
+        }
23
+
24
+        private void Hierak_Load(object sender, EventArgs e)
25
+        {
26
+            this.comboBox_CrtLayer.DropDownStyle = ComboBoxStyle.DropDownList;
27
+
28
+            this.MaximizeBox = false;
29
+            this.StartPosition = FormStartPosition.CenterScreen;
30
+
31
+            Database database = Autodesk.AutoCAD.DatabaseServices.HostApplicationServices.WorkingDatabase;
32
+            using (Transaction traction = database.TransactionManager.StartTransaction())
33
+            {
34
+                //存放所有图层名
35
+                List<string> alllayername = new List<string>();
36
+                LayerTable layertable = traction.GetObject(database.LayerTableId, OpenMode.ForRead) as LayerTable;
37
+                foreach (ObjectId objid in layertable)
38
+                {
39
+                    LayerTableRecord layertablerecord = traction.GetObject(objid, OpenMode.ForRead) as LayerTableRecord;
40
+                    alllayername.Add(layertablerecord.Name);
41
+                }
42
+
43
+                alllayername.Sort();
44
+
45
+                for (int i = 0; i < alllayername.Count; i++)
46
+                {
47
+                    this.comboBox_CrtLayer.Items.Add(alllayername[i]);
48
+                }
49
+
50
+                if (alllayername.Contains("8110"))
51
+                {
52
+                    int index = alllayername.IndexOf("8110");
53
+                    this.comboBox_CrtLayer.SelectedIndex = index;
54
+                }
55
+                traction.Commit();
56
+            }
57
+        }
58
+
59
+        private void btn_OK_Click(object sender, EventArgs e)
60
+        {
61
+            if (textBox_Gap.Text == "")
62
+            {
63
+                Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("请输入等高距");
64
+                return;
65
+            }
66
+
67
+            if (comboBox_CrtLayer.Text == "")
68
+            {
69
+                Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("请选择当前等高线所在图层");
70
+                return;
71
+            }
72
+
73
+            Hierarchy.gap = Convert.ToInt32(textBox_Gap.Text.ToString());
74
+            Hierarchy.CrtLayerName = comboBox_CrtLayer.Text;
75
+
76
+
77
+            this.Close();
78
+            Hierarchy hier = new Hierarchy();
79
+            hier.hierarchy();
80
+        }
81
+
82
+        private void btn_Cancel_Click(object sender, EventArgs e)
83
+        {
84
+            this.Close();
85
+        }
86
+    }
87
+}

+ 120
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/Hierak.resx 查看文件

@@ -0,0 +1,120 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<root>
3
+  <!-- 
4
+    Microsoft ResX Schema 
5
+    
6
+    Version 2.0
7
+    
8
+    The primary goals of this format is to allow a simple XML format 
9
+    that is mostly human readable. The generation and parsing of the 
10
+    various data types are done through the TypeConverter classes 
11
+    associated with the data types.
12
+    
13
+    Example:
14
+    
15
+    ... ado.net/XML headers & schema ...
16
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
17
+    <resheader name="version">2.0</resheader>
18
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
19
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
20
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
21
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
22
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
24
+    </data>
25
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
26
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
27
+        <comment>This is a comment</comment>
28
+    </data>
29
+                
30
+    There are any number of "resheader" rows that contain simple 
31
+    name/value pairs.
32
+    
33
+    Each data row contains a name, and value. The row also contains a 
34
+    type or mimetype. Type corresponds to a .NET class that support 
35
+    text/value conversion through the TypeConverter architecture. 
36
+    Classes that don't support this are serialized and stored with the 
37
+    mimetype set.
38
+    
39
+    The mimetype is used for serialized objects, and tells the 
40
+    ResXResourceReader how to depersist the object. This is currently not 
41
+    extensible. For a given mimetype the value must be set accordingly:
42
+    
43
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
44
+    that the ResXResourceWriter will generate, however the reader can 
45
+    read any of the formats listed below.
46
+    
47
+    mimetype: application/x-microsoft.net.object.binary.base64
48
+    value   : The object must be serialized with 
49
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
50
+            : and then encoded with base64 encoding.
51
+    
52
+    mimetype: application/x-microsoft.net.object.soap.base64
53
+    value   : The object must be serialized with 
54
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
55
+            : and then encoded with base64 encoding.
56
+
57
+    mimetype: application/x-microsoft.net.object.bytearray.base64
58
+    value   : The object must be serialized into a byte array 
59
+            : using a System.ComponentModel.TypeConverter
60
+            : and then encoded with base64 encoding.
61
+    -->
62
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
64
+    <xsd:element name="root" msdata:IsDataSet="true">
65
+      <xsd:complexType>
66
+        <xsd:choice maxOccurs="unbounded">
67
+          <xsd:element name="metadata">
68
+            <xsd:complexType>
69
+              <xsd:sequence>
70
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
71
+              </xsd:sequence>
72
+              <xsd:attribute name="name" use="required" type="xsd:string" />
73
+              <xsd:attribute name="type" type="xsd:string" />
74
+              <xsd:attribute name="mimetype" type="xsd:string" />
75
+              <xsd:attribute ref="xml:space" />
76
+            </xsd:complexType>
77
+          </xsd:element>
78
+          <xsd:element name="assembly">
79
+            <xsd:complexType>
80
+              <xsd:attribute name="alias" type="xsd:string" />
81
+              <xsd:attribute name="name" type="xsd:string" />
82
+            </xsd:complexType>
83
+          </xsd:element>
84
+          <xsd:element name="data">
85
+            <xsd:complexType>
86
+              <xsd:sequence>
87
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
88
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
89
+              </xsd:sequence>
90
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
91
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
92
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
93
+              <xsd:attribute ref="xml:space" />
94
+            </xsd:complexType>
95
+          </xsd:element>
96
+          <xsd:element name="resheader">
97
+            <xsd:complexType>
98
+              <xsd:sequence>
99
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
100
+              </xsd:sequence>
101
+              <xsd:attribute name="name" type="xsd:string" use="required" />
102
+            </xsd:complexType>
103
+          </xsd:element>
104
+        </xsd:choice>
105
+      </xsd:complexType>
106
+    </xsd:element>
107
+  </xsd:schema>
108
+  <resheader name="resmimetype">
109
+    <value>text/microsoft-resx</value>
110
+  </resheader>
111
+  <resheader name="version">
112
+    <value>2.0</value>
113
+  </resheader>
114
+  <resheader name="reader">
115
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116
+  </resheader>
117
+  <resheader name="writer">
118
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119
+  </resheader>
120
+</root>

+ 91
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/Hierarchy.cs 查看文件

@@ -0,0 +1,91 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Threading.Tasks;
6
+
7
+using Autodesk.AutoCAD.ApplicationServices;
8
+using Autodesk.AutoCAD.DatabaseServices;
9
+using Autodesk.AutoCAD.EditorInput;
10
+
11
+
12
+namespace CADTools
13
+{
14
+    class Hierarchy
15
+    {
16
+        public static int gap;//等高距
17
+        public static string CrtLayerName;//当前等高线所在图层
18
+   
19
+        /// <summary>
20
+        /// 等高线分层
21
+        /// </summary>
22
+        public void hierarchy()
23
+        {
24
+            ObjectId[] ids = BasicFunction.getHeight(CrtLayerName);//存放获取的等高线id
25
+
26
+            //检查是否有计曲线图层,没有则创建
27
+            LayerControl layerscontrol = new LayerControl();
28
+            string Jilayname = "8120";
29
+            if (!layerscontrol.haslayername(Jilayname))
30
+            {
31
+                colorgb col = new colorgb(255, 255, 0);
32
+                layerscontrol.creatlayer(Jilayname, col);
33
+                layerscontrol.movelayertofront(Jilayname);
34
+            }
35
+            else
36
+                layerscontrol.movelayertofront(Jilayname);
37
+
38
+            //检查是否有首曲线图层,没有则创建
39
+            LayerControl layerscontrol1 = new LayerControl();
40
+            string Shoulayname = "8110";
41
+            if (!layerscontrol1.haslayername(Shoulayname))
42
+            {
43
+                colorgb col = new colorgb(0, 0, 0);
44
+                layerscontrol1.creatlayer(Shoulayname, col);
45
+                layerscontrol1.movelayertofront(Shoulayname);
46
+            }
47
+            else
48
+                layerscontrol1.movelayertofront(Shoulayname);
49
+
50
+
51
+            if (ids == null)
52
+                return;
53
+
54
+            for (int i = 0; i < ids.Length; i++)
55
+            {
56
+                Polyline pll = BasicFunction.GetDBObject(ids[i]) as Polyline;
57
+                if (Math.Round(pll.Elevation, 7, MidpointRounding.AwayFromZero) % (gap * 5) == 0 && pll.Layer != "8120")
58
+                {
59
+                    ChangeLayer(pll.Id, Jilayname);
60
+                }
61
+                if (Math.Round(pll.Elevation, 7, MidpointRounding.AwayFromZero) % (gap * 5) != 0 && pll.Layer != "8110")
62
+                {
63
+                    ChangeLayer(pll.Id, Shoulayname);
64
+                }
65
+                else
66
+                    continue;
67
+            }
68
+        }
69
+
70
+        
71
+
72
+
73
+        /// <summary>
74
+        /// 将计曲线移动到相应图层
75
+        /// </summary>
76
+        private void ChangeLayer(ObjectId c1Id, string LayerName)
77
+        {
78
+            Database db = HostApplicationServices.WorkingDatabase;
79
+            DocumentLock doclock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
80
+            using (Transaction trans = db.TransactionManager.StartTransaction())
81
+            {
82
+                BlockTable bt = (BlockTable)trans.GetObject(db.BlockTableId, OpenMode.ForRead);
83
+                BlockTableRecord btr = (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
84
+                Entity ent1 = (Entity)c1Id.GetObject(OpenMode.ForWrite);
85
+                ent1.Layer = LayerName;
86
+                trans.Commit();
87
+            }
88
+            doclock.Dispose();
89
+        }
90
+    }
91
+}

+ 229
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/InsertDOM.cs 查看文件

@@ -0,0 +1,229 @@
1
+using Autodesk.AutoCAD.ApplicationServices;
2
+using Autodesk.AutoCAD.DatabaseServices;
3
+using Autodesk.AutoCAD.EditorInput;
4
+using Autodesk.AutoCAD.Geometry;
5
+using Autodesk.AutoCAD.Runtime;
6
+using System;
7
+using System.Collections.Generic;
8
+using System.IO;
9
+using System.Linq;
10
+using System.Text;
11
+using System.Threading.Tasks;
12
+using System.Windows;
13
+using System.Windows.Forms;
14
+
15
+namespace CADTools
16
+{
17
+    public class InsertDOM
18
+    {
19
+        public static string dompath;//DOM文件所在位置
20
+        public static string dwgpath;//DWG文件所在位置
21
+        public void InsertDOMToCAD()
22
+        {
23
+            List<String> dwgname = GetNameList(dwgpath, ".dwg");//获取dwg文件
24
+            if (dwgname.Count == 0)
25
+            {
26
+                MessageBox.Show("没有找到dwg文件!", "警告");
27
+                return;
28
+            }
29
+            List<String> tifname = GetNameList(dompath, ".tif");//获取tif文件
30
+            tifname.AddRange(GetNameList(dompath, ".Tif"));
31
+            if (tifname.Count == 0)
32
+            {
33
+                MessageBox.Show("没有找到dom文件!", "警告");
34
+                return;
35
+            }
36
+            List<String> tfwname = new List<string>();//tfw文件
37
+            List<String> errolist = new List<string>();//无法找到对应tif的dwg文件
38
+            foreach (String name in tifname)
39
+            {
40
+                if (name.Contains("tif"))
41
+                    tfwname.Add(name.Replace(".tif", ".tfw"));
42
+                else
43
+                    tfwname.Add(name.Replace(".Tif", ".tfw"));
44
+            }
45
+            for (int filenum = 0; filenum < dwgname.Count; filenum++)
46
+            {
47
+                string dwg = dwgpath + "\\" + dwgname[filenum];
48
+                if(tifname.Contains(dwgname[filenum].Replace(".dwg", ".tif"))||
49
+                    tifname.Contains(dwgname[filenum].Replace(".dwg", ".Tif")))
50
+                {
51
+                    Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.Add(dwg);//将dwg添加到cad中
52
+                    for (int i = 0; i < tifname.Count; i++)
53
+                    {
54
+                        //筛选与dwg同名的tif,并将tif插入到dwg中
55
+                        if (tifname[i] == (dwgname[filenum].Replace(".dwg", ".tif"))||
56
+                            tifname[i] == (dwgname[filenum].Replace(".dwg", ".Tif")))
57
+                        {
58
+                            InsertDOMs(tifname[i], tfwname[i], doc);
59
+                            tifname.RemoveAt(i);
60
+                            tfwname.RemoveAt(i);
61
+                            break;
62
+                        }
63
+                    }
64
+                }
65
+                else
66
+                {
67
+                    errolist.Add(dwgname[filenum]);
68
+                }
69
+            }
70
+            if (errolist.Count == 0)
71
+                MessageBox.Show("所有DOM插入成功","提示");
72
+            else
73
+            {
74
+                string erromsg=string.Empty;
75
+                foreach(string dwg in errolist)
76
+                {
77
+                    erromsg += dwg+"\n";
78
+                }
79
+                MessageBox.Show(erromsg+"无法找到与之匹配的tif图,插入失败!","警告");
80
+            }
81
+        }
82
+
83
+
84
+        /// <summary>
85
+        /// 获取文件夹中相应格式的所有文件
86
+        /// </summary>
87
+        private static List<String> GetNameList(String filespath, String filetype)
88
+        {
89
+            DirectoryInfo root = new DirectoryInfo(filespath);
90
+            List<String> filename = new List<string>();     //文件名
91
+            FileInfo[] files = root.GetFiles();
92
+            foreach (FileInfo file in files)
93
+            {
94
+                if (file.Name.Substring(file.Name.Length - 4, 4) != filetype)
95
+                    continue;
96
+                else
97
+                    filename.Add(file.Name);
98
+            }
99
+            return filename;
100
+        }
101
+
102
+
103
+        /// <summary>
104
+        /// 插入DOM
105
+        /// </summary>
106
+        public void InsertDOMs(string tiffilename, string tfwfilename, Document doc)
107
+        {
108
+            Database db = doc.Database;
109
+            Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
110
+            ObjectIdCollection obidcoll = new ObjectIdCollection();
111
+            string imageName = new FileInfo(tiffilename).Name;
112
+            double scale = 0;
113
+            double X = 0, Y = 0;
114
+            try
115
+            {
116
+                StreamReader sr = new StreamReader(dompath + "\\" + tfwfilename);
117
+                scale = Convert.ToDouble(sr.ReadLine());
118
+                sr.ReadLine();
119
+                sr.ReadLine();
120
+                sr.ReadLine();
121
+                X = Convert.ToDouble(sr.ReadLine());
122
+                Y = Convert.ToDouble(sr.ReadLine());
123
+                sr.Close();
124
+                sr.Dispose();
125
+            }
126
+            catch (System.Exception ex)
127
+            {
128
+                MessageBox.Show("警告:" + tiffilename + "图像没有相应的.tfw文件或tfw文件出错,无法正确插入!\r\n\r\n");
129
+            }
130
+
131
+            using (DocumentLock docLock = doc.LockDocument())
132
+            {
133
+                using (Transaction tran = db.TransactionManager.StartTransaction())
134
+                {
135
+                    //建立名为DOM的图层
136
+                    LayerTable lt = tran.GetObject(db.LayerTableId, OpenMode.ForWrite) as LayerTable;
137
+                    try
138
+                    {
139
+                        if (!lt.Has("DOM"))
140
+                        {
141
+                            LayerTableRecord ltrec = new LayerTableRecord();
142
+                            ltrec.Name = "DOM";
143
+                            ObjectId obid = lt.Add(ltrec);
144
+                            tran.AddNewlyCreatedDBObject(ltrec, true);
145
+                        }
146
+                    }
147
+                    catch (Autodesk.AutoCAD.Runtime.Exception ex)
148
+                    {
149
+                        MessageBox.Show(ex.ToString());
150
+                    }
151
+                    tran.Commit();
152
+                }
153
+                using (Transaction tran = db.TransactionManager.StartTransaction())
154
+                {
155
+                    //插入DOM
156
+                    BlockTable blktbl = tran.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
157
+                    BlockTableRecord blktblrec = tran.GetObject(blktbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
158
+                    DrawOrderTable dot = tran.GetObject(blktblrec.DrawOrderTableId, OpenMode.ForWrite) as DrawOrderTable;
159
+                    try
160
+                    {
161
+                        #region
162
+                        //RasterImageDef dom = new RasterImageDef();
163
+                        ////domimage.TransformBy();
164
+                        //dom.ActiveFileName = domfilename;
165
+                        ////dom.OpenImage();
166
+                        //dom.Load();
167
+                        //dom.ImageModified = true;
168
+                        //dom.OpenImage();
169
+                        //dom.Embed();                        
170
+                        //RasterImage domimage = new RasterImage();
171
+                        ////Matrix3d.Mirroring();//将栅格图像坐标关于Y轴镜像还原
172
+                        ////Matrix3d.Displacement();//在Y轴正方向上移动图像原始高度距离
173
+                        ////domimage.TransformBy();//最后用6参数组织缩放、旋转、移动的变换矩阵                       
174
+                        //tran.AddNewlyCreatedDBObject(dom, true);
175
+                        //tran.Commit();
176
+                        ///////////////////
177
+                        //RasterImage domimage = new RasterImage();
178
+                        //PromptEntityOptions prent = new PromptEntityOptions("\n请选择山歌图像");
179
+                        //prent.SetRejectMessage("\n选择的不是栅格图像");
180
+                        //prent.AddAllowedClass(typeof(RasterImage), true);
181
+                        //PromptEntityResult prentres = ed.GetEntity(prent);
182
+                        //if (prentres.Status != PromptStatus.OK)
183
+                        //    return;
184
+                        //Matrix3d transform;
185
+                        //ObjectId imgid = prentres.ObjectId;
186
+                        //domimage = (RasterImage)tran.GetObject(imgid, OpenMode.ForRead);
187
+                        //transform = domimage.PixelToModelTransform;
188
+                        #endregion
189
+                        //////////////////////创建图像定义对象
190
+                        ObjectId imgid = RasterImageDef.GetImageDictionary(db);
191
+                        if (imgid == ObjectId.Null)
192
+                            imgid = RasterImageDef.CreateImageDictionary(db);
193
+                        DBDictionary imgdict = tran.GetObject(imgid, OpenMode.ForWrite) as DBDictionary;
194
+                        RasterImageDef imgdef = new RasterImageDef();
195
+                        imgdef.SourceFileName = dompath + "\\" + tiffilename;
196
+                        imgdef.Load();
197
+                        ObjectId imgdefid = imgdict.SetAt(imageName, imgdef);
198
+                        tran.AddNewlyCreatedDBObject(imgdef, true);
199
+                        RasterImage image = new RasterImage();
200
+                        image.ImageDefId = imgdefid;
201
+                        image.Layer = "DOM";
202
+                        blktblrec.AppendEntity(image);
203
+                        tran.AddNewlyCreatedDBObject(image, true);
204
+                        double height = imgdef.Size.Y;
205
+                        Vector3d vt1 = scale * image.Orientation.Xaxis;
206
+                        Vector3d vt2 = scale * image.Orientation.Yaxis;
207
+                        image.AssociateRasterDef(imgdef);
208
+                        //image.Draw();
209
+
210
+                        image.Orientation = new CoordinateSystem3d(new Point3d(X, Y - height * scale, 0), vt1, vt2);
211
+                        //影像后置
212
+                        obidcoll.Add(image.ObjectId);
213
+                        dot.MoveToBottom(obidcoll);
214
+                        obidcoll = new ObjectIdCollection();
215
+                        tran.Commit();
216
+                        Autodesk.AutoCAD.ApplicationServices.Application.UpdateScreen();
217
+                    }
218
+                    catch (Autodesk.AutoCAD.Runtime.Exception ex)
219
+                    {
220
+                        MessageBox.Show(ex.ToString());
221
+                    }
222
+                }
223
+            }
224
+            doc.Database.SaveAs(doc.Database.Filename, DwgVersion.Current);
225
+            //doc.Database.Save();
226
+            doc.CloseAndDiscard();
227
+        }
228
+    }
229
+}

+ 159
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/InsertDOMs_to_one.Designer.cs 查看文件

@@ -0,0 +1,159 @@
1
+
2
+namespace CADTools
3
+{
4
+    partial class InsertDOMs_to_one
5
+    {
6
+        /// <summary>
7
+        /// Required designer variable.
8
+        /// </summary>
9
+        private System.ComponentModel.IContainer components = null;
10
+
11
+        /// <summary>
12
+        /// Clean up any resources being used.
13
+        /// </summary>
14
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
15
+        protected override void Dispose(bool disposing)
16
+        {
17
+            if (disposing && (components != null))
18
+            {
19
+                components.Dispose();
20
+            }
21
+            base.Dispose(disposing);
22
+        }
23
+
24
+        #region Windows Form Designer generated code
25
+
26
+        /// <summary>
27
+        /// Required method for Designer support - do not modify
28
+        /// the contents of this method with the code editor.
29
+        /// </summary>
30
+        private void InitializeComponent()
31
+        {
32
+            this.label1 = new System.Windows.Forms.Label();
33
+            this.label2 = new System.Windows.Forms.Label();
34
+            this.textBox_dwg = new System.Windows.Forms.TextBox();
35
+            this.textBox_dom = new System.Windows.Forms.TextBox();
36
+            this.button_dwg = new System.Windows.Forms.Button();
37
+            this.button_dom = new System.Windows.Forms.Button();
38
+            this.checkedListBox_dom = new CADTools.DraggableCheckedListBox();
39
+            this.button1 = new System.Windows.Forms.Button();
40
+            this.checkBox_selectAll = new System.Windows.Forms.CheckBox();
41
+            this.SuspendLayout();
42
+            // 
43
+            // label1
44
+            // 
45
+            this.label1.AutoSize = true;
46
+            this.label1.Location = new System.Drawing.Point(29, 40);
47
+            this.label1.Name = "label1";
48
+            this.label1.Size = new System.Drawing.Size(106, 15);
49
+            this.label1.TabIndex = 0;
50
+            this.label1.Text = "dwg所在位置:";
51
+            // 
52
+            // label2
53
+            // 
54
+            this.label2.AutoSize = true;
55
+            this.label2.Location = new System.Drawing.Point(30, 98);
56
+            this.label2.Name = "label2";
57
+            this.label2.Size = new System.Drawing.Size(106, 15);
58
+            this.label2.TabIndex = 1;
59
+            this.label2.Text = "dom所在位置:";
60
+            // 
61
+            // textBox_dwg
62
+            // 
63
+            this.textBox_dwg.Location = new System.Drawing.Point(139, 36);
64
+            this.textBox_dwg.Name = "textBox_dwg";
65
+            this.textBox_dwg.Size = new System.Drawing.Size(225, 25);
66
+            this.textBox_dwg.TabIndex = 2;
67
+            // 
68
+            // textBox_dom
69
+            // 
70
+            this.textBox_dom.Location = new System.Drawing.Point(139, 95);
71
+            this.textBox_dom.Name = "textBox_dom";
72
+            this.textBox_dom.Size = new System.Drawing.Size(225, 25);
73
+            this.textBox_dom.TabIndex = 3;
74
+            this.textBox_dom.TextChanged += new System.EventHandler(this.textBox_dom_TextChanged);
75
+            // 
76
+            // button_dwg
77
+            // 
78
+            this.button_dwg.Location = new System.Drawing.Point(382, 36);
79
+            this.button_dwg.Name = "button_dwg";
80
+            this.button_dwg.Size = new System.Drawing.Size(75, 27);
81
+            this.button_dwg.TabIndex = 4;
82
+            this.button_dwg.Text = "选 择";
83
+            this.button_dwg.UseVisualStyleBackColor = true;
84
+            this.button_dwg.Click += new System.EventHandler(this.button_dwg_Click);
85
+            // 
86
+            // button_dom
87
+            // 
88
+            this.button_dom.Location = new System.Drawing.Point(382, 95);
89
+            this.button_dom.Name = "button_dom";
90
+            this.button_dom.Size = new System.Drawing.Size(75, 29);
91
+            this.button_dom.TabIndex = 5;
92
+            this.button_dom.Text = "选 择";
93
+            this.button_dom.UseVisualStyleBackColor = true;
94
+            this.button_dom.Click += new System.EventHandler(this.button_dom_Click);
95
+            // 
96
+            // checkedListBox_dom
97
+            // 
98
+            this.checkedListBox_dom.FormattingEnabled = true;
99
+            this.checkedListBox_dom.Location = new System.Drawing.Point(33, 164);
100
+            this.checkedListBox_dom.Name = "checkedListBox_dom";
101
+            this.checkedListBox_dom.Size = new System.Drawing.Size(424, 224);
102
+            this.checkedListBox_dom.TabIndex = 6;
103
+            // 
104
+            // button1
105
+            // 
106
+            this.button1.Location = new System.Drawing.Point(192, 404);
107
+            this.button1.Name = "button1";
108
+            this.button1.Size = new System.Drawing.Size(83, 36);
109
+            this.button1.TabIndex = 7;
110
+            this.button1.Text = "确 定";
111
+            this.button1.UseVisualStyleBackColor = true;
112
+            this.button1.Click += new System.EventHandler(this.button1_Click);
113
+            // 
114
+            // checkBox_selectAll
115
+            // 
116
+            this.checkBox_selectAll.AutoSize = true;
117
+            this.checkBox_selectAll.Location = new System.Drawing.Point(33, 139);
118
+            this.checkBox_selectAll.Name = "checkBox_selectAll";
119
+            this.checkBox_selectAll.Size = new System.Drawing.Size(59, 19);
120
+            this.checkBox_selectAll.TabIndex = 8;
121
+            this.checkBox_selectAll.Text = "全选";
122
+            this.checkBox_selectAll.UseVisualStyleBackColor = true;
123
+            this.checkBox_selectAll.CheckedChanged += new System.EventHandler(this.checkBox_selectAll_CheckedChanged);
124
+            // 
125
+            // InsertDOMs_to_one
126
+            // 
127
+            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
128
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
129
+            this.ClientSize = new System.Drawing.Size(482, 489);
130
+            this.Controls.Add(this.checkBox_selectAll);
131
+            this.Controls.Add(this.button1);
132
+            this.Controls.Add(this.checkedListBox_dom);
133
+            this.Controls.Add(this.button_dom);
134
+            this.Controls.Add(this.button_dwg);
135
+            this.Controls.Add(this.textBox_dom);
136
+            this.Controls.Add(this.textBox_dwg);
137
+            this.Controls.Add(this.label2);
138
+            this.Controls.Add(this.label1);
139
+            this.Name = "InsertDOMs_to_one";
140
+            this.Text = "批量插入图片(多对一)";
141
+            this.Load += new System.EventHandler(this.InsertDOMs_to_one_Load);
142
+            this.ResumeLayout(false);
143
+            this.PerformLayout();
144
+
145
+        }
146
+
147
+        #endregion
148
+
149
+        private System.Windows.Forms.Label label1;
150
+        private System.Windows.Forms.Label label2;
151
+        private System.Windows.Forms.TextBox textBox_dwg;
152
+        private System.Windows.Forms.TextBox textBox_dom;
153
+        private System.Windows.Forms.Button button_dwg;
154
+        private System.Windows.Forms.Button button_dom;
155
+        private System.Windows.Forms.Button button1;
156
+        private System.Windows.Forms.CheckBox checkBox_selectAll;
157
+        private DraggableCheckedListBox checkedListBox_dom;
158
+    }
159
+}

+ 453
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/InsertDOMs_to_one.cs 查看文件

@@ -0,0 +1,453 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.ComponentModel;
4
+using System.Data;
5
+using System.Drawing;
6
+using System.Linq;
7
+using System.Text;
8
+using System.Threading.Tasks;
9
+using System.Windows.Forms;
10
+using System.IO;
11
+using Autodesk.AutoCAD.ApplicationServices;
12
+using Autodesk.AutoCAD.DatabaseServices;
13
+using Autodesk.AutoCAD.EditorInput;
14
+using Autodesk.AutoCAD.Geometry;
15
+using Autodesk.AutoCAD.Colors;
16
+
17
+namespace CADTools
18
+{
19
+    public partial class InsertDOMs_to_one : Form
20
+    {
21
+        public InsertDOMs_to_one()
22
+        {
23
+            InitializeComponent();
24
+        }
25
+        
26
+
27
+        private void button_dwg_Click(object sender, EventArgs e)
28
+        {
29
+            OpenFileDialog openFileDialog = new OpenFileDialog();
30
+            // 设置对话框属性
31
+            openFileDialog.Title = "选择文件";                   // 对话框标题
32
+            openFileDialog.Filter = "文本文件|*.dwg|所有文件|*.*"; // 文件类型筛选
33
+            openFileDialog.InitialDirectory = @"C:\";           // 初始目录
34
+            openFileDialog.Multiselect = false;                 // 是否允许多选
35
+
36
+            // 显示对话框并检查用户是否点击"确定"
37
+            if (openFileDialog.ShowDialog() == DialogResult.OK)
38
+            {
39
+                // 显示选中的文件路径
40
+                textBox_dwg.Text = openFileDialog.FileName;
41
+            }
42
+            else
43
+                return; // 用户取消选择
44
+        }
45
+
46
+        private void button_dom_Click(object sender, EventArgs e)
47
+        {
48
+            FolderBrowserDialog open = new FolderBrowserDialog();
49
+            open.Description = "请选择文件夹";
50
+            if (open.ShowDialog() == System.Windows.Forms.DialogResult.OK)
51
+            {
52
+                textBox_dom.Text = open.SelectedPath;
53
+                string[] tifFiles = Directory.GetFiles(open.SelectedPath, "*.tif", SearchOption.TopDirectoryOnly);
54
+                if (tifFiles.Length == 0)
55
+                {
56
+                    MessageBox.Show("未找到 .tif 文件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
57
+                    return;
58
+                }
59
+                // 清空 CheckedListBox
60
+                checkedListBox_dom.Items.Clear();
61
+
62
+                // 添加文件到 CheckedListBox(仅显示文件名,不含路径)
63
+                foreach (string file in tifFiles)
64
+                {
65
+                    checkedListBox_dom.Items.Add(Path.GetFileName(file));
66
+                }
67
+            }
68
+        }
69
+
70
+        private void button1_Click(object sender, EventArgs e)
71
+        {
72
+            if (checkedListBox_dom.CheckedItems.Count != 0)
73
+            {
74
+                //Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.Add(textBox_dwg.Text);
75
+                //Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument = doc;
76
+                var doc = OpenOrActivateDrawing(textBox_dwg.Text);
77
+                for (int i = 0; i < checkedListBox_dom.Items.Count; i++)
78
+                {
79
+                    if (checkedListBox_dom.GetItemChecked(i))
80
+                    {
81
+                        string fileName = checkedListBox_dom.Items[i].ToString();
82
+                        string tifpath = textBox_dom.Text + "//" + fileName;
83
+                        tifpath = System.IO.Path.GetFullPath(tifpath);
84
+                        string tfwpath = tifpath.Replace(".tif", ".tfw").Replace(".Tif", ".tfw");
85
+                        InsertDOMs(tifpath, tfwpath, doc);
86
+                    }
87
+                }
88
+                dynamic acadApp = Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication;
89
+                acadApp.ZoomExtents();
90
+                //浩辰2020不能用doc.CloseandSave,它只能close不save
91
+                //doc.CloseAndSave(doc.Database.Filename);
92
+                this.Close();
93
+            }
94
+        }
95
+
96
+        private void InsertDOMs(string tiffilename, string tfwfilename, Document doc)
97
+        {
98
+            Database db = doc.Database;
99
+            ObjectIdCollection obidcoll = new ObjectIdCollection();
100
+            string imageName = new FileInfo(tiffilename).Name;
101
+            double scale = 0;
102
+            double X = 0, Y = 0;
103
+            try
104
+            {
105
+                StreamReader sr = new StreamReader(tfwfilename);
106
+                string firstLine = sr.ReadLine()?.Trim();
107
+                scale = Convert.ToDouble(firstLine);
108
+                sr.ReadLine();
109
+                sr.ReadLine();
110
+                sr.ReadLine();
111
+                X = Convert.ToDouble(sr.ReadLine());
112
+                Y = Convert.ToDouble(sr.ReadLine());
113
+                sr.Close();
114
+                sr.Dispose();
115
+            }
116
+            catch (System.Exception ex)
117
+            {
118
+                //MessageBox.Show("警告:" + Path.GetFileName(tiffilename) + "图像没有相应的.tfw文件或tfw文件出错,无法正确插入!\r\n\r\n");
119
+                MessageBox.Show(ex.Message);
120
+            }
121
+
122
+            using (DocumentLock docLock = doc.LockDocument())
123
+            {
124
+                using (Transaction tran = db.TransactionManager.StartTransaction())
125
+                {
126
+                    //建立名为DOM的图层
127
+                    LayerTable lt = tran.GetObject(db.LayerTableId, OpenMode.ForWrite) as LayerTable;
128
+                    //try
129
+                    //{
130
+                    if (!lt.Has("DOM"))
131
+                    {
132
+                        LayerTableRecord ltrec = new LayerTableRecord();
133
+                        ltrec.Name = "DOM";
134
+                        ObjectId obid = lt.Add(ltrec);
135
+                        tran.AddNewlyCreatedDBObject(ltrec, true);
136
+                    }
137
+
138
+                    //}
139
+                    //catch (Autodesk.AutoCAD.Runtime.Exception ex)
140
+                    //{
141
+                    //    MessageBox.Show(ex.ToString());
142
+                    //}
143
+                    tran.Commit();
144
+                }
145
+                using (Transaction tran = db.TransactionManager.StartTransaction())
146
+                {
147
+                    //插入DOM
148
+                    BlockTable blktbl = tran.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
149
+                    BlockTableRecord blktblrec = tran.GetObject(blktbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
150
+                    DrawOrderTable dot = tran.GetObject(blktblrec.DrawOrderTableId, OpenMode.ForWrite) as DrawOrderTable;
151
+                    //try
152
+                    //{
153
+                        #region
154
+                        //RasterImageDef dom = new RasterImageDef();
155
+                        ////domimage.TransformBy();
156
+                        //dom.ActiveFileName = domfilename;
157
+                        ////dom.OpenImage();
158
+                        //dom.Load();
159
+                        //dom.ImageModified = true;
160
+                        //dom.OpenImage();
161
+                        //dom.Embed();                        
162
+                        //RasterImage domimage = new RasterImage();
163
+                        ////Matrix3d.Mirroring();//将栅格图像坐标关于Y轴镜像还原
164
+                        ////Matrix3d.Displacement();//在Y轴正方向上移动图像原始高度距离
165
+                        ////domimage.TransformBy();//最后用6参数组织缩放、旋转、移动的变换矩阵                       
166
+                        //tran.AddNewlyCreatedDBObject(dom, true);
167
+                        //tran.Commit();
168
+                        ///////////////////
169
+                        //RasterImage domimage = new RasterImage();
170
+                        //PromptEntityOptions prent = new PromptEntityOptions("\n请选择山歌图像");
171
+                        //prent.SetRejectMessage("\n选择的不是栅格图像");
172
+                        //prent.AddAllowedClass(typeof(RasterImage), true);
173
+                        //PromptEntityResult prentres = ed.GetEntity(prent);
174
+                        //if (prentres.Status != PromptStatus.OK)
175
+                        //    return;
176
+                        //Matrix3d transform;
177
+                        //ObjectId imgid = prentres.ObjectId;
178
+                        //domimage = (RasterImage)tran.GetObject(imgid, OpenMode.ForRead);
179
+                        //transform = domimage.PixelToModelTransform;
180
+                        #endregion
181
+                        //////////////////////创建图像定义对象
182
+                        ObjectId imgid = RasterImageDef.GetImageDictionary(db);
183
+                        if (imgid == ObjectId.Null)
184
+                            imgid = RasterImageDef.CreateImageDictionary(db);
185
+                        DBDictionary imgdict = tran.GetObject(imgid, OpenMode.ForWrite) as DBDictionary;
186
+                        RasterImageDef imgdef = new RasterImageDef();
187
+                        imgdef.SourceFileName = tiffilename;
188
+                        imgdef.Load();
189
+                        ObjectId imgdefid = imgdict.SetAt(imageName, imgdef);
190
+                        tran.AddNewlyCreatedDBObject(imgdef, true);
191
+                        RasterImage image = new RasterImage();
192
+                        image.ImageDefId = imgdefid;
193
+                        image.Layer = "DOM";
194
+                        blktblrec.AppendEntity(image);
195
+                        tran.AddNewlyCreatedDBObject(image, true);
196
+                        double height = imgdef.Size.Y;
197
+                        Vector3d vt1 = scale * image.Orientation.Xaxis;
198
+                        Vector3d vt2 = scale * image.Orientation.Yaxis;
199
+                        image.AssociateRasterDef(imgdef);
200
+                        //image.Draw();
201
+
202
+                        image.Orientation = new CoordinateSystem3d(new Point3d(X, Y - height * scale, 0), vt1, vt2);
203
+                        //影像后置
204
+                        obidcoll.Add(image.ObjectId);
205
+                        dot.MoveToBottom(obidcoll);
206
+                        obidcoll = new ObjectIdCollection();
207
+                        tran.Commit();
208
+                        Autodesk.AutoCAD.ApplicationServices.Application.UpdateScreen();
209
+                    //}
210
+                    //catch (Autodesk.AutoCAD.Runtime.Exception ex)
211
+                    //{
212
+                    //    MessageBox.Show(ex.ToString());
213
+                    //}
214
+
215
+                }
216
+            }
217
+        }
218
+
219
+        private void checkBox_selectAll_CheckedChanged(object sender, EventArgs e)
220
+        {
221
+            if (checkBox_selectAll.Checked == true)
222
+            {
223
+                for (int i = 0; i < this.checkedListBox_dom.Items.Count; i++)
224
+                {
225
+                    this.checkedListBox_dom.SetItemChecked(i, true);
226
+                }
227
+            }
228
+            else
229
+            {
230
+                for (int i = 0; i < this.checkedListBox_dom.Items.Count; i++)
231
+                {
232
+                    this.checkedListBox_dom.SetItemChecked(i, false);
233
+                }
234
+            }
235
+        }
236
+
237
+        private static Document OpenOrActivateDrawing(string filePath)
238
+        {
239
+            // 检查文件是否存在
240
+            if (!File.Exists(filePath))
241
+            {
242
+                throw new FileNotFoundException($"文件不存在: {filePath}");
243
+            }
244
+
245
+            string normalizedPath = Path.GetFullPath(filePath).ToLowerInvariant();
246
+            DocumentCollection docs = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager;
247
+
248
+            // 检查是否已打开
249
+            foreach (Document doc in docs)
250
+            {
251
+                if (!string.IsNullOrEmpty(doc.Name))
252
+                {
253
+                    string docPath = Path.GetFullPath(doc.Name).ToLowerInvariant();
254
+                    if (docPath == normalizedPath)
255
+                    {
256
+                        // 已打开,激活
257
+                        if (doc != docs.MdiActiveDocument)
258
+                        {
259
+                            docs.MdiActiveDocument = doc;
260
+                        }
261
+                        return doc;
262
+                    }
263
+                }
264
+            }
265
+
266
+            // 未打开,创建新文档
267
+            return docs.Add(filePath);
268
+        }
269
+
270
+        private void textBox_dom_TextChanged(object sender, EventArgs e)
271
+        {
272
+            string pastedContent = textBox_dom.Text;
273
+
274
+            // 处理粘贴的内容
275
+            if (!string.IsNullOrEmpty(pastedContent))
276
+            {
277
+
278
+                // 检查文件是否存在
279
+                if (Directory.Exists(pastedContent))
280
+                {
281
+                    string[] tifFiles = Directory.GetFiles(pastedContent, "*.tif", SearchOption.TopDirectoryOnly);
282
+                    if (tifFiles.Length == 0)
283
+                    {
284
+                        MessageBox.Show("未找到 .tif 文件!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
285
+                        return;
286
+                    }
287
+                    // 清空 CheckedListBox
288
+                    checkedListBox_dom.Items.Clear();
289
+
290
+                    // 添加文件到 CheckedListBox(仅显示文件名,不含路径)
291
+                    foreach (string file in tifFiles)
292
+                    {
293
+                        checkedListBox_dom.Items.Add(Path.GetFileName(file));
294
+                    }
295
+                }
296
+            }
297
+        }
298
+
299
+        private void InsertDOMs_to_one_Load(object sender, EventArgs e)
300
+        {
301
+            var doc =Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
302
+            string docPath = Path.GetFullPath(doc.Name).ToLowerInvariant();
303
+            textBox_dwg.Text = docPath;
304
+        }
305
+    }
306
+
307
+    public class DraggableCheckedListBox : CheckedListBox
308
+    {
309
+        private bool isDragging = false;
310
+        private Point dragStartPoint;
311
+        private bool isMouseDown = false;
312
+        private int lastSelectedIndex = -1;
313
+        private bool isClick = false;
314
+        private List<int> dragSelectedIndices = new List<int>();
315
+        private bool isDragSelecting = false;
316
+
317
+        public DraggableCheckedListBox()
318
+        {
319
+            // 启用双缓冲减少闪烁
320
+            this.DoubleBuffered = true;
321
+
322
+            // 设置属性
323
+            this.CheckOnClick = false; // 手动控制勾选
324
+
325
+            // 处理鼠标事件
326
+            this.MouseDown += DraggableCheckedListBox_MouseDown;
327
+            this.MouseMove += DraggableCheckedListBox_MouseMove;
328
+            this.MouseUp += DraggableCheckedListBox_MouseUp;
329
+        }
330
+
331
+        private void DraggableCheckedListBox_MouseDown(object sender, MouseEventArgs e)
332
+        {
333
+            isMouseDown = true;
334
+            dragStartPoint = e.Location;
335
+            isClick = true;
336
+            isDragSelecting = false;
337
+
338
+            // 获取当前鼠标下的项
339
+            int index = this.IndexFromPoint(e.Location);
340
+            if (index != ListBox.NoMatches)
341
+            {
342
+                lastSelectedIndex = index;
343
+
344
+                // 处理单击选择(不拖动的情况)
345
+                if (ModifierKeys.HasFlag(Keys.Control))
346
+                {
347
+                    // Ctrl + 单击:切换当前项,保留其他已选项
348
+                    this.SetItemChecked(index, !this.GetItemChecked(index));
349
+                }
350
+                else if (ModifierKeys.HasFlag(Keys.Shift) && lastSelectedIndex != -1)
351
+                {
352
+                    // Shift + 单击:范围选择,保留其他已选项
353
+                    int start = Math.Min(lastSelectedIndex, index);
354
+                    int end = Math.Max(lastSelectedIndex, index);
355
+                    bool checkState = !this.GetItemChecked(index);
356
+
357
+                    for (int i = start; i <= end; i++)
358
+                    {
359
+                        this.SetItemChecked(i, checkState);
360
+                    }
361
+                }
362
+                else
363
+                {
364
+                    // 普通单击:切换当前项
365
+                    // 注意:这里不清除其他已选项,只是切换当前项
366
+                    this.SetItemChecked(index, !this.GetItemChecked(index));
367
+                }
368
+            }
369
+        }
370
+
371
+        private void DraggableCheckedListBox_MouseMove(object sender, MouseEventArgs e)
372
+        {
373
+            if (!isMouseDown) return;
374
+
375
+            // 检测是否开始拖动(移动距离超过阈值)
376
+            if (!isDragging &&
377
+                (Math.Abs(e.X - dragStartPoint.X) > SystemInformation.DragSize.Width ||
378
+                 Math.Abs(e.Y - dragStartPoint.Y) > SystemInformation.DragSize.Height))
379
+            {
380
+                isDragging = true;
381
+                isClick = false;
382
+                isDragSelecting = true;
383
+
384
+                // 开始拖动选择,清空临时记录
385
+                dragSelectedIndices.Clear();
386
+
387
+                // 可选:如果需要拖动时清除之前的选择,取消下面的注释
388
+                // if (!ModifierKeys.HasFlag(Keys.Control))
389
+                // {
390
+                //     for (int i = 0; i < this.Items.Count; i++)
391
+                //     {
392
+                //         this.SetItemChecked(i, false);
393
+                //     }
394
+                // }
395
+            }
396
+
397
+            // 如果在拖动状态,处理选择
398
+            if (isDragging && isDragSelecting)
399
+            {
400
+                Point currentPoint = this.PointToClient(MousePosition);
401
+                int index = this.IndexFromPoint(currentPoint);
402
+
403
+                if (index != ListBox.NoMatches && !dragSelectedIndices.Contains(index))
404
+                {
405
+                    dragSelectedIndices.Add(index);
406
+
407
+                    // 根据修饰键决定选择行为
408
+                    if (ModifierKeys.HasFlag(Keys.Control))
409
+                    {
410
+                        // Ctrl + 拖动:切换状态(保留其他已选项)
411
+                        this.SetItemChecked(index, !this.GetItemChecked(index));
412
+                    }
413
+                    else
414
+                    {
415
+                        // 普通拖动:选中当前项(保留其他已选项)
416
+                        this.SetItemChecked(index, true);
417
+                    }
418
+
419
+                    lastSelectedIndex = index;
420
+
421
+                    // 滚动到当前项
422
+                    this.TopIndex = Math.Max(0, index - 5);
423
+
424
+                    // 触发自定义事件
425
+                    OnItemDraggedSelected(new ItemCheckEventArgs(index,
426
+                        this.GetItemChecked(index) ? CheckState.Checked : CheckState.Unchecked,
427
+                        CheckState.Indeterminate));
428
+                }
429
+            }
430
+        }
431
+
432
+        private void DraggableCheckedListBox_MouseUp(object sender, MouseEventArgs e)
433
+        {
434
+            isMouseDown = false;
435
+            isDragging = false;
436
+            isDragSelecting = false;
437
+            dragSelectedIndices.Clear();
438
+
439
+            // 如果是单击,已经在 MouseDown 中处理了
440
+            // 这里不需要额外处理
441
+
442
+            lastSelectedIndex = -1;
443
+        }
444
+
445
+        // 自定义事件:当通过拖动选择项时触发
446
+        public event EventHandler<ItemCheckEventArgs> ItemDraggedSelected;
447
+
448
+        protected virtual void OnItemDraggedSelected(ItemCheckEventArgs e)
449
+        {
450
+            ItemDraggedSelected?.Invoke(this, e);
451
+        }
452
+    }
453
+}

+ 120
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/InsertDOMs_to_one.resx 查看文件

@@ -0,0 +1,120 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<root>
3
+  <!-- 
4
+    Microsoft ResX Schema 
5
+    
6
+    Version 2.0
7
+    
8
+    The primary goals of this format is to allow a simple XML format 
9
+    that is mostly human readable. The generation and parsing of the 
10
+    various data types are done through the TypeConverter classes 
11
+    associated with the data types.
12
+    
13
+    Example:
14
+    
15
+    ... ado.net/XML headers & schema ...
16
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
17
+    <resheader name="version">2.0</resheader>
18
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
19
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
20
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
21
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
22
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
24
+    </data>
25
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
26
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
27
+        <comment>This is a comment</comment>
28
+    </data>
29
+                
30
+    There are any number of "resheader" rows that contain simple 
31
+    name/value pairs.
32
+    
33
+    Each data row contains a name, and value. The row also contains a 
34
+    type or mimetype. Type corresponds to a .NET class that support 
35
+    text/value conversion through the TypeConverter architecture. 
36
+    Classes that don't support this are serialized and stored with the 
37
+    mimetype set.
38
+    
39
+    The mimetype is used for serialized objects, and tells the 
40
+    ResXResourceReader how to depersist the object. This is currently not 
41
+    extensible. For a given mimetype the value must be set accordingly:
42
+    
43
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
44
+    that the ResXResourceWriter will generate, however the reader can 
45
+    read any of the formats listed below.
46
+    
47
+    mimetype: application/x-microsoft.net.object.binary.base64
48
+    value   : The object must be serialized with 
49
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
50
+            : and then encoded with base64 encoding.
51
+    
52
+    mimetype: application/x-microsoft.net.object.soap.base64
53
+    value   : The object must be serialized with 
54
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
55
+            : and then encoded with base64 encoding.
56
+
57
+    mimetype: application/x-microsoft.net.object.bytearray.base64
58
+    value   : The object must be serialized into a byte array 
59
+            : using a System.ComponentModel.TypeConverter
60
+            : and then encoded with base64 encoding.
61
+    -->
62
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
64
+    <xsd:element name="root" msdata:IsDataSet="true">
65
+      <xsd:complexType>
66
+        <xsd:choice maxOccurs="unbounded">
67
+          <xsd:element name="metadata">
68
+            <xsd:complexType>
69
+              <xsd:sequence>
70
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
71
+              </xsd:sequence>
72
+              <xsd:attribute name="name" use="required" type="xsd:string" />
73
+              <xsd:attribute name="type" type="xsd:string" />
74
+              <xsd:attribute name="mimetype" type="xsd:string" />
75
+              <xsd:attribute ref="xml:space" />
76
+            </xsd:complexType>
77
+          </xsd:element>
78
+          <xsd:element name="assembly">
79
+            <xsd:complexType>
80
+              <xsd:attribute name="alias" type="xsd:string" />
81
+              <xsd:attribute name="name" type="xsd:string" />
82
+            </xsd:complexType>
83
+          </xsd:element>
84
+          <xsd:element name="data">
85
+            <xsd:complexType>
86
+              <xsd:sequence>
87
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
88
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
89
+              </xsd:sequence>
90
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
91
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
92
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
93
+              <xsd:attribute ref="xml:space" />
94
+            </xsd:complexType>
95
+          </xsd:element>
96
+          <xsd:element name="resheader">
97
+            <xsd:complexType>
98
+              <xsd:sequence>
99
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
100
+              </xsd:sequence>
101
+              <xsd:attribute name="name" type="xsd:string" use="required" />
102
+            </xsd:complexType>
103
+          </xsd:element>
104
+        </xsd:choice>
105
+      </xsd:complexType>
106
+    </xsd:element>
107
+  </xsd:schema>
108
+  <resheader name="resmimetype">
109
+    <value>text/microsoft-resx</value>
110
+  </resheader>
111
+  <resheader name="version">
112
+    <value>2.0</value>
113
+  </resheader>
114
+  <resheader name="reader">
115
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116
+  </resheader>
117
+  <resheader name="writer">
118
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119
+  </resheader>
120
+</root>

+ 132
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/InstDOM.Designer.cs 查看文件

@@ -0,0 +1,132 @@
1
+
2
+namespace CADTools
3
+{
4
+    partial class InstDOM
5
+    {
6
+        /// <summary>
7
+        /// Required designer variable.
8
+        /// </summary>
9
+        private System.ComponentModel.IContainer components = null;
10
+
11
+        /// <summary>
12
+        /// Clean up any resources being used.
13
+        /// </summary>
14
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
15
+        protected override void Dispose(bool disposing)
16
+        {
17
+            if (disposing && (components != null))
18
+            {
19
+                components.Dispose();
20
+            }
21
+            base.Dispose(disposing);
22
+        }
23
+
24
+        #region Windows Form Designer generated code
25
+
26
+        /// <summary>
27
+        /// Required method for Designer support - do not modify
28
+        /// the contents of this method with the code editor.
29
+        /// </summary>
30
+        private void InitializeComponent()
31
+        {
32
+            this.label1 = new System.Windows.Forms.Label();
33
+            this.label2 = new System.Windows.Forms.Label();
34
+            this.textBox_dom = new System.Windows.Forms.TextBox();
35
+            this.textBox_dwg = new System.Windows.Forms.TextBox();
36
+            this.button_ok = new System.Windows.Forms.Button();
37
+            this.button_choose1 = new System.Windows.Forms.Button();
38
+            this.button_choose2 = new System.Windows.Forms.Button();
39
+            this.SuspendLayout();
40
+            // 
41
+            // label1
42
+            // 
43
+            this.label1.AutoSize = true;
44
+            this.label1.Location = new System.Drawing.Point(35, 46);
45
+            this.label1.Name = "label1";
46
+            this.label1.Size = new System.Drawing.Size(136, 15);
47
+            this.label1.TabIndex = 0;
48
+            this.label1.Text = "DOM文件所在位置:";
49
+            // 
50
+            // label2
51
+            // 
52
+            this.label2.AutoSize = true;
53
+            this.label2.Location = new System.Drawing.Point(35, 105);
54
+            this.label2.Name = "label2";
55
+            this.label2.Size = new System.Drawing.Size(136, 15);
56
+            this.label2.TabIndex = 1;
57
+            this.label2.Text = "DWG文件所在位置:";
58
+            // 
59
+            // textBox_dom
60
+            // 
61
+            this.textBox_dom.Location = new System.Drawing.Point(168, 36);
62
+            this.textBox_dom.Name = "textBox_dom";
63
+            this.textBox_dom.Size = new System.Drawing.Size(325, 25);
64
+            this.textBox_dom.TabIndex = 2;
65
+            // 
66
+            // textBox_dwg
67
+            // 
68
+            this.textBox_dwg.Location = new System.Drawing.Point(168, 95);
69
+            this.textBox_dwg.Name = "textBox_dwg";
70
+            this.textBox_dwg.Size = new System.Drawing.Size(325, 25);
71
+            this.textBox_dwg.TabIndex = 3;
72
+            // 
73
+            // button_ok
74
+            // 
75
+            this.button_ok.Location = new System.Drawing.Point(277, 144);
76
+            this.button_ok.Name = "button_ok";
77
+            this.button_ok.Size = new System.Drawing.Size(74, 33);
78
+            this.button_ok.TabIndex = 4;
79
+            this.button_ok.Text = "确 定";
80
+            this.button_ok.UseVisualStyleBackColor = true;
81
+            this.button_ok.Click += new System.EventHandler(this.button_ok_Click);
82
+            // 
83
+            // button_choose1
84
+            // 
85
+            this.button_choose1.Location = new System.Drawing.Point(509, 31);
86
+            this.button_choose1.Name = "button_choose1";
87
+            this.button_choose1.Size = new System.Drawing.Size(76, 31);
88
+            this.button_choose1.TabIndex = 5;
89
+            this.button_choose1.Text = "选 择";
90
+            this.button_choose1.UseVisualStyleBackColor = true;
91
+            this.button_choose1.Click += new System.EventHandler(this.button_choose1_Click);
92
+            // 
93
+            // button_choose2
94
+            // 
95
+            this.button_choose2.Location = new System.Drawing.Point(509, 89);
96
+            this.button_choose2.Name = "button_choose2";
97
+            this.button_choose2.Size = new System.Drawing.Size(76, 31);
98
+            this.button_choose2.TabIndex = 6;
99
+            this.button_choose2.Text = "选 择";
100
+            this.button_choose2.UseVisualStyleBackColor = true;
101
+            this.button_choose2.Click += new System.EventHandler(this.button_choose2_Click);
102
+            // 
103
+            // InstDOM
104
+            // 
105
+            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
106
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
107
+            this.ClientSize = new System.Drawing.Size(641, 200);
108
+            this.Controls.Add(this.button_choose2);
109
+            this.Controls.Add(this.button_choose1);
110
+            this.Controls.Add(this.button_ok);
111
+            this.Controls.Add(this.textBox_dwg);
112
+            this.Controls.Add(this.textBox_dom);
113
+            this.Controls.Add(this.label2);
114
+            this.Controls.Add(this.label1);
115
+            this.Name = "InstDOM";
116
+            this.Text = "InstDOM";
117
+            this.ResumeLayout(false);
118
+            this.PerformLayout();
119
+
120
+        }
121
+
122
+        #endregion
123
+
124
+        private System.Windows.Forms.Label label1;
125
+        private System.Windows.Forms.Label label2;
126
+        private System.Windows.Forms.TextBox textBox_dom;
127
+        private System.Windows.Forms.TextBox textBox_dwg;
128
+        private System.Windows.Forms.Button button_ok;
129
+        private System.Windows.Forms.Button button_choose1;
130
+        private System.Windows.Forms.Button button_choose2;
131
+    }
132
+}

+ 45
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/InstDOM.cs 查看文件

@@ -0,0 +1,45 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.ComponentModel;
4
+using System.Data;
5
+using System.Drawing;
6
+using System.Linq;
7
+using System.Text;
8
+using System.Threading.Tasks;
9
+using System.Windows.Forms;
10
+
11
+namespace CADTools
12
+{
13
+    public partial class InstDOM : Form
14
+    {
15
+        public InstDOM()
16
+        {
17
+            InitializeComponent();
18
+        }
19
+
20
+        private void button_choose1_Click(object sender, EventArgs e)
21
+        {
22
+            FolderBrowserDialog open = new FolderBrowserDialog();
23
+            open.Description = "请选择文件夹";
24
+            if (open.ShowDialog() == System.Windows.Forms.DialogResult.OK)
25
+                textBox_dom.Text = open.SelectedPath;
26
+        }
27
+
28
+        private void button_choose2_Click(object sender, EventArgs e)
29
+        {
30
+            FolderBrowserDialog open = new FolderBrowserDialog();
31
+            open.Description = "请选择文件夹";
32
+            if (open.ShowDialog() == System.Windows.Forms.DialogResult.OK)
33
+                textBox_dwg.Text = open.SelectedPath;
34
+        }
35
+
36
+        private void button_ok_Click(object sender, EventArgs e)
37
+        {
38
+            InsertDOM.dompath = textBox_dom.Text.ToString();
39
+            InsertDOM.dwgpath = textBox_dwg.Text.ToString();
40
+            InsertDOM instdom = new InsertDOM();
41
+            instdom.InsertDOMToCAD();
42
+            this.Close();
43
+        }
44
+    }
45
+}

+ 120
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/InstDOM.resx 查看文件

@@ -0,0 +1,120 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<root>
3
+  <!-- 
4
+    Microsoft ResX Schema 
5
+    
6
+    Version 2.0
7
+    
8
+    The primary goals of this format is to allow a simple XML format 
9
+    that is mostly human readable. The generation and parsing of the 
10
+    various data types are done through the TypeConverter classes 
11
+    associated with the data types.
12
+    
13
+    Example:
14
+    
15
+    ... ado.net/XML headers & schema ...
16
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
17
+    <resheader name="version">2.0</resheader>
18
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
19
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
20
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
21
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
22
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
24
+    </data>
25
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
26
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
27
+        <comment>This is a comment</comment>
28
+    </data>
29
+                
30
+    There are any number of "resheader" rows that contain simple 
31
+    name/value pairs.
32
+    
33
+    Each data row contains a name, and value. The row also contains a 
34
+    type or mimetype. Type corresponds to a .NET class that support 
35
+    text/value conversion through the TypeConverter architecture. 
36
+    Classes that don't support this are serialized and stored with the 
37
+    mimetype set.
38
+    
39
+    The mimetype is used for serialized objects, and tells the 
40
+    ResXResourceReader how to depersist the object. This is currently not 
41
+    extensible. For a given mimetype the value must be set accordingly:
42
+    
43
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
44
+    that the ResXResourceWriter will generate, however the reader can 
45
+    read any of the formats listed below.
46
+    
47
+    mimetype: application/x-microsoft.net.object.binary.base64
48
+    value   : The object must be serialized with 
49
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
50
+            : and then encoded with base64 encoding.
51
+    
52
+    mimetype: application/x-microsoft.net.object.soap.base64
53
+    value   : The object must be serialized with 
54
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
55
+            : and then encoded with base64 encoding.
56
+
57
+    mimetype: application/x-microsoft.net.object.bytearray.base64
58
+    value   : The object must be serialized into a byte array 
59
+            : using a System.ComponentModel.TypeConverter
60
+            : and then encoded with base64 encoding.
61
+    -->
62
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
64
+    <xsd:element name="root" msdata:IsDataSet="true">
65
+      <xsd:complexType>
66
+        <xsd:choice maxOccurs="unbounded">
67
+          <xsd:element name="metadata">
68
+            <xsd:complexType>
69
+              <xsd:sequence>
70
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
71
+              </xsd:sequence>
72
+              <xsd:attribute name="name" use="required" type="xsd:string" />
73
+              <xsd:attribute name="type" type="xsd:string" />
74
+              <xsd:attribute name="mimetype" type="xsd:string" />
75
+              <xsd:attribute ref="xml:space" />
76
+            </xsd:complexType>
77
+          </xsd:element>
78
+          <xsd:element name="assembly">
79
+            <xsd:complexType>
80
+              <xsd:attribute name="alias" type="xsd:string" />
81
+              <xsd:attribute name="name" type="xsd:string" />
82
+            </xsd:complexType>
83
+          </xsd:element>
84
+          <xsd:element name="data">
85
+            <xsd:complexType>
86
+              <xsd:sequence>
87
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
88
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
89
+              </xsd:sequence>
90
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
91
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
92
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
93
+              <xsd:attribute ref="xml:space" />
94
+            </xsd:complexType>
95
+          </xsd:element>
96
+          <xsd:element name="resheader">
97
+            <xsd:complexType>
98
+              <xsd:sequence>
99
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
100
+              </xsd:sequence>
101
+              <xsd:attribute name="name" type="xsd:string" use="required" />
102
+            </xsd:complexType>
103
+          </xsd:element>
104
+        </xsd:choice>
105
+      </xsd:complexType>
106
+    </xsd:element>
107
+  </xsd:schema>
108
+  <resheader name="resmimetype">
109
+    <value>text/microsoft-resx</value>
110
+  </resheader>
111
+  <resheader name="version">
112
+    <value>2.0</value>
113
+  </resheader>
114
+  <resheader name="reader">
115
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116
+  </resheader>
117
+  <resheader name="writer">
118
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119
+  </resheader>
120
+</root>

+ 679
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/Inters.cs 查看文件

@@ -0,0 +1,679 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Threading.Tasks;
6
+
7
+using Autodesk.AutoCAD.ApplicationServices;
8
+using Autodesk.AutoCAD.DatabaseServices;
9
+using Autodesk.AutoCAD.EditorInput;
10
+using Autodesk.AutoCAD.Geometry;
11
+using GeoAPI.Geometries;
12
+using NetTopologySuite.Geometries;
13
+using NetTopologySuite.Operation;
14
+using NetTopologySuite.Operation.Valid;
15
+
16
+namespace CADTools
17
+{
18
+    class Inters
19
+    {
20
+        public static int blc;//比例尺
21
+        public static string jqx;
22
+        public static string sqx;
23
+
24
+        //由于AUTOCAD的IntersectWith()函数在实体离开原点过远的情况下精确度会大幅下降,
25
+        //在进行相交检查时需要将待检查的实体移动到原点再进行检查,
26
+        //将检查后的标记移动回原位。
27
+        #region 线自相交
28
+        public void SelfInts()
29
+        {
30
+            double flagradius = 4.0 * blc / 1000;//画圆标记半径
31
+            string layername = jqx + "," + sqx;
32
+
33
+            Document doc = Application.DocumentManager.MdiActiveDocument;
34
+            Database db = doc.Database;
35
+            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
36
+
37
+            TypedValue[] value = new TypedValue[]
38
+            {
39
+                new TypedValue((int)DxfCode.LayerName,layername),
40
+                new TypedValue((int)DxfCode.Start,"LWPOLYLINE")
41
+            };//设置筛选条件
42
+            SelectionFilter filter = new SelectionFilter(value);//选择区域中全部对象
43
+            //PromptSelectionResult psr = ed.SelectAll(filter);// 要求在图形区域中手动选择对象
44
+            PromptSelectionResult psr = ed.GetSelection(filter);
45
+            
46
+            if (psr.Status == PromptStatus.OK)
47
+            {
48
+                Point3dCollection intersectPts = new Point3dCollection();
49
+                int j = 0;
50
+
51
+                SelectionSet ss = psr.Value;
52
+                if (ss == null)
53
+                    return;
54
+
55
+                //创建标注相交点符号的图层
56
+                LayerControl layerscontrol = new LayerControl();
57
+                string layname = "线自相交点";
58
+                if (!layerscontrol.haslayername(layname))
59
+                {
60
+                    colorgb col = new colorgb(255, 0, 255);
61
+                    layerscontrol.creatlayer(layname, col);
62
+                    layerscontrol.movelayertofront(layname);
63
+                }
64
+                else
65
+                    layerscontrol.movelayertofront(layname);
66
+
67
+                ObjectIdCollection idcoll1 = new ObjectIdCollection(ss.GetObjectIds());//需要添加到块中的实体
68
+                ObjectIdCollection idcoll2 = new ObjectIdCollection();//explode后重新添加到数据库的实体
69
+                ObjectIdCollection idcoll3 = new ObjectIdCollection();//添加标记后实体
70
+                Point3d MoveToPt = new Point3d(0, 0, 0);//目标点
71
+                Point3d SelfPt = new Point3d();//基点
72
+
73
+                //将选中多段线添加到块中并移动
74
+                DBObjectCollection objcoll = MovebyBlock(idcoll1, out SelfPt, MoveToPt);
75
+
76
+                //将explode之后的实体重新添加到数据库中并检查是否自相交
77
+                //foreach (Polyline ent in objcoll)
78
+                //{
79
+                //    DocumentLock doclock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
80
+                //    using (Transaction trans = db.TransactionManager.StartTransaction())
81
+                //    {
82
+                //        BlockTable blocktable = trans.GetObject(db.BlockTableId, OpenMode.ForWrite) as BlockTable;
83
+                //        BlockTableRecord blocktablerecord = trans.GetObject(blocktable[BlockTableRecord.ModelSpace],
84
+                //            OpenMode.ForWrite) as BlockTableRecord;
85
+                //        blocktablerecord.AppendEntity(ent);
86
+                //        trans.AddNewlyCreatedDBObject(ent, true);
87
+                //        idcoll2.Add(ent.Id);
88
+                //        trans.Commit();
89
+                //    }
90
+                //    doclock.Dispose();
91
+                //}
92
+
93
+                for(int i =0;i< idcoll1.Count;i++)
94
+                {
95
+                    Polyline pll = BasicFunction.GetDBObject(idcoll1[i]) as Polyline;
96
+                    if (pll != null)
97
+                        SelfIntersectDetect(pll, out intersectPts);
98
+                    if (intersectPts.Count != 0)
99
+                    {
100
+                        j += intersectPts.Count;
101
+                        foreach (Point3d pt in intersectPts)
102
+                        {
103
+                            Makeflag(pt.X, pt.Y, pt.Z, flagradius, "线自相交点", idcoll1);
104
+                        }
105
+                    }
106
+                    else
107
+                        continue;
108
+                }
109
+
110
+                //将检查后的所有实体添加到块中并移动
111
+                Point3d Self = new Point3d();
112
+                Point3d MoveTo = SelfPt;
113
+                DBObjectCollection objcoll1 = MovebyBlock(idcoll1, out Self, MoveTo);
114
+
115
+                //将explode之后的实体添加到数据库中
116
+                //foreach (Entity ent in objcoll1)
117
+                //{
118
+                //    ObjectIdCollection idcoll = new ObjectIdCollection();
119
+
120
+                //    DocumentLock doclock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
121
+                //    using (Transaction trans = db.TransactionManager.StartTransaction())
122
+                //    {
123
+                //        BlockTable blocktable = trans.GetObject(db.BlockTableId, OpenMode.ForWrite) as BlockTable;
124
+                //        BlockTableRecord blocktablerecord = trans.GetObject(blocktable[BlockTableRecord.ModelSpace],
125
+                //            OpenMode.ForWrite) as BlockTableRecord;
126
+                //        blocktablerecord.AppendEntity(ent);
127
+                //        trans.AddNewlyCreatedDBObject(ent, true);
128
+                //        DrawOrderTable orderTable = trans.GetObject(blocktablerecord.DrawOrderTableId, OpenMode.ForWrite) as DrawOrderTable;
129
+                //        idcoll.Add(ent.Id);
130
+                //        orderTable.MoveToBottom(idcoll);
131
+                //        trans.Commit();
132
+                //    }
133
+                //    doclock.Dispose();
134
+                //}
135
+                ed.WriteMessage("有" + j.ToString() + "个交点");
136
+            }
137
+        }
138
+
139
+        /// <summary>
140
+        /// 线自相交检查
141
+        /// </summary>
142
+        private static bool SelfIntersectDetect(Polyline pPolyline, out Point3dCollection intersectPoint3Ds)
143
+        {
144
+            intersectPoint3Ds = new Point3dCollection();
145
+            try
146
+            {
147
+                // 自身与自身相交结果(包含顶点和相交点)
148
+                var intersectWithResult = new Point3dCollection();
149
+                pPolyline.IntersectWith(pPolyline, Intersect.OnBothOperands, intersectWithResult, IntPtr.Zero, IntPtr.Zero);
150
+
151
+                List<Point3d> itpts = new List<Point3d>();
152
+                List<Point3d> pts = new List<Point3d>();
153
+                for(int i =0;i<pPolyline.NumberOfVertices;i++)
154
+                    pts.Add(pPolyline.GetPoint3dAt(i));
155
+                for (int i = 0; i < intersectWithResult.Count; i++)
156
+                    itpts.Add(intersectWithResult[i]);
157
+                var result = itpts.Where(itpt =>!pts.Any(pt => pt.IsEqualTo(itpt))).ToList();
158
+                if (result.Count!=0)
159
+                {
160
+                    for (int i = 0; i < result.Count; i++)
161
+                        intersectPoint3Ds.Add(result[i]);
162
+                    return true;
163
+                }
164
+                return false;
165
+
166
+                #region 老方法
167
+                //// 存储顶点
168
+                //List<Point3d> vertices = new List<Point3d>();
169
+                //int count = pPolyline.NumberOfVertices;
170
+                //for (int j = 0; j < count; j++)
171
+                //{
172
+                //    Point3d pt = pPolyline.GetPoint3dAt(j);
173
+                //    //Point3d pt1 = new Point3d(Math.Round(pt.X, 6), Math.Round(pt.Y, 6), Math.Round(pt.Z, 6));
174
+                //    vertices.Add(pt);
175
+                //}
176
+                //for (int i = 0; i < count - 2; i++)
177
+                //{
178
+                //    LineSegment3d lsgment0 = pPolyline.GetLineSegmentAt(i);
179
+                //    for (int ii = i + 1; ii < count - 1; ii++)
180
+                //    {
181
+                //        LineSegment3d lsgment1 = pPolyline.GetLineSegmentAt(ii);
182
+                //        Point3d[] itpt = lsgment0.IntersectWith(lsgment1);
183
+                //        if (itpt != null)
184
+                //        {
185
+                //            foreach (Point3d pt in itpt)
186
+                //            {
187
+                //                intersectWithResult.Add(pt);
188
+                //            }
189
+                //        }
190
+                //    }
191
+                //    if (i == 0)
192
+                //    {
193
+                //        if (intersectWithResult.Count > 1)
194
+                //        {
195
+                //            for (int j = 0; j < intersectWithResult.Count - 1; j++)
196
+                //            {
197
+                //                for (int jj = j + 1; jj < intersectWithResult.Count; jj++)
198
+                //                {
199
+                //                    if (intersectWithResult[j] == intersectWithResult[jj] &&
200
+                //                        !intersectPoint3Ds.Contains(intersectWithResult[jj]))
201
+                //                    {
202
+                //                        intersectPoint3Ds.Add(intersectWithResult[jj]);
203
+                //                    }
204
+                //                }
205
+                //            }
206
+                //            foreach (Point3d pt in intersectWithResult)
207
+                //            {
208
+                //                if (pt == vertices[1])
209
+                //                    continue;
210
+                //                else
211
+                //                {
212
+                //                    if (!intersectPoint3Ds.Contains(pt))
213
+                //                        intersectPoint3Ds.Add(pt);
214
+                //                }
215
+                //            }
216
+                //        }
217
+                //    }
218
+                //    else if (i == count - 3)
219
+                //    {
220
+                //        if (intersectWithResult.Count > 1)
221
+                //        {
222
+                //            for (int j = 0; j < intersectWithResult.Count - 1; j++)
223
+                //            {
224
+                //                for (int jj = j + 1; jj < intersectWithResult.Count; jj++)
225
+                //                {
226
+                //                    if (intersectWithResult[j] == intersectWithResult[jj] &&
227
+                //                        !intersectPoint3Ds.Contains(intersectWithResult[jj]))
228
+                //                    {
229
+                //                        intersectPoint3Ds.Add(intersectWithResult[jj]);
230
+                //                    }
231
+                //                }
232
+                //            }
233
+                //            foreach (Point3d pt in intersectWithResult)
234
+                //            {
235
+                //                if (pt == vertices[i])
236
+                //                    continue;
237
+                //                else
238
+                //                {
239
+                //                    if (!intersectPoint3Ds.Contains(pt))
240
+                //                        intersectPoint3Ds.Add(pt);
241
+                //                }
242
+                //            }
243
+                //        }
244
+                //    }
245
+                //    else
246
+                //    {
247
+                //        if (intersectWithResult.Count > 1)
248
+                //        {
249
+                //            for (int j = 0; j < intersectWithResult.Count - 1; j++)
250
+                //            {
251
+                //                for (int jj = j + 1; jj < intersectWithResult.Count; jj++)
252
+                //                {
253
+                //                    if (intersectWithResult[j] == intersectWithResult[jj] &&
254
+                //                        !intersectPoint3Ds.Contains(intersectWithResult[jj]))
255
+                //                    {
256
+                //                        intersectPoint3Ds.Add(intersectWithResult[jj]);
257
+                //                    }
258
+                //                }
259
+                //            }
260
+                //            foreach (Point3d pt in intersectWithResult)
261
+                //            {
262
+                //                if (pt == vertices[i] || pt == vertices[i + 1])
263
+                //                    continue;
264
+                //                else
265
+                //                {
266
+                //                    if (!intersectPoint3Ds.Contains(pt))
267
+                //                        intersectPoint3Ds.Add(pt);
268
+                //                }
269
+                //            }
270
+                //        }
271
+                //    }
272
+                //    intersectWithResult.Clear();
273
+                //}
274
+                //return true;
275
+                #endregion
276
+            }
277
+            catch (Exception ex)
278
+            {
279
+                string str = ex.ToString();
280
+                Application.ShowAlertDialog(str);
281
+                return false;
282
+            }
283
+        }
284
+        #endregion
285
+
286
+
287
+
288
+
289
+        #region 线相交
290
+        public void Ints()
291
+        {
292
+            double flagradius = 4.0 * blc / 1000;//画圆标记半径
293
+
294
+            Document doc = Application.DocumentManager.MdiActiveDocument;
295
+            Database db = doc.Database;
296
+            Editor ed = Application.DocumentManager.MdiActiveDocument.Editor;
297
+            string layername = jqx + "," + sqx;
298
+
299
+            TypedValue[] value = new TypedValue[]
300
+            {
301
+                new TypedValue((int)DxfCode.LayerName,layername),
302
+                new TypedValue((int)DxfCode.Start,"LWPOLYLINE")
303
+            };//设置筛选条件
304
+            SelectionFilter filter = new SelectionFilter(value);//选择区域中全部对象
305
+            //PromptSelectionResult psr = ed.SelectAll(filter);// 要求在图形区域中手动选择对象
306
+            PromptSelectionResult psr = ed.GetSelection(filter);
307
+
308
+
309
+            if (psr.Status == PromptStatus.OK)
310
+            {
311
+                List<Point3d> intersectPts = new List<Point3d>();
312
+                int j = 0;
313
+
314
+                SelectionSet ss = psr.Value;
315
+                if (ss == null)
316
+                    return;
317
+
318
+                //创建标注相交点符号的图层
319
+                LayerControl layerscontrol = new LayerControl();
320
+                string layname = "线相交点";
321
+                if (!layerscontrol.haslayername(layname))
322
+                {
323
+                    colorgb col = new colorgb(0, 0, 255);
324
+                    layerscontrol.creatlayer(layname, col);
325
+                    layerscontrol.movelayertofront(layname);
326
+                }
327
+                else
328
+                    layerscontrol.movelayertofront(layname);
329
+
330
+
331
+                ObjectIdCollection idcoll1 = new ObjectIdCollection(ss.GetObjectIds());//需要添加到块中的实体
332
+                ObjectIdCollection idcoll2 = new ObjectIdCollection();//explode之后的实体
333
+                Point3d MoveToPt = new Point3d(0, 0, 0);//目标点
334
+                Point3d SelfPt = new Point3d();//基点
335
+
336
+                //将选中多段线添加到块中并移动
337
+                DBObjectCollection objcoll = MovebyBlock(idcoll1, out SelfPt, MoveToPt);
338
+
339
+                //将explode之后的实体重新添加到数据库中
340
+                //foreach (Entity ent in objcoll)
341
+                //{
342
+                //    DocumentLock doclock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
343
+                //    using (Transaction trans = db.TransactionManager.StartTransaction())
344
+                //    {
345
+                //        BlockTable blocktable = trans.GetObject(db.BlockTableId, OpenMode.ForWrite) as BlockTable;
346
+                //        BlockTableRecord blocktablerecord = trans.GetObject(blocktable[BlockTableRecord.ModelSpace],
347
+                //            OpenMode.ForWrite) as BlockTableRecord;
348
+                //        blocktablerecord.AppendEntity(ent);
349
+                //        trans.AddNewlyCreatedDBObject(ent, true);
350
+                //        idcoll2.Add(ent.Id);
351
+                //        trans.Commit();
352
+                //    }
353
+                //    doclock.Dispose();
354
+                //}
355
+
356
+                #region 检查线相交情况 cad
357
+                //检查线相交情况
358
+                int num = 0;
359
+                int numb = 0;//记录无法判断的实体数量
360
+                ObjectIdCollection objidcoll_check = new ObjectIdCollection();
361
+                List<Point3d> interpoint = new List<Point3d>();
362
+                for (int i = 0; i < objcoll.Count; i++)
363
+                {
364
+                    DocumentLock doclock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
365
+                    using (Transaction trans = db.TransactionManager.StartTransaction())
366
+                    {
367
+                        Polyline pll1 = trans.GetObject(objcoll[i].Id, OpenMode.ForWrite) as Polyline;
368
+                        ViewTableRecord currview = ed.GetCurrentView();
369
+                        double x = (pll1.StartPoint.X +pll1.EndPoint.X) / 2;
370
+                        double y = (pll1.StartPoint.Y +pll1.EndPoint.Y) / 2;
371
+                        currview.CenterPoint = new Point2d(x, y);
372
+                        currview.Width = Math.Abs(pll1.Bounds.Value.MaxPoint.X - pll1.Bounds.Value.MinPoint.X);
373
+                        currview.Height = Math.Abs(pll1.Bounds.Value.MaxPoint.Y - pll1.Bounds.Value.MinPoint.Y);
374
+                        ed.SetCurrentView(currview);
375
+                        ObjectIdCollection pllids = GetIntersectPlline(pll1, out num);//获取附近多段线
376
+                        numb = numb + num;
377
+
378
+                        //根据获取的多段线进行相交检查
379
+                        for (int ii = 0; ii < pllids.Count; ii++)
380
+                        {
381
+                            if (objidcoll_check.Contains(pllids[ii]))
382
+                                continue;
383
+                            Polyline pll2 = trans.GetObject(pllids[ii], OpenMode.ForWrite) as Polyline;
384
+                            EachIntersect(pll1, pll2, out intersectPts);
385
+                            foreach (Point3d pt in intersectPts)
386
+                            {
387
+                                if (!interpoint.Contains(pt))
388
+                                    interpoint.Add(pt);
389
+                            }
390
+                        }
391
+                        if (intersectPts.Count != 0)
392
+                            objidcoll_check.Add(objcoll[i].Id);
393
+
394
+                        trans.Commit();
395
+                        doclock.Dispose();
396
+                    }
397
+                }
398
+                #endregion
399
+
400
+                #region 检查线相交情况 hc
401
+                ////检查线相交情况
402
+                //ObjectIdCollection objidcoll_check = new ObjectIdCollection();
403
+                //List<Point3d> interpoint = new List<Point3d>();
404
+                //for (int i = 0; i < objcoll.Count - 1; i++)
405
+                //{
406
+                //    DocumentLock doclock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
407
+                //    using (Transaction trans = db.TransactionManager.StartTransaction())
408
+                //    {
409
+                //        Polyline pll1 = trans.GetObject(objcoll[i].Id, OpenMode.ForWrite) as Polyline;
410
+                //        for (int ii = i + 1; ii < objcoll.Count; ii++)
411
+                //        {
412
+                //            Polyline pll2 = trans.GetObject(objcoll[ii].Id, OpenMode.ForWrite) as Polyline;
413
+                //            EachIntersect(pll1, pll2, out intersectPts);
414
+                //            foreach (Point3d pt in intersectPts)
415
+                //            {
416
+                //                interpoint.Add(pt);
417
+                //            }
418
+                //        }
419
+                //        if (intersectPts.Count != 0)
420
+                //            objidcoll_check.Add(objcoll[i].Id);
421
+
422
+                //        trans.Commit();
423
+                //        doclock.Dispose();
424
+                //    }
425
+
426
+                #endregion
427
+                if (interpoint.Count != 0)
428
+                {
429
+                    j = interpoint.Count;
430
+                    foreach (Point3d pt in interpoint)
431
+                    {
432
+                        Makeflag(pt.X, pt.Y, pt.Z, flagradius, "线相交点", idcoll1);
433
+                    }
434
+                }
435
+                //}
436
+
437
+                //将检查后的实体都添加到块中并移动
438
+                Point3d Self = new Point3d();
439
+                Point3d MoveTo = SelfPt;
440
+                DBObjectCollection objcoll1 = MovebyBlock(idcoll1, out Self, MoveTo);
441
+
442
+                //将explode之后的实体添加到数据库中
443
+                //foreach (Entity ent in objcoll1)
444
+                //{
445
+                //    ObjectIdCollection idcoll = new ObjectIdCollection();
446
+
447
+                //    DocumentLock doclock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
448
+                //    using (Transaction trans = db.TransactionManager.StartTransaction())
449
+                //    {
450
+                //        BlockTable blocktable = trans.GetObject(db.BlockTableId, OpenMode.ForWrite) as BlockTable;
451
+                //        BlockTableRecord blocktablerecord = trans.GetObject(blocktable[BlockTableRecord.ModelSpace],
452
+                //            OpenMode.ForWrite) as BlockTableRecord;
453
+                //        blocktablerecord.AppendEntity(ent);
454
+                //        trans.AddNewlyCreatedDBObject(ent, true);
455
+                //        DrawOrderTable orderTable = trans.GetObject(blocktablerecord.DrawOrderTableId, OpenMode.ForWrite) as DrawOrderTable;
456
+                //        idcoll.Add(ent.Id);
457
+                //        orderTable.MoveToBottom(idcoll);
458
+                //        trans.Commit();
459
+                //    }
460
+                //    doclock.Dispose();
461
+                //}
462
+                ed.WriteMessage("有" + j.ToString() + "个交点");
463
+                dynamic acadApp = Application.AcadApplication;
464
+                acadApp.ZoomExtents();
465
+                //ed.WriteMessage("\n有" + numb.ToString() + "处无法判断");
466
+            }
467
+        }
468
+
469
+
470
+        /// <summary>
471
+        /// 获取附近多段线
472
+        /// </summary>
473
+        private static ObjectIdCollection GetIntersectPlline(Polyline pll, out int num)
474
+        {
475
+            num = 0;
476
+            ObjectIdCollection objidcoll = new ObjectIdCollection();
477
+            DBObjectCollection objcoll = new DBObjectCollection();
478
+            Editor editor = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
479
+            Point3dCollection ptcoll = new Point3dCollection();
480
+
481
+            //获取包围盒最大点和最小点
482
+            Point3d min = pll.Bounds.Value.MinPoint;
483
+            Point3d max = pll.Bounds.Value.MaxPoint;
484
+
485
+            TypedValue[] vl = new TypedValue[]
486
+            {
487
+                new TypedValue((int)DxfCode.LayerName,jqx+","+sqx),
488
+                new TypedValue((int)DxfCode.Start,"LWPOLYLINE")
489
+            };//设置筛选条件
490
+            SelectionFilter selefilter = new SelectionFilter(vl);//选择区域中全部对象
491
+            //PromptSelectionResult psr = ed.SelectAll(filter);// 要求在图形区域中手动选择对象
492
+
493
+            for (int i = 0; i < pll.NumberOfVertices; i++)
494
+            {
495
+                ptcoll.Add(pll.GetPoint3dAt(i));
496
+            }
497
+
498
+            //SelectFence()无法找到不在当前视图的实体,需要将视图转移到实体所在的位置
499
+            //dynamic acadApp = Application.AcadApplication;
500
+            //acadApp.ZoomExtents();
501
+            //PromptSelectionResult seleresult = editor.SelectCrossingWindow(min, max, selefilter);
502
+            PromptSelectionResult seleresult = editor.SelectFence(ptcoll, selefilter);
503
+            //acadApp.ZoomPrevious();
504
+
505
+
506
+            if (seleresult.Status == PromptStatus.OK)
507
+            {
508
+                SelectionSet selectionset = seleresult.Value;
509
+                objidcoll = new ObjectIdCollection(selectionset.GetObjectIds());
510
+                if (objidcoll.Contains(pll.Id))
511
+                    objidcoll.Remove(pll.Id);
512
+            }
513
+            return objidcoll;
514
+        }
515
+
516
+
517
+        /// <summary>
518
+        /// 线相交检查
519
+        /// </summary>
520
+        private static bool EachIntersect(Polyline oPolyline, Polyline tPolyline, out List<Point3d> intersectPoint3Ds)
521
+        {
522
+            intersectPoint3Ds = new List<Point3d>();
523
+            try
524
+            {
525
+                //两线相交结果
526
+                var intersectWithResult = new Point3dCollection();
527
+                double temp = oPolyline.Elevation;
528
+                oPolyline.Elevation = tPolyline.Elevation;
529
+                oPolyline.IntersectWith(tPolyline, Intersect.OnBothOperands, intersectWithResult, IntPtr.Zero, IntPtr.Zero);
530
+
531
+                if (intersectWithResult.Count!=0)
532
+                {
533
+                    for (int i = 0; i < intersectWithResult.Count; i++)
534
+                        intersectPoint3Ds.Add(intersectWithResult[i]);
535
+                }
536
+                oPolyline.Elevation = temp;
537
+                return true;
538
+            }
539
+            catch (Exception ex)
540
+            {
541
+                string str = ex.ToString();
542
+                Application.ShowAlertDialog(str);
543
+                return false;
544
+            }
545
+        }
546
+        #endregion
547
+
548
+
549
+        /// <summary>
550
+        /// 将多段线添加到块后将块移动到目标位置并explode
551
+        /// </summary>
552
+        private static DBObjectCollection MovebyBlock(ObjectIdCollection idcoll, out Point3d SelfPt, Point3d MoveToPt)
553
+        {
554
+            Document doc = Application.DocumentManager.MdiActiveDocument;
555
+            Database db = doc.Database;
556
+
557
+            DBObjectCollection objcoll = new DBObjectCollection();
558
+
559
+            DocumentLock docLock = doc.LockDocument();
560
+            try
561
+            {
562
+                using (Transaction trans = db.TransactionManager.StartTransaction())
563
+                {
564
+                    // 获取第一个实体作为基准点
565
+                    Entity firstEnt = trans.GetObject(idcoll[0], OpenMode.ForRead) as Entity;
566
+                    if (firstEnt is Polyline firstPll)
567
+                    {
568
+                        SelfPt = firstPll.StartPoint;
569
+                    }
570
+                    else
571
+                    {
572
+                        SelfPt = firstEnt.GeometricExtents.MinPoint;
573
+                    }
574
+
575
+                    // 计算位移向量
576
+                    Vector3d displacement = SelfPt.GetVectorTo(MoveToPt);
577
+
578
+                    // 创建变换矩阵
579
+                    Matrix3d transform = Matrix3d.Displacement(displacement);
580
+
581
+                    // 移动所有实体
582
+                    foreach (ObjectId id in idcoll)
583
+                    {
584
+                        Entity ent = trans.GetObject(id, OpenMode.ForWrite) as Entity;
585
+                        if (ent != null)
586
+                        {
587
+                            ent.TransformBy(transform);
588
+
589
+                            // 如果需要分解后的实体,可以克隆并变换
590
+                            if (ent is Polyline pll)
591
+                            {
592
+                                // 可以在这里进行其他处理
593
+                            }
594
+                        }
595
+                    }
596
+                   
597
+                    foreach (ObjectId id in idcoll)
598
+                    {
599
+                        Entity ent = trans.GetObject(id, OpenMode.ForRead) as Entity;
600
+                        if (ent != null)
601
+                            objcoll.Add(ent);
602
+                    }
603
+
604
+                    trans.Commit();
605
+                }
606
+            }
607
+            finally
608
+            {
609
+                docLock.Dispose();
610
+            }
611
+
612
+            return objcoll;
613
+
614
+            //Document doc = Application.DocumentManager.MdiActiveDocument;
615
+            //Database db = doc.Database;
616
+
617
+            //DBObjectCollection objcoll = new DBObjectCollection();//explode后的实体
618
+            //ObjectId btrid = new ObjectId();//块id
619
+
620
+
621
+            //DocumentLock documentlock1 = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
622
+            //using (Transaction trans = db.TransactionManager.StartTransaction())
623
+            //{
624
+            //    BlockTable bt = trans.GetObject(db.BlockTableId, OpenMode.ForWrite) as BlockTable;
625
+            //    BlockTableRecord btr = new BlockTableRecord();
626
+            //    Polyline pll = trans.GetObject(idcoll[0], OpenMode.ForRead) as Polyline;
627
+            //    btr.Name = "BLK";
628
+            //    bt.UpgradeOpen();
629
+            //    btrid = bt.Add(btr);
630
+            //    trans.AddNewlyCreatedDBObject(btr, true);
631
+            //    btr.AssumeOwnershipOf(idcoll);
632
+            //    btr.Origin = pll.StartPoint;
633
+            //    SelfPt = pll.StartPoint;
634
+
635
+            //    BlockTableRecord ms = (BlockTableRecord)trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
636
+            //    BlockReference br = new BlockReference(pll.StartPoint, btrid);
637
+            //    Vector3d acVec3d = SelfPt.GetVectorTo(MoveToPt);
638
+            //    br.TransformBy(Matrix3d.Displacement(acVec3d));
639
+
640
+            //    ms.AppendEntity(br);
641
+            //    trans.AddNewlyCreatedDBObject(br, true);
642
+            //    br.Explode(objcoll);
643
+            //    btr.UpgradeOpen();
644
+            //    btr.Erase();
645
+            //    br.Erase();
646
+            //    trans.Commit();
647
+            //}
648
+            //documentlock1.Dispose();
649
+            //return objcoll;
650
+        }
651
+
652
+        /// <summary>
653
+        /// 错误标记
654
+        /// </summary>
655
+        private void Makeflag(double x, double y, double z, double radius, string layername, ObjectIdCollection idcoll)
656
+        {
657
+            Database database = HostApplicationServices.WorkingDatabase;
658
+            DocumentLock doclock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
659
+            using (Transaction traction = database.TransactionManager.StartTransaction())
660
+            {
661
+                BlockTable blocktable = traction.GetObject(database.BlockTableId,OpenMode.ForWrite) as BlockTable;
662
+                BlockTableRecord blocktablerecord = traction.GetObject(blocktable[BlockTableRecord.ModelSpace],
663
+                                               OpenMode.ForWrite) as BlockTableRecord;
664
+                Circle circ = new Circle();
665
+                circ.Center = new Point3d(x, y, z);
666
+                circ.Radius = radius;
667
+                circ.Normal = new Vector3d(0, 0, 1);
668
+                circ.SetDatabaseDefaults();
669
+                circ.Layer = layername;
670
+                blocktablerecord.AppendEntity(circ);
671
+                traction.AddNewlyCreatedDBObject(circ, true);
672
+                idcoll.Add(circ.Id);
673
+                traction.Commit();
674
+                //traction.Dispose();
675
+            }
676
+            doclock.Dispose();
677
+        }
678
+    }
679
+}

+ 222
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/JQXLabel_grid.Designer.cs 查看文件

@@ -0,0 +1,222 @@
1
+
2
+namespace CADTools
3
+{
4
+    partial class JQXLabel_grid
5
+    {
6
+        /// <summary>
7
+        /// Required designer variable.
8
+        /// </summary>
9
+        private System.ComponentModel.IContainer components = null;
10
+
11
+        /// <summary>
12
+        /// Clean up any resources being used.
13
+        /// </summary>
14
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
15
+        protected override void Dispose(bool disposing)
16
+        {
17
+            if (disposing && (components != null))
18
+            {
19
+                components.Dispose();
20
+            }
21
+            base.Dispose(disposing);
22
+        }
23
+
24
+        #region Windows Form Designer generated code
25
+
26
+        /// <summary>
27
+        /// Required method for Designer support - do not modify
28
+        /// the contents of this method with the code editor.
29
+        /// </summary>
30
+        private void InitializeComponent()
31
+        {
32
+            this.label2 = new System.Windows.Forms.Label();
33
+            this.label3 = new System.Windows.Forms.Label();
34
+            this.comboBox_jqx = new System.Windows.Forms.ComboBox();
35
+            this.comboBox_bz = new System.Windows.Forms.ComboBox();
36
+            this.button_ok = new System.Windows.Forms.Button();
37
+            this.comboBox_tk = new System.Windows.Forms.ComboBox();
38
+            this.label4 = new System.Windows.Forms.Label();
39
+            this.comboBox_blc = new System.Windows.Forms.ComboBox();
40
+            this.label5 = new System.Windows.Forms.Label();
41
+            this.label1 = new System.Windows.Forms.Label();
42
+            this.comboBox_sqx = new System.Windows.Forms.ComboBox();
43
+            this.label6 = new System.Windows.Forms.Label();
44
+            this.textBox_decimal = new System.Windows.Forms.TextBox();
45
+            this.label7 = new System.Windows.Forms.Label();
46
+            this.SuspendLayout();
47
+            // 
48
+            // label2
49
+            // 
50
+            this.label2.AutoSize = true;
51
+            this.label2.Location = new System.Drawing.Point(56, 42);
52
+            this.label2.Name = "label2";
53
+            this.label2.Size = new System.Drawing.Size(127, 15);
54
+            this.label2.TabIndex = 1;
55
+            this.label2.Text = "计曲线所在图层:";
56
+            // 
57
+            // label3
58
+            // 
59
+            this.label3.AutoSize = true;
60
+            this.label3.Location = new System.Drawing.Point(68, 266);
61
+            this.label3.Name = "label3";
62
+            this.label3.Size = new System.Drawing.Size(112, 15);
63
+            this.label3.TabIndex = 2;
64
+            this.label3.Text = "标注所在图层:";
65
+            // 
66
+            // comboBox_jqx
67
+            // 
68
+            this.comboBox_jqx.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
69
+            this.comboBox_jqx.FormattingEnabled = true;
70
+            this.comboBox_jqx.Location = new System.Drawing.Point(189, 39);
71
+            this.comboBox_jqx.Name = "comboBox_jqx";
72
+            this.comboBox_jqx.Size = new System.Drawing.Size(173, 23);
73
+            this.comboBox_jqx.TabIndex = 4;
74
+            // 
75
+            // comboBox_bz
76
+            // 
77
+            this.comboBox_bz.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
78
+            this.comboBox_bz.FormattingEnabled = true;
79
+            this.comboBox_bz.Location = new System.Drawing.Point(186, 263);
80
+            this.comboBox_bz.Name = "comboBox_bz";
81
+            this.comboBox_bz.Size = new System.Drawing.Size(173, 23);
82
+            this.comboBox_bz.TabIndex = 5;
83
+            // 
84
+            // button_ok
85
+            // 
86
+            this.button_ok.Location = new System.Drawing.Point(162, 346);
87
+            this.button_ok.Name = "button_ok";
88
+            this.button_ok.Size = new System.Drawing.Size(75, 31);
89
+            this.button_ok.TabIndex = 6;
90
+            this.button_ok.Text = "确 定";
91
+            this.button_ok.UseVisualStyleBackColor = true;
92
+            this.button_ok.Click += new System.EventHandler(this.button_ok_Click);
93
+            // 
94
+            // comboBox_tk
95
+            // 
96
+            this.comboBox_tk.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
97
+            this.comboBox_tk.FormattingEnabled = true;
98
+            this.comboBox_tk.Location = new System.Drawing.Point(186, 149);
99
+            this.comboBox_tk.Name = "comboBox_tk";
100
+            this.comboBox_tk.Size = new System.Drawing.Size(173, 23);
101
+            this.comboBox_tk.TabIndex = 8;
102
+            // 
103
+            // label4
104
+            // 
105
+            this.label4.AutoSize = true;
106
+            this.label4.Location = new System.Drawing.Point(68, 152);
107
+            this.label4.Name = "label4";
108
+            this.label4.Size = new System.Drawing.Size(112, 15);
109
+            this.label4.TabIndex = 7;
110
+            this.label4.Text = "图框所在图层:";
111
+            // 
112
+            // comboBox_blc
113
+            // 
114
+            this.comboBox_blc.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
115
+            this.comboBox_blc.FormattingEnabled = true;
116
+            this.comboBox_blc.Items.AddRange(new object[] {
117
+            "1:500",
118
+            "1:1000",
119
+            "1:2000",
120
+            "1:5000",
121
+            "1:10000"});
122
+            this.comboBox_blc.Location = new System.Drawing.Point(186, 207);
123
+            this.comboBox_blc.Name = "comboBox_blc";
124
+            this.comboBox_blc.Size = new System.Drawing.Size(173, 23);
125
+            this.comboBox_blc.TabIndex = 10;
126
+            // 
127
+            // label5
128
+            // 
129
+            this.label5.AutoSize = true;
130
+            this.label5.Location = new System.Drawing.Point(113, 210);
131
+            this.label5.Name = "label5";
132
+            this.label5.Size = new System.Drawing.Size(67, 15);
133
+            this.label5.TabIndex = 9;
134
+            this.label5.Text = "比例尺:";
135
+            // 
136
+            // label1
137
+            // 
138
+            this.label1.AutoSize = true;
139
+            this.label1.Location = new System.Drawing.Point(59, 94);
140
+            this.label1.Name = "label1";
141
+            this.label1.Size = new System.Drawing.Size(127, 15);
142
+            this.label1.TabIndex = 11;
143
+            this.label1.Text = "首曲线所在图层:";
144
+            // 
145
+            // comboBox_sqx
146
+            // 
147
+            this.comboBox_sqx.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
148
+            this.comboBox_sqx.FormattingEnabled = true;
149
+            this.comboBox_sqx.Location = new System.Drawing.Point(189, 94);
150
+            this.comboBox_sqx.Name = "comboBox_sqx";
151
+            this.comboBox_sqx.Size = new System.Drawing.Size(173, 23);
152
+            this.comboBox_sqx.TabIndex = 12;
153
+            // 
154
+            // label6
155
+            // 
156
+            this.label6.AutoSize = true;
157
+            this.label6.Location = new System.Drawing.Point(130, 306);
158
+            this.label6.Name = "label6";
159
+            this.label6.Size = new System.Drawing.Size(37, 15);
160
+            this.label6.TabIndex = 13;
161
+            this.label6.Text = "保留";
162
+            // 
163
+            // textBox_decimal
164
+            // 
165
+            this.textBox_decimal.Location = new System.Drawing.Point(173, 303);
166
+            this.textBox_decimal.Name = "textBox_decimal";
167
+            this.textBox_decimal.Size = new System.Drawing.Size(42, 25);
168
+            this.textBox_decimal.TabIndex = 14;
169
+            // 
170
+            // label7
171
+            // 
172
+            this.label7.AutoSize = true;
173
+            this.label7.Location = new System.Drawing.Point(221, 306);
174
+            this.label7.Name = "label7";
175
+            this.label7.Size = new System.Drawing.Size(52, 15);
176
+            this.label7.TabIndex = 15;
177
+            this.label7.Text = "位小数";
178
+            // 
179
+            // JQXLabel_grid
180
+            // 
181
+            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
182
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
183
+            this.ClientSize = new System.Drawing.Size(484, 413);
184
+            this.Controls.Add(this.label7);
185
+            this.Controls.Add(this.textBox_decimal);
186
+            this.Controls.Add(this.label6);
187
+            this.Controls.Add(this.comboBox_sqx);
188
+            this.Controls.Add(this.label1);
189
+            this.Controls.Add(this.comboBox_blc);
190
+            this.Controls.Add(this.label5);
191
+            this.Controls.Add(this.comboBox_tk);
192
+            this.Controls.Add(this.label4);
193
+            this.Controls.Add(this.button_ok);
194
+            this.Controls.Add(this.comboBox_bz);
195
+            this.Controls.Add(this.comboBox_jqx);
196
+            this.Controls.Add(this.label3);
197
+            this.Controls.Add(this.label2);
198
+            this.Name = "JQXLabel_grid";
199
+            this.Text = "计曲线高程标注(网格版)";
200
+            this.Load += new System.EventHandler(this.JQXLabel_grid_Load);
201
+            this.ResumeLayout(false);
202
+            this.PerformLayout();
203
+
204
+        }
205
+
206
+        #endregion
207
+        private System.Windows.Forms.Label label2;
208
+        private System.Windows.Forms.Label label3;
209
+        private System.Windows.Forms.ComboBox comboBox_jqx;
210
+        private System.Windows.Forms.ComboBox comboBox_bz;
211
+        private System.Windows.Forms.Button button_ok;
212
+        private System.Windows.Forms.ComboBox comboBox_tk;
213
+        private System.Windows.Forms.Label label4;
214
+        private System.Windows.Forms.ComboBox comboBox_blc;
215
+        private System.Windows.Forms.Label label5;
216
+        private System.Windows.Forms.Label label1;
217
+        private System.Windows.Forms.ComboBox comboBox_sqx;
218
+        private System.Windows.Forms.Label label6;
219
+        private System.Windows.Forms.TextBox textBox_decimal;
220
+        private System.Windows.Forms.Label label7;
221
+    }
222
+}

+ 993
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/JQXLabel_grid.cs 查看文件

@@ -0,0 +1,993 @@
1
+using Autodesk.AutoCAD.ApplicationServices;
2
+using Autodesk.AutoCAD.DatabaseServices;
3
+using Autodesk.AutoCAD.EditorInput;
4
+using Autodesk.AutoCAD.Geometry;
5
+using GeoAPI.Geometries;
6
+using NetTopologySuite.Geometries;
7
+using NetTopologySuite.Operation.Linemerge;
8
+using System;
9
+using System.Collections.Generic;
10
+using System.ComponentModel;
11
+using System.Data;
12
+using System.Drawing;
13
+using System.IO;
14
+using System.Linq;
15
+using System.Text;
16
+using System.Threading.Tasks;
17
+using System.Windows.Forms;
18
+
19
+namespace CADTools
20
+{
21
+    public partial class JQXLabel_grid : Form
22
+    {
23
+        public JQXLabel_grid()
24
+        {
25
+            InitializeComponent();
26
+        }
27
+
28
+        public class PointPolylinePair
29
+        {
30
+            public Point3d Point { get; set; }
31
+            public Polyline Polyline { get; set; }
32
+            public double curvature { get; set; }
33
+        }
34
+
35
+        int nodirection = 0;
36
+        private void JQXLabel_grid_Load(object sender, EventArgs e)
37
+        {
38
+            //自动填充下拉框
39
+            Database database = Autodesk.AutoCAD.DatabaseServices.HostApplicationServices.WorkingDatabase;
40
+            using (Transaction traction = database.TransactionManager.StartTransaction())
41
+            {
42
+                //存放所有图层名
43
+                List<string> alllayername = new List<string>();
44
+                LayerTable layertable = traction.GetObject(database.LayerTableId, OpenMode.ForRead) as LayerTable;
45
+                foreach (ObjectId objid in layertable)
46
+                {
47
+                    LayerTableRecord layertablerecord = traction.GetObject(objid, OpenMode.ForRead) as LayerTableRecord;
48
+                    alllayername.Add(layertablerecord.Name);
49
+                }
50
+
51
+                alllayername.Sort();
52
+                for (int i = 0; i < alllayername.Count; i++)
53
+                {
54
+                    this.comboBox_jqx.Items.Add(alllayername[i]);
55
+                    this.comboBox_sqx.Items.Add(alllayername[i]);
56
+                    this.comboBox_bz.Items.Add(alllayername[i]);
57
+                    this.comboBox_tk.Items.Add(alllayername[i]);
58
+                }
59
+                if (alllayername.Contains("8120"))
60
+                {
61
+                    int index = alllayername.IndexOf("8120");
62
+                    this.comboBox_jqx.SelectedIndex = index;
63
+                }
64
+                if (alllayername.Contains("8110"))
65
+                {
66
+                    int index = alllayername.IndexOf("8110");
67
+                    this.comboBox_sqx.SelectedIndex = index;
68
+                }
69
+                if (alllayername.Contains("tk") || alllayername.Contains("TK"))
70
+                {
71
+                    if (alllayername.Contains("tk"))
72
+                    {
73
+                        int index = alllayername.IndexOf("tk");
74
+                        this.comboBox_tk.SelectedIndex = index;
75
+                    }
76
+                    else
77
+                    {
78
+                        int index = alllayername.IndexOf("TK");
79
+                        this.comboBox_tk.SelectedIndex = index;
80
+                    }
81
+                }
82
+                traction.Commit();
83
+            }
84
+            this.textBox_decimal.Text = "0";
85
+        }
86
+
87
+        private void button_ok_Click(object sender, EventArgs e)
88
+        {
89
+            if (comboBox_jqx.Text == "")
90
+            {
91
+                MessageBox.Show("计曲线图层不能为空!");
92
+                return;
93
+            }
94
+            if (comboBox_sqx.Text == "")
95
+            {
96
+                MessageBox.Show("首曲线图层不能为空!");
97
+                return;
98
+            }
99
+            if (comboBox_tk.Text == "")
100
+            {
101
+                MessageBox.Show("图框图层不能为空!");
102
+                return;
103
+            }
104
+            if (comboBox_blc.Text == "")
105
+            {
106
+                MessageBox.Show("比例尺不能为空!");
107
+                return;
108
+            }
109
+            if (comboBox_bz.Text == "")
110
+            {
111
+                MessageBox.Show("等高线标注图层不能为空!");
112
+                return;
113
+            }
114
+            jqxLabelbyGrid();
115
+            MessageBox.Show("标注完成。\n有" + nodirection.ToString() + "处无法确定方向,移动到“无法确定方向”图层");
116
+            this.Close();
117
+        }
118
+
119
+        private void jqxLabelbyGrid()
120
+        {
121
+            //计曲线
122
+            string jqx = comboBox_jqx.Text;
123
+            //图框
124
+            string tk = comboBox_tk.Text;
125
+            //比例尺
126
+            string blctext = comboBox_blc.Text;
127
+            int blcindex = blctext.LastIndexOf(':');
128
+            string strblc = blctext.Substring(blcindex + 1);
129
+            int blc = Convert.ToInt32(strblc);
130
+            //图框顶点列表
131
+            List<Polyline> tks = new List<Polyline>();
132
+
133
+            Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
134
+            Database db = Autodesk.AutoCAD.DatabaseServices.HostApplicationServices.WorkingDatabase;
135
+            //获取所有图框,记录图框的最大点和最小点
136
+            TypedValue[] typedvalue = new TypedValue[2];
137
+            typedvalue.SetValue(new TypedValue((int)DxfCode.LayerName, tk), 0);
138
+            typedvalue.SetValue(new TypedValue((int)DxfCode.Start, "LWPOLYLINE"), 1);
139
+            SelectionFilter selectionfilter = new SelectionFilter(typedvalue);
140
+            PromptSelectionResult psr = ed.SelectAll(selectionfilter);
141
+            if (psr.Status == PromptStatus.OK)
142
+            {
143
+                SelectionSet ss = psr.Value;
144
+                ObjectId[] tkids = ss.GetObjectIds();
145
+                for (int i = 0; i < tkids.Length; i++)
146
+                {
147
+                    using (Transaction tr = db.TransactionManager.StartTransaction())
148
+                    {
149
+                        Polyline pl = tr.GetObject(tkids[i], OpenMode.ForRead) as Polyline;
150
+                        tks.Add(pl);
151
+                        tr.Commit();
152
+                    }
153
+                }
154
+            }
155
+            else
156
+            {
157
+                MessageBox.Show("未找到图框!");
158
+                return;
159
+            }
160
+
161
+            //创建标记字体
162
+            CreateSheetMap cs = new CreateSheetMap();
163
+            cs.createTextStyle();
164
+            ObjectId HZ = cs.gettextstyleID("HZ");
165
+            //遍历图框顶点列表,按顶点范围搜索等高线
166
+            for (int i = 0; i < tks.Count; i++)
167
+            {
168
+                ZoomView(ed, tks[i].Bounds.Value.MinPoint, tks[i].Bounds.Value.MaxPoint);
169
+                List<Polyline> pllist = new List<Polyline>();
170
+                TypedValue[] typedvalue_pl = new TypedValue[2];
171
+                typedvalue_pl.SetValue(new TypedValue((int)DxfCode.LayerName, jqx), 0);
172
+                typedvalue_pl.SetValue(new TypedValue((int)DxfCode.Start, "LWPOLYLINE"), 1);
173
+                SelectionFilter selectionfilter_pl = new SelectionFilter(typedvalue_pl);
174
+                PromptSelectionResult psr_pl = ed.SelectCrossingWindow(tks[i].Bounds.Value.MinPoint, tks[i].Bounds.Value.MaxPoint, selectionfilter_pl);
175
+                if (psr_pl.Status == PromptStatus.OK)
176
+                {
177
+                    SelectionSet ss = psr_pl.Value;
178
+                    ObjectId[] plids = ss.GetObjectIds();
179
+
180
+                    using (Transaction tr = db.TransactionManager.StartTransaction())
181
+                    {
182
+                        for (int ii = 0; ii < plids.Length; ii++)
183
+                        {
184
+                            Polyline pl = tr.GetObject(plids[ii], OpenMode.ForRead) as Polyline;
185
+                            if (IsPolylineInsideOrIntersecting(pl, tks[i].Bounds.Value.MinPoint, tks[i].Bounds.Value.MaxPoint))
186
+                            {
187
+                                pllist.Add(pl);
188
+                            }
189
+                        }
190
+                        tr.Commit();
191
+                    }
192
+
193
+                    //绘制图框
194
+                    double x = (tks[i].Bounds.Value.MinPoint.X + tks[i].Bounds.Value.MaxPoint.X) / 2;
195
+                    double y = (tks[i].Bounds.Value.MinPoint.Y + tks[i].Bounds.Value.MaxPoint.Y) / 2;
196
+                    Point3d centralpt = new Point3d(x, y, 0);
197
+                    if (pllist.Count > 0)
198
+                    {
199
+                        //var result = getPll(pllist, tk1, centralpt);
200
+                        var target = getPosition(pllist, tks[i], centralpt);
201
+                        makeMark(target, db, blc, centralpt, HZ);
202
+                        pllist.Clear();
203
+                    }
204
+                }
205
+            }
206
+        }
207
+
208
+        private PointPolylinePair getPosition(List<Polyline> pllist, Polyline tk, Point3d central)
209
+        {
210
+            List<PointPolylinePair> ptpllist = new List<PointPolylinePair>();
211
+            List<PointPolylinePair> ptpllist1 = new List<PointPolylinePair>();
212
+            List<Polyline> plinsidetk = new List<Polyline>();
213
+            Polyline labelpll = new Polyline();
214
+            int index = 0;
215
+            // 找到距离中心点最近的等高线
216
+            var pllist_sorted = pllist.OrderBy(c => c.GetClosestPointTo(new Point3d(central.X, central.Y, c.Elevation), new Vector3d(0, 0, 1), false)
217
+                                               .DistanceTo(new Point3d(central.X, central.Y, c.Elevation))).ToList();
218
+            while (ptpllist1.Count == 0)
219
+            {
220
+                labelpll = pllist_sorted[index];
221
+                plinsidetk = GetPolylineInsideFrame(labelpll, tk);
222
+                ptpllist1.Clear();
223
+
224
+                for (int i = 0; i < plinsidetk.Count; i++)
225
+                {
226
+                    Polyline pl_temp = plinsidetk[i];
227
+
228
+                    // 获取顶点数量
229
+                    int vertexCount = pl_temp.NumberOfVertices;
230
+
231
+                    // 每5个点取一个点
232
+                    int step = 5;
233
+                    int sampleCount = Math.Max(1, vertexCount / step);
234
+
235
+                    // 存储连续平缓点的索引
236
+                    List<int> consecutiveFlatIndices = new List<int>();
237
+
238
+                    for (int j = 1; j <= sampleCount; j++)
239
+                    {
240
+                        // 计算顶点索引
241
+                        int vertexIndex = Math.Min(j * step, vertexCount - 1);
242
+                        double curvature = GetCurvatureAtVertex(pl_temp, vertexIndex, step);
243
+                        // 检查是否为平缓点
244
+                        if (curvature <= 0.05)
245
+                        {
246
+                            consecutiveFlatIndices.Add(vertexIndex);
247
+
248
+                            // 检查是否有连续10个平缓点
249
+                            if (consecutiveFlatIndices.Count >= 2)
250
+                            {
251
+                                // 使用弦高差法验证是否整体平缓
252
+                                bool isOverallFlat = ValidateFlatRegionByChordHeight(pl_temp, consecutiveFlatIndices);
253
+
254
+                                if (isOverallFlat)
255
+                                {
256
+                                    // 取中间点
257
+                                    int middleIndex = consecutiveFlatIndices[consecutiveFlatIndices.Count / 2];
258
+                                    Point3d middlePoint = pl_temp.GetPoint3dAt(middleIndex);
259
+
260
+                                    PointPolylinePair pair = new PointPolylinePair();
261
+                                    pair.Point = middlePoint;
262
+                                    pair.Polyline = pllist_sorted[index];
263
+                                    pair.curvature = curvature;
264
+                                    ptpllist.Add(pair);
265
+
266
+                                    // 清空连续记录,避免重复添加
267
+                                    consecutiveFlatIndices.Clear();
268
+                                }
269
+                                else
270
+                                {
271
+                                    // 如果不平缓,清空并继续,避免从这个区域继续累积
272
+                                    consecutiveFlatIndices.Clear();
273
+                                }
274
+                            }
275
+                        }
276
+                        else
277
+                        {
278
+                            // 遇到非平缓点,重置连续计数
279
+                            consecutiveFlatIndices.Clear();
280
+                        }
281
+                    }
282
+                }
283
+
284
+                // 筛选长度大于15的等高线对应的点
285
+                ptpllist1 = ptpllist.Where(p => p.Polyline.Length > 15).ToList();
286
+                index++;
287
+                if (index == pllist_sorted.Count) break;
288
+            }
289
+            PointPolylinePair target = new PointPolylinePair();
290
+
291
+            // 处理 ptpllist1 和 ptpllist 为空的情况
292
+            if (ptpllist1.Count == 0)
293
+            {
294
+                // 如果 ptpllist 不为空,按曲率排序取最小的
295
+                if (ptpllist.Count > 0)
296
+                {
297
+                    target = ptpllist.OrderBy(p => p.curvature).First();
298
+                }
299
+                else
300
+                {
301
+                    // 如果 ptpllist 也为空,获取离中心点最近点
302
+                    var pl_label = pllist.OrderBy(c => c.GetClosestPointTo(new Point3d(central.X, central.Y, c.Elevation), new Vector3d(0, 0, 1), false)
303
+                                            .DistanceTo(new Point3d(central.X, central.Y, c.Elevation))).First();
304
+                    PointPolylinePair pair = new PointPolylinePair();
305
+                    pair.Point = pl_label.GetClosestPointTo(central, new Vector3d(0, 0, 1), false);
306
+                    pair.Polyline = pl_label;
307
+                    pair.curvature = 0;
308
+                    target = pair;
309
+                }
310
+            }
311
+            else if (ptpllist1.Count > 0)
312
+            {
313
+                target = ptpllist1.OrderBy(p => p.Point.DistanceTo(central)).First();
314
+            }
315
+            else
316
+            {
317
+                // ptpllist1 为空但还有等高线未处理,返回最接近中心的点
318
+                target = ptpllist.OrderBy(p => p.Point.DistanceTo(central)).FirstOrDefault();
319
+            }
320
+
321
+            return target;
322
+        }
323
+
324
+        #region
325
+        //private Polyline mergePl(List<Polyline> plllist, Polyline tk)
326
+        //{
327
+        //    List<Polyline> interse = new List<Polyline>();
328
+        //    List<Polyline> result = new List<Polyline>(plllist);
329
+        //    for (int i = 0; i < plllist.Count - 1; i++)
330
+        //    {
331
+        //        Point3d start1 = plllist[i].GetPoint3dAt(0);
332
+        //        Point3d end1 = plllist[i].GetPoint3dAt(plllist[i].NumberOfVertices - 1);
333
+        //        for (int j = i + 1; j < plllist.Count; j++)
334
+        //        {
335
+        //            Point3d start2 = plllist[j].GetPoint3dAt(0);
336
+        //            Point3d end2 = plllist[j].GetPoint3dAt(plllist[j].NumberOfVertices - 1);
337
+        //            if (start1 == start2 || start1 == end2 || end1 == start2 || end1 == end2)
338
+        //            {
339
+        //                interse.Add(plllist[i]);
340
+        //                interse.Add(plllist[j]);
341
+        //                if (result.Contains(plllist[i])) result.Remove(plllist[i]);
342
+        //                if (result.Contains(plllist[j])) result.Remove(plllist[j]);
343
+        //            }
344
+        //        }
345
+        //    }
346
+        //    if (interse.Count > 0)
347
+        //    {
348
+        //        // 转换为NTS线串
349
+        //        var lineStrings = new List<Geometry>();
350
+        //        foreach (var pl in interse)
351
+        //        {
352
+        //            var lineString1 = ConvertPolylineToNtsGeometry(pl);
353
+        //            lineStrings.Add(lineString1);
354
+        //        }
355
+        //        // 使用线合并器
356
+        //        var merger = new LineMerger();
357
+        //        merger.Add(lineStrings);
358
+
359
+        //        // 获取合并结果
360
+        //        var mergedCollection = merger.GetMergedLineStrings();
361
+
362
+        //        // 转换回AutoCAD多段线
363
+        //        foreach (var geometry in mergedCollection)
364
+        //        {
365
+        //            if (geometry is LineString mergedLineString)
366
+        //            {
367
+        //                var mergedPolyline = ConvertNtsLineStringToPolyline(mergedLineString);
368
+        //                if (mergedPolyline != null)
369
+        //                {
370
+        //                    mergedPolyline.Elevation = plllist[0].Elevation;
371
+        //                    result.Add(mergedPolyline);
372
+        //                }
373
+        //            }
374
+        //        }
375
+        //    }
376
+        //    var plinside = new List<Polyline>();
377
+        //    foreach (var item in result)
378
+        //    {
379
+        //        var pls = GetPolylineInsideFrame(item, tk);
380
+        //        foreach (var l in pls)
381
+        //        {
382
+        //            plinside.Add(l);
383
+        //        }
384
+        //    }
385
+        //    return plinside.OrderByDescending(g => g.Length).First();
386
+        //}
387
+        #endregion
388
+
389
+        private double GetCurvatureAtVertex(Polyline pl, int vertexIndex, int step)
390
+        {
391
+            int vertexCount = pl.NumberOfVertices;
392
+
393
+            // 获取前一个顶点
394
+            int prevIndex = Math.Max(0, vertexIndex - step);
395
+            Point3d p0 = pl.GetPoint3dAt(prevIndex);
396
+
397
+            // 获取当前顶点
398
+            Point3d p1 = pl.GetPoint3dAt(vertexIndex);
399
+
400
+            // 获取后一个顶点
401
+            int nextIndex = Math.Min(vertexCount - 1, vertexIndex + step);
402
+            Point3d p2 = pl.GetPoint3dAt(nextIndex);
403
+
404
+            // 计算向量
405
+            Vector3d v1 = p1 - p0;
406
+            Vector3d v2 = p2 - p1;
407
+
408
+            double v1Len = v1.Length;
409
+            double v2Len = v2.Length;
410
+
411
+            // 计算曲率
412
+            double curvature = 0;
413
+            if (v1Len > 1e-6 && v2Len > 1e-6)
414
+            {
415
+                // 计算方向变化角度
416
+                double cosAngle = v1.DotProduct(v2) / (v1Len * v2Len);
417
+                cosAngle = Math.Max(-1, Math.Min(1, cosAngle));
418
+                double angle = Math.Acos(cosAngle);
419
+
420
+                // 计算弧长
421
+                double arcLength = v1Len + v2Len;
422
+
423
+                // 曲率 = 角度变化 / 弧长
424
+                curvature = angle / arcLength;
425
+            }
426
+
427
+            return curvature;
428
+        }
429
+
430
+        /// <summary>
431
+        /// 通过弦高差(中间点到首尾点连线的距离)验证区域是否平缓
432
+        /// </summary>
433
+        private bool ValidateFlatRegionByChordHeight(Polyline pl, List<int> sampledIndices)
434
+        {
435
+            // 获取首尾顶点索引(使用采样点的首尾)
436
+            int startVertex = sampledIndices[0];
437
+            int endVertex = sampledIndices[sampledIndices.Count - 1];
438
+
439
+            // 获取首尾点坐标
440
+            Point3d startPoint = pl.GetPoint3dAt(startVertex);
441
+            Point3d endPoint = pl.GetPoint3dAt(endVertex);
442
+
443
+            // 计算弦长
444
+            Vector3d chordVector = endPoint - startPoint;
445
+            double chordLength = chordVector.Length;
446
+
447
+            if (chordLength < 1e-6) return false;
448
+
449
+            // 检查从 startVertex 到 endVertex 之间的所有顶点
450
+            double maxDistance = 0;
451
+            int totalPoints = 0;
452
+            double sumDistance = 0;
453
+
454
+            for (int i = startVertex; i <= endVertex; i++)
455
+            {
456
+                Point3d point = pl.GetPoint3dAt(i);
457
+                double distance = PointToLineDistance(point, startPoint, endPoint);
458
+
459
+                maxDistance = Math.Max(maxDistance, distance);
460
+                sumDistance += distance;
461
+                totalPoints++;
462
+
463
+                // 早期退出:如果任何点距离超过阈值,直接返回false
464
+                if (maxDistance > 0.5)
465
+                {
466
+                    return false;
467
+                }
468
+            }
469
+
470
+            // 判断条件:最大距离和平均距离都满足要求
471
+            bool isFlat = maxDistance <= 0.5;
472
+
473
+            return isFlat;
474
+        }
475
+
476
+        /// <summary>
477
+        /// 计算点到线段的距离
478
+        /// </summary>
479
+        private double PointToLineDistance(Point3d point, Point3d lineStart, Point3d lineEnd)
480
+        {
481
+            Vector3d lineVector = lineEnd - lineStart;
482
+            Vector3d pointVector = point - lineStart;
483
+
484
+            double lineLengthSq = lineVector.DotProduct(lineVector);
485
+            if (lineLengthSq < 1e-6) return pointVector.Length;
486
+
487
+            // 计算投影参数 t
488
+            double t = pointVector.DotProduct(lineVector) / lineLengthSq;
489
+
490
+            // 找到线段上的最近点
491
+            Point3d closestPoint;
492
+            if (t < 0)
493
+                closestPoint = lineStart;
494
+            else if (t > 1)
495
+                closestPoint = lineEnd;
496
+            else
497
+                closestPoint = lineStart + lineVector * t;
498
+
499
+            return point.DistanceTo(closestPoint);
500
+        }
501
+
502
+        private void makeMark(PointPolylinePair pair, Database db, int blc, Point3d central, ObjectId HZ)
503
+        //private void makeMark(Polyline pll, Database db, int blc, Point3d central, ObjectId HZ)
504
+        {
505
+            Polyline pll = pair.Polyline;
506
+            Point3d label_pos = pair.Point;
507
+            Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
508
+            Polyline labelpll = (Polyline)pll.Clone();
509
+
510
+            //Point3d label_pos = labelpll.GetClosestPointTo(central, new Vector3d(0, 0, 1), false);
511
+            if (labelpll.StartPoint.X > labelpll.EndPoint.X)
512
+                labelpll.ReverseCurve();
513
+            //计算放置注记处的方向
514
+            Vector3d tangent = labelpll.GetFirstDerivative(labelpll.GetParameterAtPoint(label_pos));
515
+            double angle = tangent.GetAngleTo(Vector3d.XAxis);
516
+            //调整角度范围(0到2Π)
517
+            if (tangent.Y < 0)
518
+                angle = 2 * Math.PI - angle;
519
+            //法线向量
520
+            Vector3d normal = new Vector3d(-tangent.Y, tangent.X, 0);
521
+            //单位化
522
+            normal = normal.GetNormal();
523
+
524
+            List<Polyline> pllist = new List<Polyline>();
525
+            var angle1 = angle;
526
+            var angle2 = angle + Math.PI;
527
+            int trans_index1 = 0;
528
+            int trans_index2 = 0;
529
+            //以标注所在位置点为基点做基于该点的法线射线进行搜索(正向搜索)
530
+            Point3d startPoint = label_pos;
531
+            Point3d endPoint = label_pos + normal * 200;
532
+            Point3dCollection ptcoll = new Point3dCollection() { startPoint, endPoint };
533
+            List<Point3d> intersepts_y = new List<Point3d>();
534
+            Line l = new Line(startPoint, endPoint);
535
+            ZoomView(ed, startPoint, endPoint);
536
+            TypedValue[] typedvalue_pl = new TypedValue[2];
537
+            typedvalue_pl.SetValue(new TypedValue((int)DxfCode.LayerName, comboBox_jqx.Text + "," + comboBox_sqx.Text), 0);
538
+            typedvalue_pl.SetValue(new TypedValue((int)DxfCode.Start, "LWPOLYLINE"), 1);
539
+            SelectionFilter selectionfilter_pl = new SelectionFilter(typedvalue_pl);
540
+            PromptSelectionResult psr_pl = ed.SelectFence(ptcoll, selectionfilter_pl);
541
+            if (psr_pl.Status == PromptStatus.OK)
542
+            {
543
+                SelectionSet ss = psr_pl.Value;
544
+                ObjectId[] plids = ss.GetObjectIds();
545
+                using (Transaction tr = db.TransactionManager.StartTransaction())
546
+                {
547
+                    for (int ii = 0; ii < plids.Length; ii++)
548
+                    {
549
+                        Polyline dgx = tr.GetObject(plids[ii], OpenMode.ForRead) as Polyline;
550
+                        if (dgx.Elevation == pll.Elevation && dgx.Length - labelpll.Length < 0.0001 &&
551
+                                (dgx.StartPoint == labelpll.EndPoint || dgx.StartPoint == labelpll.StartPoint))
552
+                        {
553
+                            intersepts_y = GetIntersections(dgx, l);
554
+                            continue;
555
+                        }
556
+                        pllist.Add(dgx);
557
+                    }
558
+                    tr.Commit();
559
+                }
560
+                if (pllist.Count != 0)
561
+                    trans_index1 = Iftransdirection(pllist, label_pos, intersepts_y, l);
562
+            }
563
+            //反向搜索
564
+            if (trans_index1 != 1)
565
+            {
566
+                intersepts_y = new List<Point3d>();
567
+                endPoint = label_pos - normal * 200;
568
+                ptcoll = new Point3dCollection() { startPoint, endPoint };
569
+                ZoomView(ed, startPoint, endPoint);
570
+                PromptSelectionResult psr_pl1 = ed.SelectFence(ptcoll, selectionfilter_pl);
571
+                if (psr_pl1.Status == PromptStatus.OK)
572
+                {
573
+                    SelectionSet ss = psr_pl1.Value;
574
+                    ObjectId[] plids = ss.GetObjectIds();
575
+                    l = new Line(startPoint, endPoint);
576
+                    using (Transaction tr = db.TransactionManager.StartTransaction())
577
+                    {
578
+                        for (int ii = 0; ii < plids.Length; ii++)
579
+                        {
580
+                            Polyline dgx = tr.GetObject(plids[ii], OpenMode.ForRead) as Polyline;
581
+                            if (dgx.Elevation == pll.Elevation && dgx.Length - labelpll.Length < 0.0001 && 
582
+                                (dgx.StartPoint == labelpll.EndPoint || dgx.StartPoint == labelpll.StartPoint))
583
+                            {
584
+                                intersepts_y = GetIntersections(dgx, l);
585
+                                continue;
586
+                            }
587
+                            pllist.Add(dgx);
588
+                        }
589
+                        tr.Commit();
590
+                    }
591
+                    if (pllist.Count != 0)
592
+                        trans_index2 = Iftransdirection(pllist, label_pos, intersepts_y, l);
593
+                }
594
+            }
595
+            if (trans_index1 != 0 || trans_index2 != 0)
596
+            {
597
+                if (trans_index1 == 0 && trans_index2 == 1 || trans_index1 == -1 && trans_index2 == 0||
598
+                    trans_index1 == -1 && trans_index2 == 1) angle = angle2;
599
+                //1:2000字高4,以此为基础计算其他比例尺的字高
600
+                double labelheight = 4;
601
+                if (blc == 500)
602
+                    labelheight = labelheight * ((double)500 / 2000);
603
+                if (blc == 1000)
604
+                    labelheight = labelheight * ((double)1000 / 2000);
605
+                if (blc == 5000)
606
+                    labelheight = labelheight * ((double)5000 / 2000);
607
+                if (blc == 10000)
608
+                    labelheight = labelheight * ((double)10000 / 2000);
609
+                string ele = labelpll.Elevation.ToString("F" + textBox_decimal.Text);
610
+                using (DocumentLock doclock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument())
611
+                {
612
+                    using (Transaction tr = db.TransactionManager.StartTransaction())
613
+                    {
614
+                        BlockTable bt = tr.GetObject(db.BlockTableId, OpenMode.ForWrite) as BlockTable;
615
+                        BlockTableRecord btr = tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
616
+                        DBText ele_txt = new DBText();
617
+                        ele_txt.Height = labelheight;
618
+                        ele_txt.TextString = ele;
619
+                        ele_txt.TextStyleId = HZ;
620
+                        ele_txt.HorizontalMode = TextHorizontalMode.TextMid;
621
+                        ele_txt.Position = label_pos;
622
+                        ele_txt.AlignmentPoint = label_pos;
623
+                        ele_txt.Rotation = angle;
624
+                        ele_txt.Layer = comboBox_bz.Text;
625
+                        ele_txt.WidthFactor = 0.75;
626
+                        btr.AppendEntity(ele_txt);
627
+                        tr.AddNewlyCreatedDBObject(ele_txt, true);
628
+                        tr.Commit();
629
+                    }
630
+                }
631
+            }
632
+            else
633
+            {
634
+                nodirection = nodirection + 1;
635
+                LayerControl layerscontrol = new LayerControl();
636
+                string layname = "无法判断方向";
637
+                if (layerscontrol.haslayername(layname) == false)
638
+                {
639
+                    colorgb col = new colorgb(255, 0, 0);
640
+                    layerscontrol.creatlayer(layname, col);
641
+                }
642
+                //1:2000字高4,以此为基础计算其他比例尺的字高
643
+                double labelheight = 4;
644
+                if (blc == 500)
645
+                    labelheight = labelheight * ((double)500 / 2000);
646
+                if (blc == 1000)
647
+                    labelheight = labelheight * ((double)1000 / 2000);
648
+                if (blc == 5000)
649
+                    labelheight = labelheight * ((double)5000 / 2000);
650
+                if (blc == 10000)
651
+                    labelheight = labelheight * ((double)10000 / 2000);
652
+
653
+                string ele = labelpll.Elevation.ToString("F" + textBox_decimal.Text);
654
+                using (DocumentLock doclock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument())
655
+                {
656
+                    using (Transaction tr = db.TransactionManager.StartTransaction())
657
+                    {
658
+                        BlockTable bt = tr.GetObject(db.BlockTableId, OpenMode.ForWrite) as BlockTable;
659
+                        BlockTableRecord btr = tr.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
660
+                        DBText ele_txt = new DBText();
661
+                        ele_txt.Height = labelheight;
662
+                        ele_txt.TextString = ele;
663
+                        ele_txt.TextStyleId = HZ;
664
+                        ele_txt.HorizontalMode = TextHorizontalMode.TextMid;
665
+                        ele_txt.Position = label_pos;
666
+                        ele_txt.AlignmentPoint = label_pos;
667
+                        ele_txt.Rotation = angle;
668
+                        ele_txt.Layer = "无法判断方向";
669
+                        ele_txt.WidthFactor = 0.75;
670
+                        btr.AppendEntity(ele_txt);
671
+                        tr.AddNewlyCreatedDBObject(ele_txt, true);
672
+                        tr.Commit();
673
+                    }
674
+                }
675
+            }
676
+            pllist.Clear();
677
+            psr_pl = null;
678
+            #region
679
+            //Polyline templine = pllist[0].Clone() as Polyline;
680
+
681
+            //// 计算平移向量(以图框起点为基准,移动至原点)
682
+            //Vector3d translation = -tk.StartPoint.GetAsVector();
683
+            //Matrix3d translateMatrix = Matrix3d.Displacement(translation);
684
+            //// 应用平移变换
685
+            //tk.TransformBy(translateMatrix);
686
+            //templine.TransformBy(translateMatrix);
687
+
688
+            //Point3dCollection translatedPoints = new Point3dCollection();
689
+            //var plane = new Plane(Point3d.Origin, Vector3d.ZAxis);
690
+            //tk.IntersectWith(templine, Intersect.OnBothOperands, plane, translatedPoints, IntPtr.Zero, IntPtr.Zero);
691
+
692
+            //// 计算逆平移矩阵
693
+            //Matrix3d inverseMatrix = Matrix3d.Displacement(-translation);
694
+            //if (translatedPoints.Count > 0)
695
+            //{
696
+            //    // 获取平移后的交点
697
+            //    foreach (Point3d item in translatedPoints)
698
+            //    {
699
+            //        // 恢复交点坐标
700
+            //        var pt = item.TransformBy(inverseMatrix);
701
+
702
+            //    }
703
+            //}
704
+            #endregion
705
+        }
706
+
707
+
708
+        /// <summary>
709
+        /// 获取多段线在图框内部的线段部分
710
+        /// </summary>
711
+        public static List<Polyline> GetPolylineInsideFrame(Polyline sourcePolyline, Polyline framePolygon)
712
+        {
713
+            var insidePolylines = new List<Polyline>();
714
+
715
+            // 转换图框为NTS多边形
716
+            var ntsFrame = ConvertPolylineToNtsPolygon(framePolygon);
717
+
718
+            // 转换源多段线为NTS几何对象
719
+            var ntsSource = ConvertPolylineToNtsGeometry(sourcePolyline);
720
+
721
+            // 计算交集(图框 ∩ 多段线)
722
+            var intersection = ntsFrame.Intersection(ntsSource);
723
+
724
+            // 处理交集结果
725
+            if (intersection != null && !intersection.IsEmpty)
726
+            {
727
+                if (intersection is LineString lineString)
728
+                {
729
+                    // 单个线串
730
+                    var polyline = ConvertNtsLineStringToPolyline(lineString);
731
+                    polyline.Elevation = sourcePolyline.Elevation;
732
+                    insidePolylines.Add(polyline);
733
+                }
734
+                else if (intersection is MultiLineString multiLineString)
735
+                {
736
+                    // 多个线串(多段线被分割成多段)
737
+                    for (int i = 0; i < multiLineString.NumGeometries; i++)
738
+                    {
739
+                        LineString segment = multiLineString.GetGeometryN(i) as LineString;
740
+                        var polyline = ConvertNtsLineStringToPolyline(segment);
741
+                        polyline.Elevation = sourcePolyline.Elevation;
742
+                        insidePolylines.Add(polyline);
743
+                    }
744
+                }
745
+                //else if (intersection is GeometryCollection collection)
746
+                //{
747
+                //    // 几何集合
748
+                //    for (int i = 0; i < collection.NumGeometries; i++)
749
+                //    {
750
+                //        LineString segment = collection.GetGeometryN(i) as LineString;
751
+                //        var polyline = ConvertNtsLineStringToPolyline(segment);
752
+                //        polyline.Elevation = sourcePolyline.Elevation;
753
+                //        insidePolylines.Add(polyline);
754
+                //    }
755
+                //}
756
+            }
757
+
758
+            ntsFrame = null;
759
+            ntsSource = null;
760
+            return insidePolylines;
761
+        }
762
+
763
+        /// <summary>
764
+        /// 将AutoCAD多段线转换为NTS多边形
765
+        /// </summary>
766
+        private static Polygon ConvertPolylineToNtsPolygon(Polyline polyline)
767
+        {
768
+            var coordinates = new List<Coordinate>();
769
+
770
+            for (int i = 0; i < polyline.NumberOfVertices; i++)
771
+            {
772
+                Point3d point = polyline.GetPoint3dAt(i);
773
+                coordinates.Add(new Coordinate(point.X, point.Y));
774
+            }
775
+
776
+            // 闭合多边形
777
+            if (polyline.Closed == true && coordinates[0] != coordinates[coordinates.Count - 1])
778
+                coordinates.Add(new Coordinate(coordinates[0].X, coordinates[0].Y));
779
+
780
+            var geometryFactory = new GeometryFactory();
781
+            return (Polygon)geometryFactory.CreatePolygon(coordinates.ToArray());
782
+        }
783
+
784
+        /// <summary>
785
+        /// 将AutoCAD多段线转换为NTS几何对象
786
+        /// </summary>
787
+        private static Geometry ConvertPolylineToNtsGeometry(Polyline polyline)
788
+        {
789
+            var coordinates = new List<Coordinate>();
790
+
791
+            for (int i = 0; i < polyline.NumberOfVertices; i++)
792
+            {
793
+                Point3d point = polyline.GetPoint3dAt(i);
794
+                coordinates.Add(new Coordinate(point.X, point.Y));
795
+            }
796
+
797
+            var geometryFactory = new GeometryFactory();
798
+            return (LineString)geometryFactory.CreateLineString(coordinates.ToArray());
799
+        }
800
+
801
+        /// <summary>
802
+        /// 将NTS线串转换回AutoCAD多段线
803
+        /// </summary>
804
+        private static Polyline ConvertNtsLineStringToPolyline(LineString lineString)
805
+        {
806
+            if (lineString == null || lineString.IsEmpty || lineString.NumPoints < 2)
807
+                return null;
808
+
809
+            var polyline = new Polyline();
810
+            var coordinates = lineString.Coordinates;
811
+
812
+            for (int i = 0; i < coordinates.Length; i++)
813
+            {
814
+                polyline.AddVertexAt(i, new Point2d(coordinates[i].X, coordinates[i].Y), 0, 0, 0);
815
+            }
816
+
817
+
818
+            return polyline;
819
+        }
820
+
821
+        // 检查多段线是否有部分在框内
822
+        private bool IsPolylineInsideOrIntersecting(Polyline pl, Point3d minPoint, Point3d maxPoint)
823
+        {
824
+            // 方法1:检查是否有顶点在框内
825
+            for (int j = 0; j < pl.NumberOfVertices; j++)
826
+            {
827
+                Point3d vertex = pl.GetPoint3dAt(j);
828
+                if (IsPointInside(vertex, minPoint, maxPoint))
829
+                    return true; // 有顶点在框内,说明线有部分在框内
830
+            }
831
+
832
+            // 方法2:检查线的包围盒是否与选择框相交
833
+            Extents3d plExtents = pl.GeometricExtents;
834
+            if (plExtents.MinPoint.X <= maxPoint.X && plExtents.MaxPoint.X >= minPoint.X &&
835
+                plExtents.MinPoint.Y <= maxPoint.Y && plExtents.MaxPoint.Y >= minPoint.Y)
836
+            {
837
+                // 包围盒相交,进一步检查线段
838
+                return true;
839
+            }
840
+
841
+            return false;
842
+        }
843
+
844
+        // 检查点是否在矩形内(不包括边界)
845
+        private bool IsPointInside(Point3d point, Point3d minPoint, Point3d maxPoint)
846
+        {
847
+            return point.X > minPoint.X && point.X < maxPoint.X &&
848
+                   point.Y > minPoint.Y && point.Y < maxPoint.Y;
849
+        }
850
+
851
+        // 检查点是否在矩形内或边界上
852
+        private bool IsPointInsideOrOnBoundary(Point3d point, Point3d minPoint, Point3d maxPoint)
853
+        {
854
+            return point.X >= minPoint.X && point.X <= maxPoint.X &&
855
+                   point.Y >= minPoint.Y && point.Y <= maxPoint.Y;
856
+        }
857
+
858
+        private List<Point3d> GetIntersections(Polyline pll, Line line)
859
+        {
860
+            List<Point3d> result = new List<Point3d>();
861
+            // 创建临时副本
862
+            Polyline tempLine1 = (Polyline)pll.Clone();
863
+            Point3d p1 = new Point3d(line.StartPoint.X, line.StartPoint.Y, pll.Elevation);
864
+            Point3d p2 = new Point3d(line.EndPoint.X, line.EndPoint.Y, pll.Elevation);
865
+            Line tempLine2 = new Line(p1, p2);
866
+
867
+            // 计算平移向量(以线1起点为基准,移动至原点)
868
+            Vector3d translation = -tempLine1.StartPoint.GetAsVector();
869
+            Matrix3d translateMatrix = Matrix3d.Displacement(translation);
870
+
871
+            // 应用平移变换
872
+            tempLine1.TransformBy(translateMatrix);
873
+            tempLine2.TransformBy(translateMatrix);
874
+
875
+            Point3dCollection translatedPoints = new Point3dCollection();
876
+            var plane = new Plane(Point3d.Origin, Vector3d.ZAxis);
877
+            tempLine1.IntersectWith(tempLine2, Intersect.OnBothOperands, plane, translatedPoints, IntPtr.Zero, IntPtr.Zero);
878
+
879
+            // 计算逆平移矩阵
880
+            Matrix3d inverseMatrix = Matrix3d.Displacement(-translation);
881
+            if (translatedPoints.Count > 0)
882
+            {
883
+                // 获取平移后的交点
884
+                foreach (Point3d item in translatedPoints)
885
+                {
886
+                    // 恢复交点坐标
887
+                    var pt = item.TransformBy(inverseMatrix);
888
+                    result.Add(pt);
889
+                }
890
+            }
891
+            return result;
892
+        }
893
+
894
+
895
+        /// <summary>
896
+        /// 计算点到线段的距离
897
+        /// <returns>-1表示反向,1表示同向,0表示不确定</returns>
898
+        /// </summary>
899
+        int Iftransdirection(List<Polyline> pllist,Point3d label_pos, List<Point3d> intersepts_y,Line l) 
900
+        {
901
+            Polyline closest = null;
902
+            double minDistance = double.MaxValue;
903
+            List<Point3d> intersepts_l = new List<Point3d>();
904
+            foreach (Polyline dgx in pllist)
905
+            {
906
+                Polyline dgx_copy = dgx;
907
+                var pts = GetIntersections(dgx_copy, l);
908
+                // 计算距离
909
+                if (pts.Count != 0)
910
+                {
911
+                    foreach (Point3d item in pts)
912
+                    {
913
+                        // 避免创建新的Point3d对象
914
+                        double distance = Math.Sqrt(
915
+                            Math.Pow(item.X - label_pos.X, 2) +
916
+                            Math.Pow(item.Y - label_pos.Y, 2)
917
+                        );
918
+
919
+                        if (distance < minDistance)
920
+                        {
921
+                            minDistance = distance;
922
+                            closest = dgx;
923
+                            intersepts_l = pts;
924
+                        }
925
+                    }
926
+                }
927
+            }
928
+            int count_intersepts_y = intersepts_y.Count;
929
+            intersepts_y.AddRange(intersepts_l);
930
+            var points = intersepts_y.OrderBy(p => Math.Sqrt(Math.Pow(l.StartPoint.X - p.X, 2) + Math.Pow(l.StartPoint.Y - p.Y, 2))).ToList();
931
+            if (count_intersepts_y == 1&& intersepts_l.Count!=0&&Math.Abs(closest.Elevation-label_pos.Z)>0.001)
932
+            {
933
+                if (closest.Elevation > label_pos.Z) return 1;
934
+                else if (closest.Elevation < label_pos.Z) return -1;
935
+            }
936
+            else if (intersepts_l.Count > 0 && intersepts_y.Count > 2 && Math.Abs(closest.Elevation - label_pos.Z) > 0.001)
937
+            {
938
+                double x = closest.Elevation;
939
+                double y = label_pos.Z;
940
+                // 找到第一个高程为y的点的索引
941
+                int firstIndex = -1;
942
+                for (int i = 0; i < points.Count; i++)
943
+                {
944
+                    if (Math.Abs(points[i].Z - y) < 1e-6)
945
+                    {
946
+                        firstIndex = i;
947
+                        break;
948
+                    }
949
+                }
950
+                if (firstIndex == -1) return 0;
951
+
952
+                // 找到第二个高程为y的点的索引
953
+                int secondIndex = -1;
954
+                for (int i = firstIndex + 1; i < points.Count; i++)
955
+                {
956
+                    if (Math.Abs(points[i].Z - y) < 1e-6)
957
+                    {
958
+                        secondIndex = i;
959
+                        break;
960
+                    }
961
+                }
962
+                if (secondIndex == -1) return 0;
963
+                bool haspt = false;
964
+                // 检查两个索引之间是否存在高程为x的点
965
+                for (int i = firstIndex + 1; i < secondIndex; i++)
966
+                {
967
+                    if (Math.Abs(points[i].Z - x) < 1e-6)
968
+                        haspt = true;
969
+                }
970
+                if (haspt && closest.Elevation > label_pos.Z) return 1;
971
+                else if (haspt && closest.Elevation < label_pos.Z) return -1;
972
+                else if (!haspt) return 0;
973
+            }
974
+            
975
+            return 0;
976
+        }
977
+
978
+        private void ZoomView(Editor edit, Point3d pt1, Point3d pt2)
979
+        {
980
+            var x_min = Math.Min(pt1.X, pt2.X);
981
+            var y_min = Math.Min(pt1.Y, pt2.Y);
982
+            using (ViewTableRecord currview1 = edit.GetCurrentView())
983
+            {
984
+                currview1.CenterPoint = new Point2d(Math.Abs((pt2.X - pt1.X) / 2) + x_min,
985
+                                                    Math.Abs((pt2.Y - pt1.Y) / 2) + y_min);
986
+                currview1.Width = Math.Abs(pt2.X - pt1.X)+ 10;
987
+                currview1.Height = Math.Abs(pt2.Y - pt1.Y) + 10;
988
+                edit.SetCurrentView(currview1);
989
+            }
990
+            edit.UpdateScreen();
991
+        }
992
+    }
993
+}

+ 120
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/JQXLabel_grid.resx 查看文件

@@ -0,0 +1,120 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<root>
3
+  <!-- 
4
+    Microsoft ResX Schema 
5
+    
6
+    Version 2.0
7
+    
8
+    The primary goals of this format is to allow a simple XML format 
9
+    that is mostly human readable. The generation and parsing of the 
10
+    various data types are done through the TypeConverter classes 
11
+    associated with the data types.
12
+    
13
+    Example:
14
+    
15
+    ... ado.net/XML headers & schema ...
16
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
17
+    <resheader name="version">2.0</resheader>
18
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
19
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
20
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
21
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
22
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
24
+    </data>
25
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
26
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
27
+        <comment>This is a comment</comment>
28
+    </data>
29
+                
30
+    There are any number of "resheader" rows that contain simple 
31
+    name/value pairs.
32
+    
33
+    Each data row contains a name, and value. The row also contains a 
34
+    type or mimetype. Type corresponds to a .NET class that support 
35
+    text/value conversion through the TypeConverter architecture. 
36
+    Classes that don't support this are serialized and stored with the 
37
+    mimetype set.
38
+    
39
+    The mimetype is used for serialized objects, and tells the 
40
+    ResXResourceReader how to depersist the object. This is currently not 
41
+    extensible. For a given mimetype the value must be set accordingly:
42
+    
43
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
44
+    that the ResXResourceWriter will generate, however the reader can 
45
+    read any of the formats listed below.
46
+    
47
+    mimetype: application/x-microsoft.net.object.binary.base64
48
+    value   : The object must be serialized with 
49
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
50
+            : and then encoded with base64 encoding.
51
+    
52
+    mimetype: application/x-microsoft.net.object.soap.base64
53
+    value   : The object must be serialized with 
54
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
55
+            : and then encoded with base64 encoding.
56
+
57
+    mimetype: application/x-microsoft.net.object.bytearray.base64
58
+    value   : The object must be serialized into a byte array 
59
+            : using a System.ComponentModel.TypeConverter
60
+            : and then encoded with base64 encoding.
61
+    -->
62
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
64
+    <xsd:element name="root" msdata:IsDataSet="true">
65
+      <xsd:complexType>
66
+        <xsd:choice maxOccurs="unbounded">
67
+          <xsd:element name="metadata">
68
+            <xsd:complexType>
69
+              <xsd:sequence>
70
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
71
+              </xsd:sequence>
72
+              <xsd:attribute name="name" use="required" type="xsd:string" />
73
+              <xsd:attribute name="type" type="xsd:string" />
74
+              <xsd:attribute name="mimetype" type="xsd:string" />
75
+              <xsd:attribute ref="xml:space" />
76
+            </xsd:complexType>
77
+          </xsd:element>
78
+          <xsd:element name="assembly">
79
+            <xsd:complexType>
80
+              <xsd:attribute name="alias" type="xsd:string" />
81
+              <xsd:attribute name="name" type="xsd:string" />
82
+            </xsd:complexType>
83
+          </xsd:element>
84
+          <xsd:element name="data">
85
+            <xsd:complexType>
86
+              <xsd:sequence>
87
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
88
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
89
+              </xsd:sequence>
90
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
91
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
92
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
93
+              <xsd:attribute ref="xml:space" />
94
+            </xsd:complexType>
95
+          </xsd:element>
96
+          <xsd:element name="resheader">
97
+            <xsd:complexType>
98
+              <xsd:sequence>
99
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
100
+              </xsd:sequence>
101
+              <xsd:attribute name="name" type="xsd:string" use="required" />
102
+            </xsd:complexType>
103
+          </xsd:element>
104
+        </xsd:choice>
105
+      </xsd:complexType>
106
+    </xsd:element>
107
+  </xsd:schema>
108
+  <resheader name="resmimetype">
109
+    <value>text/microsoft-resx</value>
110
+  </resheader>
111
+  <resheader name="version">
112
+    <value>2.0</value>
113
+  </resheader>
114
+  <resheader name="reader">
115
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116
+  </resheader>
117
+  <resheader name="writer">
118
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119
+  </resheader>
120
+</root>

+ 248
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/LayerChange.cs 查看文件

@@ -0,0 +1,248 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Threading.Tasks;
6
+
7
+using Autodesk.AutoCAD.ApplicationServices;
8
+using Autodesk.AutoCAD.DatabaseServices;
9
+using Autodesk.AutoCAD.EditorInput;
10
+using System.Collections;
11
+using Autodesk.AutoCAD.Geometry;
12
+using System.IO;
13
+using System.Windows.Forms;
14
+
15
+namespace CADTools
16
+{
17
+    class LayerChange
18
+    {
19
+        public static string dwgpath;//dwg文件所在位置
20
+        public static List<string> lys;//要删除/打开/关闭的图层
21
+        public static string savepath;//保存位置
22
+        public static int flag;
23
+
24
+        public void chagly()
25
+        {
26
+            //try
27
+            //{
28
+                List<String> dwgname = GetNameList(dwgpath, ".dwg");//获取dwg文件
29
+                if (dwgname.Count == 0)
30
+                {
31
+                    MessageBox.Show("没有找到dwg文件!", "警告");
32
+                    return;
33
+                }
34
+                foreach (string dwgfile in dwgname)
35
+                {
36
+                    string dwg = dwgpath + "\\" + dwgfile;
37
+                    Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.Add(dwg);
38
+                    if (flag == 0|| flag == 3 || flag == 4)
39
+                    {
40
+                        Delete(lys, doc, dwgfile);
41
+                    }
42
+                    else if (flag == 1)
43
+                    {
44
+                        Closely(lys, doc, dwgfile);
45
+                    }
46
+                    else if (flag == 2)
47
+                    {
48
+                        Openly(lys, doc, dwgfile);
49
+                    }
50
+                    doc.CloseAndDiscard();
51
+            }
52
+        //}
53
+            //catch (Autodesk.AutoCAD.Runtime.Exception ex)
54
+            //{
55
+            //    Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("Error:\n" + ex.Message);
56
+            //}
57
+}
58
+
59
+        private void Delete(List<string> lys, Document doc, string dwgfile)
60
+        {
61
+            Database database = doc.Database;
62
+            Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
63
+            if (flag == 0)
64
+            {
65
+                DocumentLock doclock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
66
+                using (Transaction trans = doc.Database.TransactionManager.StartTransaction())
67
+                {
68
+                    LayerTable layerTable = trans.GetObject(database.LayerTableId, OpenMode.ForRead) as LayerTable;
69
+                    for (int i = 0; i < lys.Count; i++)
70
+                    {
71
+                        if (layerTable.Has(lys[i]))
72
+                        {
73
+                            TypedValue[] value = new TypedValue[]
74
+                            {
75
+                                new TypedValue((int)DxfCode.LayerName,lys[i])
76
+                            };
77
+                            SelectionFilter filter = new SelectionFilter(value);
78
+                            PromptSelectionResult psr = ed.SelectAll(filter);
79
+                            if (psr.Status == PromptStatus.OK)
80
+                            {
81
+                                SelectionSet ss = psr.Value;
82
+                                ObjectIdCollection idcoll = new ObjectIdCollection(ss.GetObjectIds());
83
+                                for (int ii = 0; ii < idcoll.Count; ii++)
84
+                                {
85
+                                    Entity ent = trans.GetObject(idcoll[ii], OpenMode.ForWrite) as Entity;
86
+                                    ent.Erase();
87
+                                }
88
+                            }
89
+                        }
90
+                    }
91
+                    database.SaveAs(savepath + "\\" + dwgfile, true, DwgVersion.AC1021, doc.Database.SecurityParameters);
92
+                    ed.WriteMessage("删除成功!\n");
93
+                    trans.Commit();
94
+                }
95
+                doclock.Dispose();
96
+            }
97
+
98
+            if (flag == 3)
99
+            {
100
+                DocumentLock doclock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
101
+                using (Transaction transaction = database.TransactionManager.StartTransaction())
102
+                {
103
+                    LayerTable layerTable = transaction.GetObject(database.LayerTableId, OpenMode.ForRead) as LayerTable;
104
+                    foreach (ObjectId objid in layerTable)
105
+                    {
106
+                        LayerTableRecord layerTableRecord = transaction.GetObject(objid, OpenMode.ForWrite) as LayerTableRecord;
107
+                        //if (layerTableRecord == null)
108
+                        //    continue;
109
+                        layerTableRecord.IsLocked = false;
110
+                        if (database.Clayer == layerTableRecord.ObjectId)
111
+                            continue;
112
+                        TypedValue[] value = new TypedValue[]
113
+                        {
114
+                            new TypedValue((int)DxfCode.LayerName,layerTableRecord.Name)
115
+                        };
116
+                        SelectionFilter filter = new SelectionFilter(value);
117
+                        PromptSelectionResult psr = ed.SelectAll(filter);
118
+                        if (psr.Status == PromptStatus.Error&& lys.Contains(layerTableRecord.Name))
119
+                            layerTableRecord.Erase();
120
+                    }
121
+                    transaction.Commit();
122
+                    database.SaveAs(savepath + "\\" + dwgfile, true, DwgVersion.AC1021, doc.Database.SecurityParameters);
123
+                }
124
+                doclock.Dispose();
125
+                ed.WriteMessage("删除成功!\n");
126
+            }
127
+
128
+            if (flag == 4)
129
+            {
130
+                DocumentLock doclock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
131
+                using (Transaction transaction = database.TransactionManager.StartTransaction())
132
+                {
133
+                    LayerTable layerTable = transaction.GetObject(database.LayerTableId, OpenMode.ForRead) as LayerTable;
134
+                    for (int i = 0; i < lys.Count; i++)
135
+                    {
136
+                        if (layerTable.Has(lys[i]))
137
+                        {
138
+                            LayerTableRecord layerTableRecord = transaction.GetObject(layerTable[lys[i]], OpenMode.ForWrite) as LayerTableRecord;
139
+                            if (layerTableRecord == null)
140
+                                continue;
141
+                            if (database.Clayer == layerTableRecord.ObjectId)
142
+                            {
143
+                                database.Clayer = layerTable["0"];
144
+                            }
145
+                            layerTableRecord.IsLocked = false;
146
+                            layerTableRecord.Erase();
147
+                            BlockTable bt = transaction.GetObject(database.BlockTableId, OpenMode.ForRead) as BlockTable;
148
+                            foreach (ObjectId btrId in bt)
149
+                            {
150
+                                BlockTableRecord btr = transaction.GetObject(btrId, OpenMode.ForRead) as BlockTableRecord;
151
+                                foreach (ObjectId entId in btr)
152
+                                {
153
+                                    Entity entity = transaction.GetObject(entId, OpenMode.ForRead) as Entity;
154
+                                    if (entity.Layer == lys[i])
155
+                                    {
156
+                                        entity.UpgradeOpen();
157
+                                        try
158
+                                        {
159
+                                            entity.Erase();
160
+                                        }
161
+                                        catch
162
+                                        {
163
+                                            continue;
164
+                                        }
165
+                                    }
166
+                                }
167
+                            }
168
+                        }
169
+                    }
170
+                    database.SaveAs(savepath + "\\" + dwgfile, true, DwgVersion.AC1021, doc.Database.SecurityParameters);
171
+                    transaction.Commit();
172
+                    ed.WriteMessage("删除成功!\n");
173
+                }
174
+                doclock.Dispose();
175
+            }
176
+        }
177
+        
178
+
179
+        private void Openly(List<string> lys, Document doc, string dwgfile)
180
+        {
181
+            Database database = doc.Database;
182
+            Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
183
+            DocumentLock doclock = doc.LockDocument();
184
+            using (Transaction transaction = database.TransactionManager.StartTransaction())
185
+            {
186
+                LayerTable layerTable = transaction.GetObject(database.LayerTableId, OpenMode.ForRead) as LayerTable;
187
+                for (int i = 0; i < lys.Count; i++)
188
+                {
189
+                    if (layerTable.Has(lys[i]))
190
+                    {
191
+                        LayerTableRecord layerTableRecord = transaction.GetObject(layerTable[lys[i]], OpenMode.ForWrite) as LayerTableRecord;
192
+                        if (layerTableRecord == null)
193
+                            continue;
194
+                        layerTableRecord.IsOff = false;
195
+                    }
196
+                }
197
+                database.SaveAs(savepath + "\\" + dwgfile, true, DwgVersion.AC1021, doc.Database.SecurityParameters);
198
+                transaction.Commit();
199
+            }
200
+            doclock.Dispose();
201
+            ed.WriteMessage("打开成功!\n");
202
+        }
203
+
204
+        private void Closely(List<string> lys, Document doc, string dwgfile)
205
+        {
206
+            Database database = doc.Database;
207
+            Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
208
+            DocumentLock doclock = doc.LockDocument();
209
+            using (Transaction transaction = database.TransactionManager.StartTransaction())
210
+            {
211
+                LayerTable layerTable = transaction.GetObject(database.LayerTableId, OpenMode.ForRead) as LayerTable;
212
+                for (int i = 0; i < lys.Count; i++)
213
+                {
214
+                    if (layerTable.Has(lys[i]))
215
+                    {
216
+                        LayerTableRecord layerTableRecord = transaction.GetObject(layerTable[lys[i]], OpenMode.ForWrite) as LayerTableRecord;
217
+                        if (layerTableRecord == null)
218
+                            continue;
219
+                        layerTableRecord.IsOff = true;
220
+                    }
221
+                }
222
+                database.SaveAs(savepath + "\\" + dwgfile, true, DwgVersion.AC1021, doc.Database.SecurityParameters);
223
+                transaction.Commit();
224
+            }
225
+            doclock.Dispose();
226
+            ed.WriteMessage("关闭成功!\n");
227
+        }
228
+
229
+        /// <summary>
230
+        /// 获取文件夹中相应格式的所有文件
231
+        /// </summary>
232
+        private static List<String> GetNameList(String filespath, String filetype)
233
+        {
234
+            DirectoryInfo root = new DirectoryInfo(filespath);
235
+            List<String> filename = new List<string>();     //文件名
236
+            FileInfo[] files = root.GetFiles();
237
+            foreach (FileInfo file in files)
238
+            {
239
+                if (file.Name.Substring(file.Name.Length - 4, 4) != filetype)
240
+                    continue;
241
+                else
242
+                    filename.Add(file.Name);
243
+            }
244
+            return filename;
245
+        }
246
+
247
+    }
248
+}

+ 248
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/Layerchange_Form.Designer.cs 查看文件

@@ -0,0 +1,248 @@
1
+
2
+namespace CADTools
3
+{
4
+    partial class Layerchange_Form
5
+    {
6
+        /// <summary>
7
+        /// Required designer variable.
8
+        /// </summary>
9
+        private System.ComponentModel.IContainer components = null;
10
+
11
+        /// <summary>
12
+        /// Clean up any resources being used.
13
+        /// </summary>
14
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
15
+        protected override void Dispose(bool disposing)
16
+        {
17
+            if (disposing && (components != null))
18
+            {
19
+                components.Dispose();
20
+            }
21
+            base.Dispose(disposing);
22
+        }
23
+
24
+        #region Windows Form Designer generated code
25
+
26
+        /// <summary>
27
+        /// Required method for Designer support - do not modify
28
+        /// the contents of this method with the code editor.
29
+        /// </summary>
30
+        private void InitializeComponent()
31
+        {
32
+            this.label1 = new System.Windows.Forms.Label();
33
+            this.textBox_dwgpath = new System.Windows.Forms.TextBox();
34
+            this.label2 = new System.Windows.Forms.Label();
35
+            this.button_ok = new System.Windows.Forms.Button();
36
+            this.button_cancel = new System.Windows.Forms.Button();
37
+            this.checkedListBox_tc = new System.Windows.Forms.CheckedListBox();
38
+            this.checkBox_delete = new System.Windows.Forms.CheckBox();
39
+            this.checkBox_open = new System.Windows.Forms.CheckBox();
40
+            this.checkBox_close = new System.Windows.Forms.CheckBox();
41
+            this.button_choose = new System.Windows.Forms.Button();
42
+            this.label3 = new System.Windows.Forms.Label();
43
+            this.textBox_savepath = new System.Windows.Forms.TextBox();
44
+            this.button_cssavepath = new System.Windows.Forms.Button();
45
+            this.checkBox_deletself = new System.Windows.Forms.CheckBox();
46
+            this.checkBox_deletnull = new System.Windows.Forms.CheckBox();
47
+            this.checkBox_selectall = new System.Windows.Forms.CheckBox();
48
+            this.SuspendLayout();
49
+            // 
50
+            // label1
51
+            // 
52
+            this.label1.AutoSize = true;
53
+            this.label1.Location = new System.Drawing.Point(31, 35);
54
+            this.label1.Name = "label1";
55
+            this.label1.Size = new System.Drawing.Size(121, 15);
56
+            this.label1.TabIndex = 0;
57
+            this.label1.Text = "dwg所在文件夹:";
58
+            // 
59
+            // textBox_dwgpath
60
+            // 
61
+            this.textBox_dwgpath.Location = new System.Drawing.Point(158, 29);
62
+            this.textBox_dwgpath.Name = "textBox_dwgpath";
63
+            this.textBox_dwgpath.Size = new System.Drawing.Size(275, 25);
64
+            this.textBox_dwgpath.TabIndex = 1;
65
+            // 
66
+            // label2
67
+            // 
68
+            this.label2.AutoSize = true;
69
+            this.label2.Location = new System.Drawing.Point(61, 102);
70
+            this.label2.Name = "label2";
71
+            this.label2.Size = new System.Drawing.Size(82, 15);
72
+            this.label2.TabIndex = 2;
73
+            this.label2.Text = "选择图层:";
74
+            // 
75
+            // button_ok
76
+            // 
77
+            this.button_ok.Location = new System.Drawing.Point(101, 310);
78
+            this.button_ok.Name = "button_ok";
79
+            this.button_ok.Size = new System.Drawing.Size(71, 31);
80
+            this.button_ok.TabIndex = 4;
81
+            this.button_ok.Text = "确 定";
82
+            this.button_ok.UseVisualStyleBackColor = true;
83
+            this.button_ok.Click += new System.EventHandler(this.button_ok_Click);
84
+            // 
85
+            // button_cancel
86
+            // 
87
+            this.button_cancel.Location = new System.Drawing.Point(406, 310);
88
+            this.button_cancel.Name = "button_cancel";
89
+            this.button_cancel.Size = new System.Drawing.Size(75, 31);
90
+            this.button_cancel.TabIndex = 5;
91
+            this.button_cancel.Text = "取 消";
92
+            this.button_cancel.UseVisualStyleBackColor = true;
93
+            this.button_cancel.Click += new System.EventHandler(this.button_cancel_Click);
94
+            // 
95
+            // checkedListBox_tc
96
+            // 
97
+            this.checkedListBox_tc.FormattingEnabled = true;
98
+            this.checkedListBox_tc.Location = new System.Drawing.Point(158, 128);
99
+            this.checkedListBox_tc.Name = "checkedListBox_tc";
100
+            this.checkedListBox_tc.Size = new System.Drawing.Size(275, 164);
101
+            this.checkedListBox_tc.TabIndex = 6;
102
+            // 
103
+            // checkBox_delete
104
+            // 
105
+            this.checkBox_delete.AutoSize = true;
106
+            this.checkBox_delete.Location = new System.Drawing.Point(476, 128);
107
+            this.checkBox_delete.Name = "checkBox_delete";
108
+            this.checkBox_delete.Size = new System.Drawing.Size(164, 34);
109
+            this.checkBox_delete.TabIndex = 7;
110
+            this.checkBox_delete.Text = "删除图层\n(不包括图层本身)";
111
+            this.checkBox_delete.UseVisualStyleBackColor = true;
112
+            // 
113
+            // checkBox_open
114
+            // 
115
+            this.checkBox_open.AutoSize = true;
116
+            this.checkBox_open.Location = new System.Drawing.Point(631, 168);
117
+            this.checkBox_open.Name = "checkBox_open";
118
+            this.checkBox_open.Size = new System.Drawing.Size(89, 19);
119
+            this.checkBox_open.TabIndex = 8;
120
+            this.checkBox_open.Text = "打开图层";
121
+            this.checkBox_open.UseVisualStyleBackColor = true;
122
+            // 
123
+            // checkBox_close
124
+            // 
125
+            this.checkBox_close.AutoSize = true;
126
+            this.checkBox_close.Location = new System.Drawing.Point(631, 215);
127
+            this.checkBox_close.Name = "checkBox_close";
128
+            this.checkBox_close.Size = new System.Drawing.Size(89, 19);
129
+            this.checkBox_close.TabIndex = 9;
130
+            this.checkBox_close.Text = "关闭图层";
131
+            this.checkBox_close.UseVisualStyleBackColor = true;
132
+            // 
133
+            // button_choose
134
+            // 
135
+            this.button_choose.Location = new System.Drawing.Point(476, 18);
136
+            this.button_choose.Name = "button_choose";
137
+            this.button_choose.Size = new System.Drawing.Size(75, 32);
138
+            this.button_choose.TabIndex = 10;
139
+            this.button_choose.Text = "选 择";
140
+            this.button_choose.UseVisualStyleBackColor = true;
141
+            this.button_choose.Click += new System.EventHandler(this.button_choose_Click);
142
+            // 
143
+            // label3
144
+            // 
145
+            this.label3.AutoSize = true;
146
+            this.label3.Location = new System.Drawing.Point(61, 70);
147
+            this.label3.Name = "label3";
148
+            this.label3.Size = new System.Drawing.Size(82, 15);
149
+            this.label3.TabIndex = 11;
150
+            this.label3.Text = "保存路径:";
151
+            // 
152
+            // textBox_savepath
153
+            // 
154
+            this.textBox_savepath.Location = new System.Drawing.Point(158, 67);
155
+            this.textBox_savepath.Name = "textBox_savepath";
156
+            this.textBox_savepath.Size = new System.Drawing.Size(275, 25);
157
+            this.textBox_savepath.TabIndex = 12;
158
+            // 
159
+            // button_cssavepath
160
+            // 
161
+            this.button_cssavepath.Location = new System.Drawing.Point(476, 61);
162
+            this.button_cssavepath.Name = "button_cssavepath";
163
+            this.button_cssavepath.Size = new System.Drawing.Size(75, 32);
164
+            this.button_cssavepath.TabIndex = 13;
165
+            this.button_cssavepath.Text = "选 择";
166
+            this.button_cssavepath.UseVisualStyleBackColor = true;
167
+            this.button_cssavepath.Click += new System.EventHandler(this.button_cssavepath_Click);
168
+            // 
169
+            // checkBox_deletself
170
+            // 
171
+            this.checkBox_deletself.AutoSize = true;
172
+            this.checkBox_deletself.Location = new System.Drawing.Point(476, 179);
173
+            this.checkBox_deletself.Name = "checkBox_deletself";
174
+            this.checkBox_deletself.Size = new System.Drawing.Size(149, 34);
175
+            this.checkBox_deletself.TabIndex = 14;
176
+            this.checkBox_deletself.Text = "删除图层\n(包括图层本身)";
177
+            this.checkBox_deletself.UseVisualStyleBackColor = true;
178
+            // 
179
+            // checkBox_deletnull
180
+            // 
181
+            this.checkBox_deletnull.AutoSize = true;
182
+            this.checkBox_deletnull.Location = new System.Drawing.Point(476, 235);
183
+            this.checkBox_deletnull.Name = "checkBox_deletnull";
184
+            this.checkBox_deletnull.Size = new System.Drawing.Size(104, 19);
185
+            this.checkBox_deletnull.TabIndex = 15;
186
+            this.checkBox_deletnull.Text = "删除空图层";
187
+            this.checkBox_deletnull.UseVisualStyleBackColor = true;
188
+            // 
189
+            // checkBox_selectall
190
+            // 
191
+            this.checkBox_selectall.AutoSize = true;
192
+            this.checkBox_selectall.Location = new System.Drawing.Point(374, 103);
193
+            this.checkBox_selectall.Name = "checkBox_selectall";
194
+            this.checkBox_selectall.Size = new System.Drawing.Size(59, 19);
195
+            this.checkBox_selectall.TabIndex = 16;
196
+            this.checkBox_selectall.Text = "全选";
197
+            this.checkBox_selectall.UseVisualStyleBackColor = true;
198
+            this.checkBox_selectall.CheckedChanged += new System.EventHandler(this.checkBox_selectall_CheckedChanged);
199
+            // 
200
+            // Layerchange_Form
201
+            // 
202
+            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
203
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
204
+            this.ClientSize = new System.Drawing.Size(750, 379);
205
+            this.Controls.Add(this.checkBox_selectall);
206
+            this.Controls.Add(this.checkBox_deletnull);
207
+            this.Controls.Add(this.checkBox_deletself);
208
+            this.Controls.Add(this.button_cssavepath);
209
+            this.Controls.Add(this.textBox_savepath);
210
+            this.Controls.Add(this.label3);
211
+            this.Controls.Add(this.button_choose);
212
+            this.Controls.Add(this.checkBox_close);
213
+            this.Controls.Add(this.checkBox_open);
214
+            this.Controls.Add(this.checkBox_delete);
215
+            this.Controls.Add(this.checkedListBox_tc);
216
+            this.Controls.Add(this.button_cancel);
217
+            this.Controls.Add(this.button_ok);
218
+            this.Controls.Add(this.label2);
219
+            this.Controls.Add(this.textBox_dwgpath);
220
+            this.Controls.Add(this.label1);
221
+            this.Name = "Layerchange_Form";
222
+            this.Text = "图层删改";
223
+            this.Load += new System.EventHandler(this.Layerchange_Form_Load);
224
+            this.ResumeLayout(false);
225
+            this.PerformLayout();
226
+
227
+        }
228
+
229
+        #endregion
230
+
231
+        private System.Windows.Forms.Label label1;
232
+        private System.Windows.Forms.TextBox textBox_dwgpath;
233
+        private System.Windows.Forms.Label label2;
234
+        private System.Windows.Forms.Button button_ok;
235
+        private System.Windows.Forms.Button button_cancel;
236
+        private System.Windows.Forms.CheckedListBox checkedListBox_tc;
237
+        private System.Windows.Forms.CheckBox checkBox_delete;
238
+        private System.Windows.Forms.CheckBox checkBox_open;
239
+        private System.Windows.Forms.CheckBox checkBox_close;
240
+        private System.Windows.Forms.Button button_choose;
241
+        private System.Windows.Forms.Label label3;
242
+        private System.Windows.Forms.TextBox textBox_savepath;
243
+        private System.Windows.Forms.Button button_cssavepath;
244
+        private System.Windows.Forms.CheckBox checkBox_deletself;
245
+        private System.Windows.Forms.CheckBox checkBox_deletnull;
246
+        private System.Windows.Forms.CheckBox checkBox_selectall;
247
+    }
248
+}

+ 175
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/Layerchange_Form.cs 查看文件

@@ -0,0 +1,175 @@
1
+using Autodesk.AutoCAD.ApplicationServices;
2
+using Autodesk.AutoCAD.DatabaseServices;
3
+using System;
4
+using System.Collections.Generic;
5
+using System.ComponentModel;
6
+using System.Data;
7
+using System.Drawing;
8
+using System.IO;
9
+using System.Linq;
10
+using System.Text;
11
+using System.Threading.Tasks;
12
+using System.Windows.Forms;
13
+
14
+namespace CADTools
15
+{
16
+    public partial class Layerchange_Form : Form
17
+    {
18
+        public Layerchange_Form()
19
+        {
20
+            InitializeComponent();
21
+        }
22
+
23
+        private void button_choose_Click(object sender, EventArgs e)
24
+        {
25
+            FolderBrowserDialog open = new FolderBrowserDialog();
26
+            open.Description = "请选择文件夹";
27
+            if (open.ShowDialog() == System.Windows.Forms.DialogResult.OK)
28
+            {
29
+                textBox_dwgpath.Text = open.SelectedPath;
30
+            }
31
+            if (textBox_dwgpath.Text == "")
32
+            { 
33
+                MessageBox.Show("未选择文件夹");
34
+                return;
35
+            }
36
+            // 获取dwg文件
37
+            else
38
+            {
39
+                this.Hide();
40
+                DirectoryInfo root = new DirectoryInfo(textBox_dwgpath.Text);
41
+                List<String> filename = new List<string>();     //文件名
42
+                FileInfo[] files = root.GetFiles();
43
+                foreach (FileInfo file in files)
44
+                {
45
+                    if (file.Name.Substring(file.Name.Length - 4, 4) != ".dwg")
46
+                        continue;
47
+                    else
48
+                        filename.Add(file.Name);
49
+                }
50
+                string dwg = textBox_dwgpath.Text + "\\" + filename[0];
51
+                //获取文件中图层
52
+                Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.Add(dwg);
53
+                Database database = doc.Database;
54
+                using (Transaction traction = database.TransactionManager.StartTransaction())
55
+                {
56
+                    //存放所有图层名
57
+                    List<string> alllayername = new List<string>();
58
+                    LayerTable layertable = traction.GetObject(database.LayerTableId, OpenMode.ForRead) as LayerTable;
59
+                    foreach (ObjectId objid in layertable)
60
+                    {
61
+                        LayerTableRecord layertablerecord = traction.GetObject(objid, OpenMode.ForRead) as LayerTableRecord;
62
+                        alllayername.Add(layertablerecord.Name);
63
+                    }
64
+
65
+                    alllayername.Sort();
66
+
67
+                    for (int i = 0; i < alllayername.Count; i++)
68
+                    {
69
+                        this.checkedListBox_tc.Items.Add(alllayername[i]);
70
+                    }
71
+                    traction.Commit();
72
+                }
73
+                doc.CloseAndDiscard();
74
+                this.Show();
75
+            }
76
+        }
77
+
78
+        private void button_ok_Click(object sender, EventArgs e)
79
+        {
80
+            if (textBox_dwgpath.Text == "")
81
+            { 
82
+                MessageBox.Show("未选择文件夹!");
83
+                return;
84
+            }
85
+            else if (textBox_savepath.Text == "")
86
+            { 
87
+                MessageBox.Show("未选择保存路径!");
88
+                return;
89
+            }
90
+            else
91
+            {
92
+                LayerChange.dwgpath = textBox_dwgpath.Text;
93
+                List<string> list = new List<string>();
94
+                for (int i = 0; i < checkedListBox_tc.CheckedItems.Count; i++)
95
+                {
96
+                    list.Add(checkedListBox_tc.CheckedItems[i].ToString());
97
+                }
98
+                LayerChange.lys = list;
99
+                if (checkBox_delete.Checked == true)
100
+                {
101
+                    LayerChange lyc = new LayerChange();
102
+                    LayerChange.flag = 0;
103
+                    lyc.chagly();
104
+                    this.Close();
105
+                }
106
+                if (checkBox_close.Checked == true)
107
+                {
108
+                    LayerChange lyc = new LayerChange();
109
+                    LayerChange.flag = 1;
110
+                    lyc.chagly();
111
+                    this.Close();
112
+                }
113
+                if (checkBox_open.Checked == true)
114
+                {
115
+                    LayerChange lyc = new LayerChange();
116
+                    LayerChange.flag = 2;
117
+                    lyc.chagly();
118
+                    this.Close();
119
+                }
120
+                if (checkBox_deletnull.Checked == true)
121
+                {
122
+                    LayerChange lyc = new LayerChange();
123
+                    LayerChange.flag = 3;
124
+                    lyc.chagly();
125
+                    this.Close();
126
+                }
127
+                if (checkBox_deletself.Checked == true)
128
+                {
129
+                    LayerChange lyc = new LayerChange();
130
+                    LayerChange.flag = 4;
131
+                    lyc.chagly();
132
+                    this.Close();
133
+                }
134
+            }
135
+        }
136
+
137
+        private void button_cancel_Click(object sender, EventArgs e)
138
+        {
139
+            this.Close();
140
+        }
141
+
142
+        private void Layerchange_Form_Load(object sender, EventArgs e)
143
+        {
144
+            this.MaximizeBox = false;
145
+            this.StartPosition = FormStartPosition.CenterScreen;
146
+        }
147
+
148
+        private void button_cssavepath_Click(object sender, EventArgs e)
149
+        {
150
+            FolderBrowserDialog open = new FolderBrowserDialog();
151
+            open.Description = "请选择文件夹";
152
+            if (open.ShowDialog() == System.Windows.Forms.DialogResult.OK)
153
+                textBox_savepath.Text = open.SelectedPath;
154
+            LayerChange.savepath = textBox_savepath.Text;
155
+        }
156
+
157
+        private void checkBox_selectall_CheckedChanged(object sender, EventArgs e)
158
+        {
159
+            if (checkBox_selectall.Checked == true)
160
+            {
161
+                for (int i = 0; i < checkedListBox_tc.Items.Count; i++)
162
+                {
163
+                    checkedListBox_tc.SetItemCheckState(i, CheckState.Checked);
164
+                }
165
+            }
166
+            else
167
+            {
168
+                for (int i = 0; i < checkedListBox_tc.Items.Count; i++)
169
+                {
170
+                    checkedListBox_tc.SetItemCheckState(i, CheckState.Unchecked);
171
+                }
172
+            }
173
+        }
174
+    }
175
+}

+ 120
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/Layerchange_Form.resx 查看文件

@@ -0,0 +1,120 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<root>
3
+  <!-- 
4
+    Microsoft ResX Schema 
5
+    
6
+    Version 2.0
7
+    
8
+    The primary goals of this format is to allow a simple XML format 
9
+    that is mostly human readable. The generation and parsing of the 
10
+    various data types are done through the TypeConverter classes 
11
+    associated with the data types.
12
+    
13
+    Example:
14
+    
15
+    ... ado.net/XML headers & schema ...
16
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
17
+    <resheader name="version">2.0</resheader>
18
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
19
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
20
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
21
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
22
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
24
+    </data>
25
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
26
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
27
+        <comment>This is a comment</comment>
28
+    </data>
29
+                
30
+    There are any number of "resheader" rows that contain simple 
31
+    name/value pairs.
32
+    
33
+    Each data row contains a name, and value. The row also contains a 
34
+    type or mimetype. Type corresponds to a .NET class that support 
35
+    text/value conversion through the TypeConverter architecture. 
36
+    Classes that don't support this are serialized and stored with the 
37
+    mimetype set.
38
+    
39
+    The mimetype is used for serialized objects, and tells the 
40
+    ResXResourceReader how to depersist the object. This is currently not 
41
+    extensible. For a given mimetype the value must be set accordingly:
42
+    
43
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
44
+    that the ResXResourceWriter will generate, however the reader can 
45
+    read any of the formats listed below.
46
+    
47
+    mimetype: application/x-microsoft.net.object.binary.base64
48
+    value   : The object must be serialized with 
49
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
50
+            : and then encoded with base64 encoding.
51
+    
52
+    mimetype: application/x-microsoft.net.object.soap.base64
53
+    value   : The object must be serialized with 
54
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
55
+            : and then encoded with base64 encoding.
56
+
57
+    mimetype: application/x-microsoft.net.object.bytearray.base64
58
+    value   : The object must be serialized into a byte array 
59
+            : using a System.ComponentModel.TypeConverter
60
+            : and then encoded with base64 encoding.
61
+    -->
62
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
64
+    <xsd:element name="root" msdata:IsDataSet="true">
65
+      <xsd:complexType>
66
+        <xsd:choice maxOccurs="unbounded">
67
+          <xsd:element name="metadata">
68
+            <xsd:complexType>
69
+              <xsd:sequence>
70
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
71
+              </xsd:sequence>
72
+              <xsd:attribute name="name" use="required" type="xsd:string" />
73
+              <xsd:attribute name="type" type="xsd:string" />
74
+              <xsd:attribute name="mimetype" type="xsd:string" />
75
+              <xsd:attribute ref="xml:space" />
76
+            </xsd:complexType>
77
+          </xsd:element>
78
+          <xsd:element name="assembly">
79
+            <xsd:complexType>
80
+              <xsd:attribute name="alias" type="xsd:string" />
81
+              <xsd:attribute name="name" type="xsd:string" />
82
+            </xsd:complexType>
83
+          </xsd:element>
84
+          <xsd:element name="data">
85
+            <xsd:complexType>
86
+              <xsd:sequence>
87
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
88
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
89
+              </xsd:sequence>
90
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
91
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
92
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
93
+              <xsd:attribute ref="xml:space" />
94
+            </xsd:complexType>
95
+          </xsd:element>
96
+          <xsd:element name="resheader">
97
+            <xsd:complexType>
98
+              <xsd:sequence>
99
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
100
+              </xsd:sequence>
101
+              <xsd:attribute name="name" type="xsd:string" use="required" />
102
+            </xsd:complexType>
103
+          </xsd:element>
104
+        </xsd:choice>
105
+      </xsd:complexType>
106
+    </xsd:element>
107
+  </xsd:schema>
108
+  <resheader name="resmimetype">
109
+    <value>text/microsoft-resx</value>
110
+  </resheader>
111
+  <resheader name="version">
112
+    <value>2.0</value>
113
+  </resheader>
114
+  <resheader name="reader">
115
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116
+  </resheader>
117
+  <resheader name="writer">
118
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119
+  </resheader>
120
+</root>

+ 684
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/MainClass.cs 查看文件

@@ -0,0 +1,684 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+
6
+using Autodesk.AutoCAD.Runtime;
7
+using Autodesk.AutoCAD.EditorInput;
8
+using Autodesk.AutoCAD.ApplicationServices;
9
+using Autodesk.AutoCAD.Interop;
10
+using System.IO;
11
+using Microsoft.Win32;
12
+using System.Security.Cryptography;
13
+using System.Windows.Forms;
14
+using System.Management;
15
+
16
+[assembly: ExtensionApplication(typeof(CADTools.MainClass))]
17
+namespace CADTools
18
+{
19
+    /// <summary>
20
+    /// 加载主窗体
21
+    /// </summary>
22
+    public class MainClass : IExtensionApplication
23
+    {
24
+        public void Initialize()
25
+        {
26
+            ////Menus menu = new Menus();
27
+            ////menu.AddMenu();
28
+            //Reg reg = new Reg();
29
+            //RegistryKey retkey = Registry.CurrentUser.OpenSubKey("SOFTWARE", true).CreateSubKey("mySoftWare").CreateSubKey("Register.INI");
30
+            ////判断注册表中相应位置的subkey数量,如果为零的话则需要注册
31
+            //if (retkey.SubKeyCount == 0)
32
+            //{
33
+            //    reg.Show();
34
+            //}
35
+            ////如果不为零,判断日期是否在期限内
36
+            //else
37
+            //{
38
+            //    //转换为日期格式后检查当前日期之间和输入注册码的日期之间的间隔
39
+            //    TimeSpan ts = DateTime.Now - DateTime.Parse(retkey.GetSubKeyNames()[0]);
40
+            //    //如果超过期限,则删除所有subkey,显示注册码窗口
41
+            //    if (ts.Days > 183 || ts.Days < 0)
42
+            //    {
43
+            //        foreach (string strRNum in retkey.GetSubKeyNames())
44
+            //        {
45
+            //            retkey.DeleteSubKey(strRNum);
46
+            //        }
47
+            //        reg.Show();
48
+            //    }
49
+            //    //如果未超过期限,则可正常运行
50
+            //    else
51
+            //    {
52
+            //        //为了使命令在注册成功后才能使用,采用与一般添加命令不同的方法
53
+            //        BasicFunction functions = new BasicFunction();
54
+            //        //functions.addCommand();
55
+            Menus menu = new Menus();
56
+            menu.AddMenu();
57
+            //    }
58
+            //}
59
+        }
60
+        //Tools tool = new Tools();
61
+        //tool.AddTools();
62
+
63
+        public void Terminate()
64
+        {
65
+            //BasicFunction functions = new BasicFunction();
66
+            //functions.deleteCommand();
67
+        }
68
+
69
+        public static string Flag = "";      //标记不同命令
70
+        public int num = 1; //0超过期限,-1空
71
+        public int slf_flag = 0;
72
+
73
+        //加密
74
+        private static string Encrypt(string str,string key)
75
+        {
76
+            DESCryptoServiceProvider des = new DESCryptoServiceProvider();
77
+            byte[] inputByteArray = Encoding.Default.GetBytes(str);
78
+            des.Key = ASCIIEncoding.ASCII.GetBytes(key);// 密钥
79
+            des.IV = ASCIIEncoding.ASCII.GetBytes(key);// 初始化向量
80
+            MemoryStream ms = new MemoryStream();
81
+            CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(), CryptoStreamMode.Write);
82
+            cs.Write(inputByteArray, 0, inputByteArray.Length);
83
+            cs.FlushFinalBlock();
84
+            var retB = Convert.ToBase64String(ms.ToArray());
85
+            return retB;
86
+        }
87
+
88
+        //解密
89
+        private static string Decrypt(string pToDecrypt, string key)
90
+        {
91
+            DESCryptoServiceProvider des = new DESCryptoServiceProvider();
92
+            byte[] inputByteArray = Convert.FromBase64String(pToDecrypt);
93
+            des.Key = ASCIIEncoding.ASCII.GetBytes(key);
94
+            des.IV = ASCIIEncoding.ASCII.GetBytes(key);
95
+            MemoryStream ms = new MemoryStream();
96
+            CryptoStream cs = new CryptoStream(ms, des.CreateDecryptor(), CryptoStreamMode.Write);
97
+            cs.Write(inputByteArray, 0, inputByteArray.Length);
98
+            // 如果两次密钥不一样,这一步可能会引发异常
99
+            cs.FlushFinalBlock();
100
+            return System.Text.Encoding.Default.GetString(ms.ToArray());
101
+        }
102
+
103
+        //日期加密并放到注册表中
104
+        private void AddRecord()
105
+        {
106
+            string byte2string = null;
107
+            ManagementClass mc = new ManagementClass("Win32_Processor");
108
+            ManagementObjectCollection moc = mc.GetInstances();
109
+            string strCpuID = null;
110
+            foreach (ManagementObject mo in moc)
111
+            {
112
+                strCpuID = mo.Properties["ProcessorId"].Value.ToString();
113
+                break;
114
+            }
115
+            byte[] from = Encoding.Default.GetBytes(strCpuID);
116
+            MD5CryptoServiceProvider makemd5 = new MD5CryptoServiceProvider();
117
+            byte[] target = makemd5.ComputeHash(from);
118
+            for (int i = 0; i < target.Length; i++)
119
+            {
120
+                byte2string += target[i].ToString("x");
121
+            }
122
+
123
+            Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
124
+            Editor ed = acDoc.Editor;
125
+            PromptStringOptions options = new PromptStringOptions("机器码:" + byte2string + "\n输入注册码:");
126
+            options.AllowSpaces = true;
127
+            options.UseDefaultValue = true;
128
+            options.DefaultValue = "";
129
+
130
+            string encrypted = Encrypt(byte2string, "vnf4s3ru");
131
+            string userInput = ed.GetString(options).StringResult;
132
+            if (userInput == "")
133
+            {
134
+                num = -1;
135
+                return;
136
+            }
137
+            string jm = Decrypt(userInput, "vnf4s3ru");
138
+            string zcm = jm.Split(',')[0];
139
+            string zcm_encrypted = Encrypt(zcm, "vnf4s3ru");
140
+            string work_days = jm.Split(',')[1];
141
+            if (zcm_encrypted == encrypted)
142
+            {
143
+                string dt = DateTime.Now.ToString().Trim();
144
+                dt = dt +',' + work_days;
145
+                string dt_ecpt = Encrypt(dt, "vnf4s3ru");
146
+                Microsoft.Win32.Registry.CurrentUser.OpenSubKey("Software", true).CreateSubKey("CADplugins").CreateSubKey("Register.INI").CreateSubKey(dt_ecpt);
147
+                MessageBox.Show("注册成功!");
148
+            }
149
+            else
150
+            {
151
+                MessageBox.Show("注册失败!\n zcm_encrypted ="+ zcm_encrypted.ToString() + "\nencrypted="+ encrypted.ToString() + "\nzcm=" + zcm.ToString()+"\njm=" + jm.ToString());
152
+                MessageBox.Show("注册失败!");
153
+                num = -1;
154
+            }
155
+        }
156
+
157
+        public void Verify()
158
+        {
159
+            Microsoft.Win32.RegistryKey retkey = Microsoft.Win32.Registry.CurrentUser.OpenSubKey("SOFTWARE", true).CreateSubKey("CADplugins").CreateSubKey("Register.INI");
160
+            //判断注册表中相应位置的subkey数量,如果为零的话则需要注册
161
+            if (retkey.SubKeyCount == 0)
162
+            {
163
+                AddRecord();
164
+            }
165
+            //如果不为零,判断日期是否在期限内
166
+            else
167
+            {
168
+                //转换为日期格式后检查当前日期之间和输入注册码的日期之间的间隔
169
+                string encrypted = retkey.GetSubKeyNames()[0];
170
+                string mw = Decrypt(encrypted, "vnf4s3ru");
171
+                string dt = mw.Split(',')[0];
172
+                int wkdays = Convert.ToInt32(mw.Split(',')[1]);
173
+                TimeSpan ts = DateTime.Now - DateTime.Parse(dt);
174
+                //如果超过期限,则删除所有subkey,显示注册码窗口
175
+                if (ts.Days > wkdays || ts.Days < 0)
176
+                {
177
+                    MessageBox.Show("超出有效期,请重新注册!");
178
+                    num = 0;
179
+                    foreach (string strRNum in retkey.GetSubKeyNames())
180
+                    {
181
+                        retkey.DeleteSubKey(strRNum);
182
+                    }
183
+                    AddRecord();
184
+                }
185
+                else
186
+                {
187
+                    num = 1;
188
+                }
189
+            }
190
+        }
191
+
192
+        ////点线矛盾
193
+        [CommandMethod("PLError")]
194
+        public void PLError()
195
+        {
196
+            Verify();
197
+            if (num == 1)
198
+            {
199
+                PtLinecontradiction pl = new PtLinecontradiction();
200
+                pl.Show();
201
+                //Parameters Frm = new Parameters();
202
+                //Frm.Show();
203
+            }
204
+        }
205
+
206
+        //点线重叠
207
+        [CommandMethod("PLOverlap")]
208
+        public void PLOverlap()
209
+        {
210
+            Verify();
211
+            if (num == 1)
212
+            {
213
+                Flag = "PLOverlap";
214
+                PLError_Overlay pl = new PLError_Overlay();
215
+                pl.Show();
216
+                //Parameters Frm = new Parameters();
217
+                //Frm.Show();
218
+            }
219
+        }
220
+
221
+
222
+        //地物压盖
223
+        [CommandMethod("FeaatureOverlap")]
224
+        public void FeaatureOverlap()
225
+        {
226
+            Verify();
227
+            if (num == 1)
228
+            {
229
+                Scale Frm = new Scale();
230
+                Frm.Show();
231
+            }
232
+        }
233
+
234
+        //图斑面积统计
235
+
236
+        //[CommandMethod("Report")]
237
+        //public void Report()
238
+        //{
239
+        //    //Verify();
240
+        //    //if (num == 1)
241
+        //    //{
242
+        //        Flag = "Report";
243
+        //        StatisticsArea statisticsarea = new StatisticsArea();
244
+        //        statisticsarea.statistics();
245
+        //    //}
246
+        //}
247
+
248
+        //图斑信息
249
+        //[CommandMethod("Fills")]
250
+        //public void Fill()
251
+        //{
252
+        //    //Verify();
253
+        //    //if (num == 1)
254
+        //    //{
255
+        //        StatisticsArea statics = new StatisticsArea();
256
+        //        statics.fillboundary();
257
+        //    //}
258
+        //}
259
+
260
+        //图斑节点查看
261
+        //[CommandMethod("ViewPoint")]
262
+        //public void ViewPoint()
263
+        //{
264
+        //    Flag = "ViewPoint";
265
+        //    Parameters Frm = new Parameters();
266
+        //    Frm.Show();
267
+        //}
268
+
269
+        //自动生成图框
270
+        [CommandMethod("SheetMap")]
271
+        public void SheetMap()
272
+        {
273
+            Verify();
274
+            if (num == 1)
275
+            {
276
+                TKInfo tk = new TKInfo();
277
+                tk.Show();
278
+                //Flag = "SheetMap";
279
+                //Parameters noteFrm = new Parameters();
280
+                //noteFrm.Show();
281
+            }
282
+        }
283
+
284
+        //批量替换
285
+        [CommandMethod("BATChange")]
286
+        public void BATChange()
287
+        {
288
+            Verify();
289
+            if (num == 1)
290
+            {
291
+                Chaginfos cginfos = new Chaginfos();
292
+                cginfos.Show();
293
+                //Flag = "BATChange";
294
+                //Parameters change = new Parameters();
295
+                //change.Show();
296
+            }
297
+        }
298
+
299
+        //高程点值是否为零、与注记是否一致检查
300
+        [CommandMethod("PtCheck")]
301
+        public void PointCheck()
302
+        {
303
+            Verify();
304
+            if (num == 1)
305
+            {
306
+                PtCheck ptc = new PtCheck();
307
+                ptc.Show();
308
+                //Flag = "PtCheck";
309
+                //Parameters ptcheck = new Parameters();
310
+                //ptcheck.Show();
311
+            }
312
+        }
313
+
314
+        //等高线分层
315
+        [CommandMethod("Hierarchy")]
316
+        public void Hierarchy()
317
+        {
318
+            Verify();
319
+            if (num == 1)
320
+            {
321
+                Hierak hier = new Hierak();
322
+                hier.Show();
323
+                //Flag = "Hierarchy";
324
+                //Parameters hierarchy = new Parameters();
325
+                //hierarchy.Show();
326
+            }
327
+        }
328
+
329
+        //等高线检查
330
+        [CommandMethod("CLCheck")]
331
+        public void CLCheck()
332
+        {
333
+            Verify();
334
+            if (num == 1)
335
+            {
336
+                CheckL cl = new CheckL();
337
+                cl.Show();
338
+                //Flag = "CLCheck";
339
+                //Parameters clcheck = new Parameters();
340
+                //clcheck.Show();
341
+            }
342
+        }
343
+
344
+        //线线连接
345
+        [CommandMethod("Connect")]
346
+        public void Connect()
347
+        {
348
+            Verify();
349
+            if (num == 1)
350
+            {
351
+                Flag = "Connect";
352
+                Connect connect = new Connect();
353
+                connect.joinplline();
354
+            }
355
+        }
356
+
357
+        //等高线取整
358
+        [CommandMethod("EleRd")]
359
+        public void EleRd()
360
+        {
361
+            Verify();
362
+            if (num == 1)
363
+            {
364
+                Flag = "Connect";
365
+                EleRd form = new EleRd();
366
+                form.Show();
367
+            }
368
+        }
369
+
370
+        //线自相交
371
+        [CommandMethod("SelfIntersect")]
372
+        public void SelfIntersect()
373
+        {
374
+            Verify();
375
+            if (num == 1)
376
+            {
377
+                Flag = "SelfIntersect";
378
+                Conn con = new Conn();
379
+                con.Show();
380
+                //Parameters selfints = new Parameters();
381
+                //selfints.Show();
382
+            }
383
+        }
384
+
385
+        //线相交
386
+        [CommandMethod("EachIntersect")]
387
+        public void EachIntersect()
388
+        {
389
+            Verify();
390
+            if (num == 1)
391
+            {
392
+                Flag = "EachIntersect";
393
+                Conn con = new Conn();
394
+                con.Show();
395
+                //Parameters echints = new Parameters();
396
+                //echints.Show();
397
+            }
398
+        }
399
+
400
+        //提取点
401
+        [CommandMethod("pickupPoint")]
402
+        public void pickupP()
403
+        {
404
+            Verify();
405
+            if (num == 1)
406
+            {
407
+                PicPts pts = new PicPts();
408
+                pts.Show();
409
+                //Flag = "pickupPoint";
410
+                //Parameters pickupPt = new Parameters();
411
+                //pickupPt.Show();
412
+            }
413
+        }
414
+
415
+        #region 无用
416
+        ////伪节点检查
417
+        //[CommandMethod("FakeCheck")]
418
+        //public void FFake()
419
+        //{
420
+        //    //Verify();
421
+        //    //if (num == 1)
422
+        //    //{
423
+        //        Flag = "FakeCheck";
424
+        //        Fake_HangCheck fc = new Fake_HangCheck();
425
+        //        fc.Show();
426
+        //        //Parameters FC = new Parameters();
427
+        //        //FC.Show();
428
+        //    //}
429
+        //}
430
+
431
+        ////悬挂节点检查
432
+        //[CommandMethod("HangCheck")]
433
+        //public void HFake()
434
+        //{
435
+        //    //Verify();
436
+        //    //if (num == 1)
437
+        //    //{
438
+        //        Flag = "HangCheck";
439
+        //        Fake_HangCheck fc = new Fake_HangCheck();
440
+        //        fc.Show();
441
+        //        //Parameters HC = new Parameters();
442
+        //        //HC.Show();
443
+        //    //}
444
+        //}
445
+
446
+        //示坡线
447
+        [CommandMethod("SlopeLine")]
448
+        public void SlpLine()
449
+        {
450
+            Verify();
451
+            if (num == 1)
452
+            {
453
+                SlopeL sl = new SlopeL();
454
+                sl.Show();
455
+            }
456
+        }
457
+        #endregion
458
+
459
+        //批量插入DOM
460
+        [CommandMethod("InstDOM")]
461
+        public void IstDOM()
462
+        {
463
+            Verify();
464
+            if (num == 1)
465
+            {
466
+                InstDOM istdom = new InstDOM();
467
+                istdom.Show();
468
+                //Flag = "SlopeLine";
469
+                //Parameters SL = new Parameters();
470
+                //SL.Show();
471
+            }
472
+        }
473
+
474
+        //批量插入DOM(多对一)
475
+        [CommandMethod("InstDOMs")]
476
+        public void IstDOMs()
477
+        {
478
+            Verify();
479
+            if (num == 1)
480
+            {
481
+                InsertDOMs_to_one istdom = new InsertDOMs_to_one();
482
+                istdom.Show();
483
+                //Flag = "SlopeLine";
484
+                //Parameters SL = new Parameters();
485
+                //SL.Show();
486
+            }
487
+        }
488
+
489
+        //等高线缩编
490
+        [CommandMethod("Dgxsb")]
491
+        public void dgxSB()
492
+        {
493
+            Verify();
494
+            if (num == 1)
495
+            {
496
+                DGXGeneral Frm = new DGXGeneral();
497
+                Frm.Show();
498
+            }
499
+        }
500
+
501
+        //图层删改
502
+        [CommandMethod("Layercg")]
503
+        public void Layercg()
504
+        {
505
+            Verify();
506
+            if (num == 1)
507
+            {
508
+                Layerchange_Form Frm = new Layerchange_Form();
509
+                Frm.Show();
510
+            }
511
+        }
512
+
513
+        //属性表
514
+        [CommandMethod("Attribute")]
515
+        public void Attribute()
516
+        {
517
+            Verify();
518
+            if (num == 1)
519
+            {
520
+                Attributeget atbget = new Attributeget();
521
+                atbget.attribt();
522
+            }
523
+        }
524
+
525
+        //等高线拉线修改
526
+        [CommandMethod("CLfix")]
527
+        public void CLfix()
528
+        {
529
+            Verify();
530
+            if (num == 1)
531
+            {
532
+                ContourLineFix conlgix = new ContourLineFix();
533
+                conlgix.Clfix();
534
+            }
535
+        }
536
+
537
+        //高程点密度检查
538
+        [CommandMethod("PtDenck")]
539
+        public void PtDensityck()
540
+        {
541
+            Verify();
542
+            if (num == 1)
543
+            {
544
+                EleptDensity form = new EleptDensity();
545
+                form.Show();
546
+            }
547
+        }
548
+
549
+        //等高线注记密度检查
550
+        [CommandMethod("DgxAnnDenck")]
551
+        public void DgxAnnoDensityck()
552
+        {
553
+            Verify();
554
+            if (num == 1)
555
+            {
556
+                DgxAnno form = new DgxAnno();
557
+                form.Show();
558
+            }
559
+        }
560
+
561
+        //删除高程点
562
+        [CommandMethod("Deletept")]
563
+        public void Deletepts()
564
+        {
565
+            Verify();
566
+            if (num == 1)
567
+            {
568
+                DeleteElept form = new DeleteElept();
569
+                form.Show();
570
+            }
571
+        }
572
+
573
+        //等高线裁剪
574
+        [CommandMethod("CutDgx")]
575
+        public void CADTools()
576
+        {
577
+            Verify();
578
+            if (num == 1)
579
+            {
580
+                //CutCountL form = new CutCountL();
581
+                CutDgx form = new CutDgx();
582
+                form.Show();
583
+            }
584
+        }
585
+
586
+        //等高线内插
587
+        [CommandMethod("Dgxinter")]
588
+        public void Dgxnc()
589
+        {
590
+            Verify();
591
+            if (num == 1)
592
+            {
593
+                Dgxinters dgxinter = new Dgxinters();
594
+                dgxinter.Interdgx();
595
+            }
596
+        }
597
+
598
+        //等高线过河流道路房屋陡坎裁剪
599
+        [CommandMethod("Dgxthrorvrd")]
600
+        public void CADToolsthrorvrd()
601
+        {
602
+            Verify();
603
+            if (num == 1)
604
+            {
605
+                Dgxthrorvrd_Form form = new Dgxthrorvrd_Form();
606
+                form.Show();
607
+            }
608
+        }
609
+
610
+        //删除整数值高程点
611
+        [CommandMethod("Deleteintgcd")]
612
+        public void Deleteintgcd()
613
+        {
614
+            Verify();
615
+            if (num == 1)
616
+            {
617
+                GCDdelete_Form form = new GCDdelete_Form();
618
+                form.Show();
619
+            }
620
+        }
621
+
622
+        ////分幅输出地形图
623
+        //[CommandMethod("Clipdwg")]
624
+        //public void Clipdwg()
625
+        //{
626
+        //    Verify();
627
+        //    if (num == 1)
628
+        //    {
629
+        //        OutputbyTK_Form form = new OutputbyTK_Form();
630
+        //        form.Show();
631
+        //    }
632
+        //}
633
+
634
+
635
+        //图幅号修改
636
+        [CommandMethod("ChangeTFH")]
637
+        public void ChgTFH()
638
+        {
639
+            Verify();
640
+            if (num == 1)
641
+            {
642
+                ModifyTFH form = new ModifyTFH();
643
+                form.Show();
644
+            }
645
+        }
646
+
647
+
648
+        //计曲线高程按格网标注
649
+        [CommandMethod("JQXLabel")]
650
+        public void Jqxlb()
651
+        {
652
+            Verify();
653
+            if (num == 1)
654
+            {
655
+                JQXLabel_grid form = new JQXLabel_grid();
656
+                form.Show();
657
+            }
658
+        }
659
+
660
+        //合并dwg
661
+        [CommandMethod("Mergedwg")]
662
+        public void Merge()
663
+        {
664
+            Verify();
665
+            if (num == 1)
666
+            {
667
+                MergeDwg form = new MergeDwg();
668
+                form.Show();
669
+            }
670
+        }
671
+
672
+        //按图框裁剪等高线
673
+        [CommandMethod("CutDgxByTK")]
674
+        public void CutByTK()
675
+        {
676
+            Verify();
677
+            if (num == 1)
678
+            {
679
+                CutDgxByTK form = new CutDgxByTK();
680
+                form.Show();
681
+            }
682
+        }
683
+    }
684
+}

+ 168
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/Menus.cs 查看文件

@@ -0,0 +1,168 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Threading.Tasks;
6
+
7
+using Autodesk.AutoCAD.ApplicationServices;
8
+using Autodesk.AutoCAD.Runtime;
9
+using Autodesk.AutoCAD.Interop;
10
+
11
+namespace CADTools
12
+{
13
+    class Menus
14
+    {
15
+        public void AddMenu()
16
+        {
17
+            //COM方式获取AutoCAD应用程序对象
18
+            AcadApplication acadApp = (AcadApplication)Application.AcadApplication;
19
+            //为AutoCAD添加一个新的菜单,并设置标题为"地形图辅助"
20
+            AcadPopupMenu pm = acadApp.MenuGroups.Item(0).Menus.Add("地形图辅助");
21
+            //声明一个AutoCAD弹出菜单项,用于获取添加的菜单项对象
22
+            AcadPopupMenuItem pmi;
23
+
24
+
25
+
26
+
27
+            //在新建的菜单中添加一个名为"点线矛盾"的菜单项
28
+            pmi = pm.AddMenuItem(pm.Count + 1, "点线矛盾", "PLError ");
29
+            //设置状态栏提示信息
30
+            pmi.HelpString = "检查地形图点线矛盾";
31
+
32
+            pmi = pm.AddMenuItem(pm.Count + 1, "点线重叠", "PLOverlap ");
33
+            pmi.HelpString = "检查地形图点线重叠";
34
+
35
+            pmi = pm.AddMenuItem(pm.Count + 1, "地物压盖", "FeaatureOverlap ");
36
+            pmi.HelpString = "检查地形图地物压盖";
37
+
38
+            pmi = pm.AddMenuItem(pm.Count + 1, "节点提取", "pickupPoint ");
39
+            pmi.HelpString = "节点提取";
40
+
41
+            pmi = pm.AddMenuItem(pm.Count + 1, "等高线裁剪", "CutDgx ");
42
+            pmi.HelpString = "等高线裁剪";
43
+
44
+            pmi = pm.AddMenuItem(pm.Count + 1, "按图框等高线裁剪", "CutDgxByTK ");
45
+            pmi.HelpString = "按图框等高线裁剪";
46
+
47
+            //pmi = pm.AddMenuItem(pm.Count + 1, "伪节点检查", "FakeCheck ");
48
+            //pmi.HelpString = "伪节点检查";
49
+
50
+            //pmi = pm.AddMenuItem(pm.Count + 1, "悬挂节点检查", "HangCheck ");
51
+            //pmi.HelpString = "悬挂节点检查";
52
+
53
+            pmi = pm.AddMenuItem(pm.Count + 1, "批量插入DOM", "InstDOM ");
54
+            pmi.HelpString = "批量插入DOM";
55
+
56
+            pmi = pm.AddMenuItem(pm.Count + 1, "批量插入DOM(多对一)", "InstDOMs ");
57
+            pmi.HelpString = "批量插入DOM(多对一)";
58
+
59
+            //添加一个分隔条以区分不同类型的命令
60
+            pm.AddSeparator(pm.Count + 1);
61
+
62
+
63
+            //pmi = pm.AddMenuItem(pm.Count + 1, "图斑信息", "Report ");
64
+            //pmi.HelpString = "图斑信息";
65
+
66
+
67
+            //pmi = pm.AddMenuItem(pm.Count + 1, "填充", "Fills ");
68
+            //pmi.HelpString = "闭合多段线纯色填充";
69
+
70
+            //pmi = pm.AddMenuItem(pm.Count + 1, "图斑信息", "ViewPoint ");
71
+            //pmi.HelpString = "图斑信息";
72
+
73
+
74
+            ////添加一个分隔条以区分不同类型的命令
75
+            //pm.AddSeparator(pm.Count + 1);
76
+
77
+
78
+            pmi = pm.AddMenuItem(pm.Count + 1, "自动生成图框", "SheetMap ");
79
+            pmi.HelpString = "自动生成图框";
80
+
81
+            //pmi = pm.AddMenuItem(pm.Count + 1, "分幅输出地形图", "Clipdwg ");
82
+            //pmi.HelpString = "分幅输出地形图";
83
+
84
+            pmi = pm.AddMenuItem(pm.Count + 1, "图幅号修改", "ChangeTFH ");
85
+            pmi.HelpString = "图幅号修改";
86
+
87
+            pmi = pm.AddMenuItem(pm.Count + 1, "批量修改图框信息", "BATChange ");
88
+            pmi.HelpString = "批量修改图框信息";
89
+
90
+            pmi = pm.AddMenuItem(pm.Count + 1, "图层批量删改", "Layercg ");
91
+            pmi.HelpString = "图层批量删改";
92
+
93
+            pmi = pm.AddMenuItem(pm.Count + 1, "图层属性表", "Attribute ");
94
+            pmi.HelpString = "图层属性表";
95
+
96
+            pmi = pm.AddMenuItem(pm.Count + 1, "合并同名dwg", "Mergedwg ");
97
+            pmi.HelpString = "合并同名dwg";
98
+
99
+            //添加一个分隔条以区分不同类型的命令
100
+            pm.AddSeparator(pm.Count + 1);
101
+
102
+            pmi = pm.AddMenuItem(pm.Count + 1, "高程点检查", "PtCheck ");
103
+            pmi.HelpString = "检查高程点值与注记是否一致";
104
+
105
+            pmi = pm.AddMenuItem(pm.Count + 1, "高程点密度检查", "PtDenck ");
106
+            pmi.HelpString = "检查高程点在一定范围内密度";
107
+
108
+            pmi = pm.AddMenuItem(pm.Count + 1, "删除内部高程点", "Deletept ");
109
+            pmi.HelpString = "删除内部高程点";
110
+
111
+            pmi = pm.AddMenuItem(pm.Count + 1, "删除整数高程点", "Deleteintgcd ");
112
+            pmi.HelpString = "删除整数高程点";
113
+
114
+            pmi = pm.AddMenuItem(pm.Count + 1, "等高线分层", "Hierarchy ");
115
+            pmi.HelpString = "等高线分层";
116
+
117
+            pmi = pm.AddMenuItem(pm.Count + 1, "等高线检查", "CLCheck ");
118
+            pmi.HelpString = "等高线检查";
119
+
120
+            pmi = pm.AddMenuItem(pm.Count + 1, "等高线高程注记密度检查", "DgxAnnDenck ");
121
+            pmi.HelpString = "等高线高程注记检查";
122
+
123
+            pmi = pm.AddMenuItem(pm.Count + 1, "等高线缩编", "Dgxsb ");
124
+            pmi.HelpString = "等高线缩编";
125
+
126
+            pmi = pm.AddMenuItem(pm.Count + 1, "等高线拉线修改", "CLfix ");
127
+            pmi.HelpString = "等高线拉线修改";
128
+
129
+            pmi = pm.AddMenuItem(pm.Count + 1, "等高线内插", "Dgxinter ");
130
+            pmi.HelpString = "等高线内插";
131
+
132
+            pmi = pm.AddMenuItem(pm.Count + 1, "计曲线高程按格网标注", "JQXLabel ");
133
+            pmi.HelpString = "计曲线高程按格网标注";
134
+
135
+            pmi = pm.AddMenuItem(pm.Count + 1, "示坡线绘制", "SlopeLine ");
136
+            pmi.HelpString = "示坡线绘制";
137
+
138
+            //添加一个分隔条以区分不同类型的命令
139
+            pm.AddSeparator(pm.Count + 1);
140
+
141
+            pmi = pm.AddMenuItem(pm.Count + 1, "线连接", "Connect ");
142
+            pmi.HelpString = "线连接";
143
+
144
+            pmi = pm.AddMenuItem(pm.Count + 1, "检查线自相交", "SelfIntersect ");
145
+            pmi.HelpString = "线自相交";
146
+
147
+            pmi = pm.AddMenuItem(pm.Count + 1, "检查线线相交", "EachIntersect ");
148
+            pmi.HelpString = "线线相交";
149
+
150
+            pmi = pm.AddMenuItem(pm.Count + 1, "等高线高程取整", "EleRd ");
151
+            pmi.HelpString = "等高线高程取整";
152
+
153
+            pmi = pm.AddMenuItem(pm.Count + 1, "等高线过河流道路房屋陡坎裁剪", "Dgxthrorvrd ");
154
+            pmi.HelpString = "等高线过河流道路房屋陡坎裁剪";
155
+
156
+            //添加一个分隔条以区分不同类型的命令
157
+            pm.AddSeparator(pm.Count + 1);
158
+
159
+            //pmi = pm.AddMenuItem(pm.Count + 1, "合并面", "combFace ");
160
+            //pmi.HelpString = "合并面";
161
+
162
+            //pmi = pm.AddMenuItem(pm.Count + 1, "分割面", "splitFace ");
163
+            //pmi.HelpString = "分割面";
164
+            //将定义的菜单显示在AutoCAD菜单栏的最后
165
+            pm.InsertInMenuBar(acadApp.MenuBar.Count + 1);
166
+        }
167
+    }
168
+}

+ 167
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/MergeDwg.Designer.cs 查看文件

@@ -0,0 +1,167 @@
1
+
2
+namespace CADTools
3
+{
4
+    partial class MergeDwg
5
+    {
6
+        /// <summary>
7
+        /// Required designer variable.
8
+        /// </summary>
9
+        private System.ComponentModel.IContainer components = null;
10
+
11
+        /// <summary>
12
+        /// Clean up any resources being used.
13
+        /// </summary>
14
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
15
+        protected override void Dispose(bool disposing)
16
+        {
17
+            if (disposing && (components != null))
18
+            {
19
+                components.Dispose();
20
+            }
21
+            base.Dispose(disposing);
22
+        }
23
+
24
+        #region Windows Form Designer generated code
25
+
26
+        /// <summary>
27
+        /// Required method for Designer support - do not modify
28
+        /// the contents of this method with the code editor.
29
+        /// </summary>
30
+        private void InitializeComponent()
31
+        {
32
+            this.label1 = new System.Windows.Forms.Label();
33
+            this.label2 = new System.Windows.Forms.Label();
34
+            this.textBox_choose1 = new System.Windows.Forms.TextBox();
35
+            this.textBox_choose2 = new System.Windows.Forms.TextBox();
36
+            this.button_choose1 = new System.Windows.Forms.Button();
37
+            this.label3 = new System.Windows.Forms.Label();
38
+            this.textBox_aftermerge = new System.Windows.Forms.TextBox();
39
+            this.button_choose2 = new System.Windows.Forms.Button();
40
+            this.button_aftermerge = new System.Windows.Forms.Button();
41
+            this.button_ok = new System.Windows.Forms.Button();
42
+            this.SuspendLayout();
43
+            // 
44
+            // label1
45
+            // 
46
+            this.label1.AutoSize = true;
47
+            this.label1.Location = new System.Drawing.Point(76, 48);
48
+            this.label1.Name = "label1";
49
+            this.label1.Size = new System.Drawing.Size(120, 15);
50
+            this.label1.TabIndex = 0;
51
+            this.label1.Text = "待合并文件夹1:";
52
+            // 
53
+            // label2
54
+            // 
55
+            this.label2.AutoSize = true;
56
+            this.label2.Location = new System.Drawing.Point(76, 110);
57
+            this.label2.Name = "label2";
58
+            this.label2.Size = new System.Drawing.Size(120, 15);
59
+            this.label2.TabIndex = 1;
60
+            this.label2.Text = "待合并文件夹2:";
61
+            // 
62
+            // textBox_choose1
63
+            // 
64
+            this.textBox_choose1.Location = new System.Drawing.Point(211, 45);
65
+            this.textBox_choose1.Name = "textBox_choose1";
66
+            this.textBox_choose1.Size = new System.Drawing.Size(300, 25);
67
+            this.textBox_choose1.TabIndex = 2;
68
+            // 
69
+            // textBox_choose2
70
+            // 
71
+            this.textBox_choose2.Location = new System.Drawing.Point(211, 107);
72
+            this.textBox_choose2.Name = "textBox_choose2";
73
+            this.textBox_choose2.Size = new System.Drawing.Size(300, 25);
74
+            this.textBox_choose2.TabIndex = 3;
75
+            // 
76
+            // button_choose1
77
+            // 
78
+            this.button_choose1.Location = new System.Drawing.Point(541, 38);
79
+            this.button_choose1.Name = "button_choose1";
80
+            this.button_choose1.Size = new System.Drawing.Size(75, 29);
81
+            this.button_choose1.TabIndex = 4;
82
+            this.button_choose1.Text = "选 择";
83
+            this.button_choose1.UseVisualStyleBackColor = true;
84
+            this.button_choose1.Click += new System.EventHandler(this.button_choose1_Click);
85
+            // 
86
+            // label3
87
+            // 
88
+            this.label3.AutoSize = true;
89
+            this.label3.Location = new System.Drawing.Point(54, 169);
90
+            this.label3.Name = "label3";
91
+            this.label3.Size = new System.Drawing.Size(151, 15);
92
+            this.label3.TabIndex = 6;
93
+            this.label3.Text = "合并后dwg所在位置:";
94
+            // 
95
+            // textBox_aftermerge
96
+            // 
97
+            this.textBox_aftermerge.Location = new System.Drawing.Point(211, 166);
98
+            this.textBox_aftermerge.Name = "textBox_aftermerge";
99
+            this.textBox_aftermerge.Size = new System.Drawing.Size(300, 25);
100
+            this.textBox_aftermerge.TabIndex = 7;
101
+            // 
102
+            // button_choose2
103
+            // 
104
+            this.button_choose2.Location = new System.Drawing.Point(541, 103);
105
+            this.button_choose2.Name = "button_choose2";
106
+            this.button_choose2.Size = new System.Drawing.Size(75, 29);
107
+            this.button_choose2.TabIndex = 8;
108
+            this.button_choose2.Text = "选 择";
109
+            this.button_choose2.UseVisualStyleBackColor = true;
110
+            this.button_choose2.Click += new System.EventHandler(this.button_choose2_Click);
111
+            // 
112
+            // button_aftermerge
113
+            // 
114
+            this.button_aftermerge.Location = new System.Drawing.Point(541, 166);
115
+            this.button_aftermerge.Name = "button_aftermerge";
116
+            this.button_aftermerge.Size = new System.Drawing.Size(75, 29);
117
+            this.button_aftermerge.TabIndex = 9;
118
+            this.button_aftermerge.Text = "选 择";
119
+            this.button_aftermerge.UseVisualStyleBackColor = true;
120
+            this.button_aftermerge.Click += new System.EventHandler(this.button_aftermerge_Click);
121
+            // 
122
+            // button_ok
123
+            // 
124
+            this.button_ok.Location = new System.Drawing.Point(297, 224);
125
+            this.button_ok.Name = "button_ok";
126
+            this.button_ok.Size = new System.Drawing.Size(75, 30);
127
+            this.button_ok.TabIndex = 10;
128
+            this.button_ok.Text = "确 定";
129
+            this.button_ok.UseVisualStyleBackColor = true;
130
+            this.button_ok.Click += new System.EventHandler(this.button_ok_Click);
131
+            // 
132
+            // MergeDwg
133
+            // 
134
+            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
135
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
136
+            this.ClientSize = new System.Drawing.Size(671, 285);
137
+            this.Controls.Add(this.button_ok);
138
+            this.Controls.Add(this.button_aftermerge);
139
+            this.Controls.Add(this.button_choose2);
140
+            this.Controls.Add(this.textBox_aftermerge);
141
+            this.Controls.Add(this.label3);
142
+            this.Controls.Add(this.button_choose1);
143
+            this.Controls.Add(this.textBox_choose2);
144
+            this.Controls.Add(this.textBox_choose1);
145
+            this.Controls.Add(this.label2);
146
+            this.Controls.Add(this.label1);
147
+            this.Name = "MergeDwg";
148
+            this.Text = "合并dwg";
149
+            this.ResumeLayout(false);
150
+            this.PerformLayout();
151
+
152
+        }
153
+
154
+        #endregion
155
+
156
+        private System.Windows.Forms.Label label1;
157
+        private System.Windows.Forms.Label label2;
158
+        private System.Windows.Forms.TextBox textBox_choose1;
159
+        private System.Windows.Forms.TextBox textBox_choose2;
160
+        private System.Windows.Forms.Button button_choose1;
161
+        private System.Windows.Forms.Label label3;
162
+        private System.Windows.Forms.TextBox textBox_aftermerge;
163
+        private System.Windows.Forms.Button button_choose2;
164
+        private System.Windows.Forms.Button button_aftermerge;
165
+        private System.Windows.Forms.Button button_ok;
166
+    }
167
+}

+ 156
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/MergeDwg.cs 查看文件

@@ -0,0 +1,156 @@
1
+using Autodesk.AutoCAD.ApplicationServices;
2
+using Autodesk.AutoCAD.DatabaseServices;
3
+using System;
4
+using System.Collections.Generic;
5
+using System.ComponentModel;
6
+using System.Data;
7
+using System.Drawing;
8
+using System.IO;
9
+using System.Linq;
10
+using System.Text;
11
+using System.Threading.Tasks;
12
+using System.Windows.Forms;
13
+
14
+namespace CADTools
15
+{
16
+    public partial class MergeDwg : Form
17
+    {
18
+        public MergeDwg()
19
+        {
20
+            InitializeComponent();
21
+        }
22
+
23
+        private void button_choose1_Click(object sender, EventArgs e)
24
+        {
25
+            FolderBrowserDialog open = new FolderBrowserDialog();
26
+            open.Description = "请选择文件夹";
27
+            if (open.ShowDialog() == System.Windows.Forms.DialogResult.OK)
28
+            {
29
+                textBox_choose1.Text = open.SelectedPath;
30
+            }
31
+        }
32
+
33
+        private void button_choose2_Click(object sender, EventArgs e)
34
+        {
35
+            FolderBrowserDialog open = new FolderBrowserDialog();
36
+            open.Description = "请选择文件夹";
37
+            if (open.ShowDialog() == System.Windows.Forms.DialogResult.OK)
38
+            {
39
+                textBox_choose2.Text = open.SelectedPath;
40
+            }
41
+        }
42
+
43
+        private void button_aftermerge_Click(object sender, EventArgs e)
44
+        {
45
+            FolderBrowserDialog open = new FolderBrowserDialog();
46
+            open.Description = "请选择文件夹";
47
+            if (open.ShowDialog() == System.Windows.Forms.DialogResult.OK)
48
+            {
49
+                textBox_aftermerge.Text = open.SelectedPath;
50
+            }
51
+        }
52
+
53
+        private void button_ok_Click(object sender, EventArgs e)
54
+        {
55
+            if (textBox_choose1.Text.Trim() == "")
56
+            {
57
+                MessageBox.Show("请选择待合并文件夹1");
58
+            }
59
+            if (textBox_choose2.Text.Trim() == "")
60
+            {
61
+                MessageBox.Show("请选择待合并文件夹2");
62
+            }
63
+            if (textBox_aftermerge.Text.Trim() == "")
64
+            {
65
+                MessageBox.Show("请选择合并后dwg所在位置");
66
+            }
67
+            List<String> dwgname1 = GetNameList(textBox_choose1.Text.ToString(), ".dwg");//获取dwg文件
68
+            if (dwgname1.Count == 0)
69
+            {
70
+                MessageBox.Show("没有在" + textBox_choose1.Text.ToString() + "中找到dwg文件!", "警告");
71
+                return;
72
+            }
73
+            List<String> dwgname2 = GetNameList(textBox_choose2.Text.ToString(), ".dwg");//获取dwg文件
74
+            if (dwgname2.Count == 0)
75
+            {
76
+                MessageBox.Show("没有在" + textBox_choose2.Text.ToString() + "中找到dwg文件!", "警告");
77
+                return;
78
+            }
79
+            for (int i = 0; i < dwgname1.Count; i++)
80
+            {
81
+                //新建dwg
82
+                string templatePath = "acad.dwt";
83
+                DocumentCollection documentcoll = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager;
84
+                Document document = documentcoll.Add(templatePath);
85
+                Database newdb = document.Database;
86
+                using (Transaction targetTrans = newdb.TransactionManager.StartTransaction())
87
+                {
88
+                    string sourcePath1 = textBox_choose1.Text.ToString() + "\\" + dwgname1[i];
89
+                    string sourcePath2 = textBox_choose2.Text.ToString() + "\\" + dwgname1[i];
90
+                    Merge(sourcePath1, newdb, targetTrans);
91
+                    Merge(sourcePath2, newdb, targetTrans);
92
+                    targetTrans.Commit();
93
+                }
94
+                dynamic acadApp = Autodesk.AutoCAD.ApplicationServices.Application.AcadApplication;
95
+                acadApp.ZoomExtents();
96
+                string newFilePath = Path.Combine(textBox_aftermerge.Text.ToString(), dwgname1[i]);
97
+                newdb.SaveAs(newFilePath, true, DwgVersion.AC1021, newdb.SecurityParameters);
98
+                document.CloseAndDiscard();
99
+            }
100
+            this.Close();
101
+        }
102
+
103
+        private List<String> GetNameList(String filespath, String filetype)
104
+        {
105
+            DirectoryInfo root = new DirectoryInfo(filespath);
106
+            List<String> filename = new List<string>();     //文件名
107
+            FileInfo[] files = root.GetFiles();
108
+            foreach (FileInfo file in files)
109
+            {
110
+                if (file.Name.Substring(file.Name.Length - 4, 4) != filetype)
111
+                    continue;
112
+                else
113
+                    filename.Add(file.Name);
114
+            }
115
+            return filename;
116
+        }
117
+
118
+        private void Merge(string sourceFilePath, Database targetDb, Transaction targetTrans)
119
+        {
120
+            DocumentLock doclock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
121
+            //后台只读模式打开源DWG文件
122
+            using (Database sourceDb = new Database(false, true))
123
+            {
124
+                sourceDb.ReadDwgFile(sourceFilePath, FileOpenMode.OpenForReadAndAllShare, false, null);
125
+
126
+                //准备克隆所需的ID映射集合
127
+                ObjectIdCollection idCollection = new ObjectIdCollection();
128
+                using (Transaction sourceTrans = sourceDb.TransactionManager.StartTransaction())
129
+                {
130
+                    //获取源文件的模型空间块表记录ID
131
+                    BlockTable sourceBt = (BlockTable)sourceTrans.GetObject(sourceDb.BlockTableId, OpenMode.ForRead);
132
+                    ObjectId sourceModelSpaceId = sourceBt[BlockTableRecord.ModelSpace];
133
+
134
+                    //将模型空间中的所有实体ID添加到集合
135
+                    BlockTableRecord sourceMs = (BlockTableRecord)sourceTrans.GetObject(sourceModelSpaceId, OpenMode.ForRead);
136
+                    foreach (ObjectId objId in sourceMs)
137
+                    {
138
+                        idCollection.Add(objId);
139
+                    }
140
+                    sourceTrans.Commit();
141
+                }
142
+                //复制
143
+                if (idCollection.Count > 0)
144
+                {
145
+                    BlockTable targetBlockTable = targetTrans.GetObject(targetDb.BlockTableId, OpenMode.ForRead) as BlockTable;
146
+                    BlockTableRecord targetTableRecord = targetTrans.GetObject(targetBlockTable[BlockTableRecord.ModelSpace], OpenMode.ForWrite) as BlockTableRecord;
147
+                    using (IdMapping mapping = new IdMapping())
148
+                        targetDb.WblockCloneObjects(idCollection, targetTableRecord.ObjectId, mapping, DuplicateRecordCloning.Replace, false);
149
+
150
+                }
151
+
152
+            }
153
+            doclock.Dispose();
154
+        }
155
+    }
156
+}

+ 120
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/MergeDwg.resx 查看文件

@@ -0,0 +1,120 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<root>
3
+  <!-- 
4
+    Microsoft ResX Schema 
5
+    
6
+    Version 2.0
7
+    
8
+    The primary goals of this format is to allow a simple XML format 
9
+    that is mostly human readable. The generation and parsing of the 
10
+    various data types are done through the TypeConverter classes 
11
+    associated with the data types.
12
+    
13
+    Example:
14
+    
15
+    ... ado.net/XML headers & schema ...
16
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
17
+    <resheader name="version">2.0</resheader>
18
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
19
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
20
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
21
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
22
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
24
+    </data>
25
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
26
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
27
+        <comment>This is a comment</comment>
28
+    </data>
29
+                
30
+    There are any number of "resheader" rows that contain simple 
31
+    name/value pairs.
32
+    
33
+    Each data row contains a name, and value. The row also contains a 
34
+    type or mimetype. Type corresponds to a .NET class that support 
35
+    text/value conversion through the TypeConverter architecture. 
36
+    Classes that don't support this are serialized and stored with the 
37
+    mimetype set.
38
+    
39
+    The mimetype is used for serialized objects, and tells the 
40
+    ResXResourceReader how to depersist the object. This is currently not 
41
+    extensible. For a given mimetype the value must be set accordingly:
42
+    
43
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
44
+    that the ResXResourceWriter will generate, however the reader can 
45
+    read any of the formats listed below.
46
+    
47
+    mimetype: application/x-microsoft.net.object.binary.base64
48
+    value   : The object must be serialized with 
49
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
50
+            : and then encoded with base64 encoding.
51
+    
52
+    mimetype: application/x-microsoft.net.object.soap.base64
53
+    value   : The object must be serialized with 
54
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
55
+            : and then encoded with base64 encoding.
56
+
57
+    mimetype: application/x-microsoft.net.object.bytearray.base64
58
+    value   : The object must be serialized into a byte array 
59
+            : using a System.ComponentModel.TypeConverter
60
+            : and then encoded with base64 encoding.
61
+    -->
62
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
64
+    <xsd:element name="root" msdata:IsDataSet="true">
65
+      <xsd:complexType>
66
+        <xsd:choice maxOccurs="unbounded">
67
+          <xsd:element name="metadata">
68
+            <xsd:complexType>
69
+              <xsd:sequence>
70
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
71
+              </xsd:sequence>
72
+              <xsd:attribute name="name" use="required" type="xsd:string" />
73
+              <xsd:attribute name="type" type="xsd:string" />
74
+              <xsd:attribute name="mimetype" type="xsd:string" />
75
+              <xsd:attribute ref="xml:space" />
76
+            </xsd:complexType>
77
+          </xsd:element>
78
+          <xsd:element name="assembly">
79
+            <xsd:complexType>
80
+              <xsd:attribute name="alias" type="xsd:string" />
81
+              <xsd:attribute name="name" type="xsd:string" />
82
+            </xsd:complexType>
83
+          </xsd:element>
84
+          <xsd:element name="data">
85
+            <xsd:complexType>
86
+              <xsd:sequence>
87
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
88
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
89
+              </xsd:sequence>
90
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
91
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
92
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
93
+              <xsd:attribute ref="xml:space" />
94
+            </xsd:complexType>
95
+          </xsd:element>
96
+          <xsd:element name="resheader">
97
+            <xsd:complexType>
98
+              <xsd:sequence>
99
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
100
+              </xsd:sequence>
101
+              <xsd:attribute name="name" type="xsd:string" use="required" />
102
+            </xsd:complexType>
103
+          </xsd:element>
104
+        </xsd:choice>
105
+      </xsd:complexType>
106
+    </xsd:element>
107
+  </xsd:schema>
108
+  <resheader name="resmimetype">
109
+    <value>text/microsoft-resx</value>
110
+  </resheader>
111
+  <resheader name="version">
112
+    <value>2.0</value>
113
+  </resheader>
114
+  <resheader name="reader">
115
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116
+  </resheader>
117
+  <resheader name="writer">
118
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119
+  </resheader>
120
+</root>

+ 109
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/ModifyTFH.Designer.cs 查看文件

@@ -0,0 +1,109 @@
1
+
2
+namespace CADTools
3
+{
4
+    partial class ModifyTFH
5
+    {
6
+        /// <summary>
7
+        /// Required designer variable.
8
+        /// </summary>
9
+        private System.ComponentModel.IContainer components = null;
10
+
11
+        /// <summary>
12
+        /// Clean up any resources being used.
13
+        /// </summary>
14
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
15
+        protected override void Dispose(bool disposing)
16
+        {
17
+            if (disposing && (components != null))
18
+            {
19
+                components.Dispose();
20
+            }
21
+            base.Dispose(disposing);
22
+        }
23
+
24
+        #region Windows Form Designer generated code
25
+
26
+        /// <summary>
27
+        /// Required method for Designer support - do not modify
28
+        /// the contents of this method with the code editor.
29
+        /// </summary>
30
+        private void InitializeComponent()
31
+        {
32
+            this.label1 = new System.Windows.Forms.Label();
33
+            this.comboBox_tfh = new System.Windows.Forms.ComboBox();
34
+            this.label2 = new System.Windows.Forms.Label();
35
+            this.textBox_target = new System.Windows.Forms.TextBox();
36
+            this.button_ok = new System.Windows.Forms.Button();
37
+            this.SuspendLayout();
38
+            // 
39
+            // label1
40
+            // 
41
+            this.label1.AutoSize = true;
42
+            this.label1.Location = new System.Drawing.Point(133, 46);
43
+            this.label1.Name = "label1";
44
+            this.label1.Size = new System.Drawing.Size(127, 15);
45
+            this.label1.TabIndex = 0;
46
+            this.label1.Text = "图幅号所在图层:";
47
+            // 
48
+            // comboBox_tfh
49
+            // 
50
+            this.comboBox_tfh.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
51
+            this.comboBox_tfh.FormattingEnabled = true;
52
+            this.comboBox_tfh.Location = new System.Drawing.Point(266, 43);
53
+            this.comboBox_tfh.Name = "comboBox_tfh";
54
+            this.comboBox_tfh.Size = new System.Drawing.Size(165, 23);
55
+            this.comboBox_tfh.TabIndex = 1;
56
+            // 
57
+            // label2
58
+            // 
59
+            this.label2.AutoSize = true;
60
+            this.label2.Location = new System.Drawing.Point(43, 114);
61
+            this.label2.Name = "label2";
62
+            this.label2.Size = new System.Drawing.Size(217, 15);
63
+            this.label2.TabIndex = 2;
64
+            this.label2.Text = "第一个图框图幅号的目标格式:";
65
+            // 
66
+            // textBox_target
67
+            // 
68
+            this.textBox_target.Location = new System.Drawing.Point(266, 111);
69
+            this.textBox_target.Name = "textBox_target";
70
+            this.textBox_target.Size = new System.Drawing.Size(165, 25);
71
+            this.textBox_target.TabIndex = 3;
72
+            // 
73
+            // button_ok
74
+            // 
75
+            this.button_ok.Location = new System.Drawing.Point(233, 174);
76
+            this.button_ok.Name = "button_ok";
77
+            this.button_ok.Size = new System.Drawing.Size(75, 31);
78
+            this.button_ok.TabIndex = 4;
79
+            this.button_ok.Text = "确 定";
80
+            this.button_ok.UseVisualStyleBackColor = true;
81
+            this.button_ok.Click += new System.EventHandler(this.button_ok_Click);
82
+            // 
83
+            // ModifyTFH
84
+            // 
85
+            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
86
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
87
+            this.ClientSize = new System.Drawing.Size(541, 228);
88
+            this.Controls.Add(this.button_ok);
89
+            this.Controls.Add(this.textBox_target);
90
+            this.Controls.Add(this.label2);
91
+            this.Controls.Add(this.comboBox_tfh);
92
+            this.Controls.Add(this.label1);
93
+            this.Name = "ModifyTFH";
94
+            this.Text = "图幅号修改";
95
+            this.Load += new System.EventHandler(this.ModifyTFH_Load);
96
+            this.ResumeLayout(false);
97
+            this.PerformLayout();
98
+
99
+        }
100
+
101
+        #endregion
102
+
103
+        private System.Windows.Forms.Label label1;
104
+        private System.Windows.Forms.ComboBox comboBox_tfh;
105
+        private System.Windows.Forms.Label label2;
106
+        private System.Windows.Forms.TextBox textBox_target;
107
+        private System.Windows.Forms.Button button_ok;
108
+    }
109
+}

+ 146
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/ModifyTFH.cs 查看文件

@@ -0,0 +1,146 @@
1
+using Autodesk.AutoCAD.ApplicationServices;
2
+using Autodesk.AutoCAD.DatabaseServices;
3
+using Autodesk.AutoCAD.EditorInput;
4
+using System;
5
+using System.Collections.Generic;
6
+using System.ComponentModel;
7
+using System.Data;
8
+using System.Drawing;
9
+using System.Linq;
10
+using System.Text;
11
+using System.Text.RegularExpressions;
12
+using System.Threading.Tasks;
13
+using System.Windows.Forms;
14
+
15
+namespace CADTools
16
+{
17
+    public partial class ModifyTFH : Form
18
+    {
19
+        public ModifyTFH()
20
+        {
21
+            InitializeComponent();
22
+        }
23
+
24
+        private void ModifyTFH_Load(object sender, EventArgs e)
25
+        {
26
+            //自动填充下拉框
27
+            Database database = Autodesk.AutoCAD.DatabaseServices.HostApplicationServices.WorkingDatabase;
28
+            using (Transaction traction = database.TransactionManager.StartTransaction())
29
+            {
30
+                //存放所有图层名
31
+                List<string> alllayername = new List<string>();
32
+                LayerTable layertable = traction.GetObject(database.LayerTableId, OpenMode.ForRead) as LayerTable;
33
+                foreach (ObjectId objid in layertable)
34
+                {
35
+                    LayerTableRecord layertablerecord = traction.GetObject(objid, OpenMode.ForRead) as LayerTableRecord;
36
+                    alllayername.Add(layertablerecord.Name);
37
+                }
38
+
39
+                alllayername.Sort();
40
+                for (int i = 0; i < alllayername.Count; i++)
41
+                {
42
+                    this.comboBox_tfh.Items.Add(alllayername[i]);
43
+                }
44
+                if (alllayername.Contains("TFH"))
45
+                {
46
+                    int index = alllayername.IndexOf("TFH");
47
+                    this.comboBox_tfh.SelectedIndex = index;
48
+                }
49
+                traction.Commit();
50
+            }
51
+        }
52
+
53
+        private void button_ok_Click(object sender, EventArgs e)
54
+        {
55
+            if(comboBox_tfh.Text.ToString().Trim()=="")
56
+            {
57
+                MessageBox.Show("图幅号所在图层不能为空!");
58
+                return;
59
+            }
60
+            if (textBox_target.Text.ToString().Trim() == "")
61
+            {
62
+                MessageBox.Show("目标格式不能为空!");
63
+                return;
64
+            }
65
+            ReplaceTFH(comboBox_tfh.Text.ToString(), textBox_target.Text);
66
+            this.Close();
67
+        }
68
+
69
+        private void ReplaceTFH(string lyr,string targetfh)
70
+        {
71
+            Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
72
+            Database db = Autodesk.AutoCAD.DatabaseServices.HostApplicationServices.WorkingDatabase;
73
+
74
+            //获取图幅号
75
+            TypedValue[] typedvalue = new TypedValue[2];
76
+            typedvalue.SetValue(new TypedValue((int)DxfCode.LayerName, lyr), 0);
77
+            typedvalue.SetValue(new TypedValue((int)DxfCode.Start, "TEXT"), 1);
78
+            SelectionFilter selectionfilter = new SelectionFilter(typedvalue);
79
+            PromptSelectionResult psr = ed.SelectAll(selectionfilter);
80
+            if (psr.Status != PromptStatus.Error)
81
+            {
82
+                SelectionSet selectionset = psr.Value;
83
+                ObjectId[] ids = selectionset.GetObjectIds();
84
+                List<DBText> tfh_old = new List<DBText>();
85
+                for (int i = 0; i < ids.Count(); i++)
86
+                {
87
+                    DocumentLock doclock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
88
+                    using (Transaction tr = db.TransactionManager.StartTransaction())
89
+                    {
90
+                        DBText text = tr.GetObject(ids[i], OpenMode.ForWrite) as DBText;
91
+                        tfh_old.Add(text);
92
+                        tr.Commit();
93
+                    }
94
+                    doclock.Dispose();
95
+                }
96
+                //将图幅号按从上到下,从左到右的顺序排序
97
+                var tfh_sorted = tfh_old.OrderByDescending(x => x.Position.Y)
98
+                                        .ThenBy(x=> x.Position.X).ToList();
99
+                //遍历排序后图幅号list,并按顺序替换递增的序号
100
+                for (int i = 0; i < tfh_sorted.Count; i++)
101
+                {
102
+                    DocumentLock doclock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
103
+                    using (Transaction tr = db.TransactionManager.StartTransaction())
104
+                    {
105
+                        DBText text = tr.GetObject(tfh_sorted[i].ObjectId, OpenMode.ForWrite) as DBText;
106
+                        if (i == 0)
107
+                        {
108
+                            text.TextString = targetfh;
109
+                            tr.Commit();
110
+                            continue;
111
+                        }
112
+                        targetfh = IncrementNumber(targetfh);
113
+                        text.TextString = targetfh;
114
+                        tr.Commit();
115
+                    }
116
+                    doclock.Dispose();
117
+                }
118
+                MessageBox.Show("修改完成");
119
+            }
120
+        }
121
+
122
+        //递增规则
123
+        private static string IncrementNumber(string input, int increment = 1)
124
+        {
125
+            // 找到字符串中的最后一个数字序列
126
+            MatchCollection matches = Regex.Matches(input, @"\d+");
127
+
128
+            if (matches.Count > 0)
129
+            {
130
+                Match lastMatch = matches[matches.Count - 1];
131
+                string prefix = input.Substring(0, lastMatch.Index);
132
+                string suffix = input.Substring(lastMatch.Index + lastMatch.Length);
133
+
134
+                if (int.TryParse(lastMatch.Value, out int number))
135
+                {
136
+                    int newNumber = number + increment;
137
+                    string newNumberStr = newNumber.ToString().PadLeft(lastMatch.Value.Length, '0');
138
+
139
+                    return prefix + newNumberStr + suffix;
140
+                }
141
+            }
142
+
143
+            return input + "1";
144
+        }
145
+    }
146
+}

+ 120
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/ModifyTFH.resx 查看文件

@@ -0,0 +1,120 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<root>
3
+  <!-- 
4
+    Microsoft ResX Schema 
5
+    
6
+    Version 2.0
7
+    
8
+    The primary goals of this format is to allow a simple XML format 
9
+    that is mostly human readable. The generation and parsing of the 
10
+    various data types are done through the TypeConverter classes 
11
+    associated with the data types.
12
+    
13
+    Example:
14
+    
15
+    ... ado.net/XML headers & schema ...
16
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
17
+    <resheader name="version">2.0</resheader>
18
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
19
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
20
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
21
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
22
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
24
+    </data>
25
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
26
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
27
+        <comment>This is a comment</comment>
28
+    </data>
29
+                
30
+    There are any number of "resheader" rows that contain simple 
31
+    name/value pairs.
32
+    
33
+    Each data row contains a name, and value. The row also contains a 
34
+    type or mimetype. Type corresponds to a .NET class that support 
35
+    text/value conversion through the TypeConverter architecture. 
36
+    Classes that don't support this are serialized and stored with the 
37
+    mimetype set.
38
+    
39
+    The mimetype is used for serialized objects, and tells the 
40
+    ResXResourceReader how to depersist the object. This is currently not 
41
+    extensible. For a given mimetype the value must be set accordingly:
42
+    
43
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
44
+    that the ResXResourceWriter will generate, however the reader can 
45
+    read any of the formats listed below.
46
+    
47
+    mimetype: application/x-microsoft.net.object.binary.base64
48
+    value   : The object must be serialized with 
49
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
50
+            : and then encoded with base64 encoding.
51
+    
52
+    mimetype: application/x-microsoft.net.object.soap.base64
53
+    value   : The object must be serialized with 
54
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
55
+            : and then encoded with base64 encoding.
56
+
57
+    mimetype: application/x-microsoft.net.object.bytearray.base64
58
+    value   : The object must be serialized into a byte array 
59
+            : using a System.ComponentModel.TypeConverter
60
+            : and then encoded with base64 encoding.
61
+    -->
62
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
64
+    <xsd:element name="root" msdata:IsDataSet="true">
65
+      <xsd:complexType>
66
+        <xsd:choice maxOccurs="unbounded">
67
+          <xsd:element name="metadata">
68
+            <xsd:complexType>
69
+              <xsd:sequence>
70
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
71
+              </xsd:sequence>
72
+              <xsd:attribute name="name" use="required" type="xsd:string" />
73
+              <xsd:attribute name="type" type="xsd:string" />
74
+              <xsd:attribute name="mimetype" type="xsd:string" />
75
+              <xsd:attribute ref="xml:space" />
76
+            </xsd:complexType>
77
+          </xsd:element>
78
+          <xsd:element name="assembly">
79
+            <xsd:complexType>
80
+              <xsd:attribute name="alias" type="xsd:string" />
81
+              <xsd:attribute name="name" type="xsd:string" />
82
+            </xsd:complexType>
83
+          </xsd:element>
84
+          <xsd:element name="data">
85
+            <xsd:complexType>
86
+              <xsd:sequence>
87
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
88
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
89
+              </xsd:sequence>
90
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
91
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
92
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
93
+              <xsd:attribute ref="xml:space" />
94
+            </xsd:complexType>
95
+          </xsd:element>
96
+          <xsd:element name="resheader">
97
+            <xsd:complexType>
98
+              <xsd:sequence>
99
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
100
+              </xsd:sequence>
101
+              <xsd:attribute name="name" type="xsd:string" use="required" />
102
+            </xsd:complexType>
103
+          </xsd:element>
104
+        </xsd:choice>
105
+      </xsd:complexType>
106
+    </xsd:element>
107
+  </xsd:schema>
108
+  <resheader name="resmimetype">
109
+    <value>text/microsoft-resx</value>
110
+  </resheader>
111
+  <resheader name="version">
112
+    <value>2.0</value>
113
+  </resheader>
114
+  <resheader name="reader">
115
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116
+  </resheader>
117
+  <resheader name="writer">
118
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119
+  </resheader>
120
+</root>

+ 186
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/PLError_Overlay.Designer.cs 查看文件

@@ -0,0 +1,186 @@
1
+
2
+namespace CADTools
3
+{
4
+    partial class PLError_Overlay
5
+    {
6
+        /// <summary>
7
+        /// Required designer variable.
8
+        /// </summary>
9
+        private System.ComponentModel.IContainer components = null;
10
+
11
+        /// <summary>
12
+        /// Clean up any resources being used.
13
+        /// </summary>
14
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
15
+        protected override void Dispose(bool disposing)
16
+        {
17
+            if (disposing && (components != null))
18
+            {
19
+                components.Dispose();
20
+            }
21
+            base.Dispose(disposing);
22
+        }
23
+
24
+        #region Windows Form Designer generated code
25
+
26
+        /// <summary>
27
+        /// Required method for Designer support - do not modify
28
+        /// the contents of this method with the code editor.
29
+        /// </summary>
30
+        private void InitializeComponent()
31
+        {
32
+            this.label_ElePoint = new System.Windows.Forms.Label();
33
+            this.comboBox_blc = new System.Windows.Forms.ComboBox();
34
+            this.label_Jqx = new System.Windows.Forms.Label();
35
+            this.label_Blc = new System.Windows.Forms.Label();
36
+            this.comboBox_ElePoint = new System.Windows.Forms.ComboBox();
37
+            this.comboBox_jqx = new System.Windows.Forms.ComboBox();
38
+            this.comboBox_sqx = new System.Windows.Forms.ComboBox();
39
+            this.label_Sqx = new System.Windows.Forms.Label();
40
+            this.btn_Cancel = new System.Windows.Forms.Button();
41
+            this.btn_OK = new System.Windows.Forms.Button();
42
+            this.SuspendLayout();
43
+            // 
44
+            // label_ElePoint
45
+            // 
46
+            this.label_ElePoint.AutoSize = true;
47
+            this.label_ElePoint.Location = new System.Drawing.Point(79, 36);
48
+            this.label_ElePoint.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
49
+            this.label_ElePoint.Name = "label_ElePoint";
50
+            this.label_ElePoint.Size = new System.Drawing.Size(150, 15);
51
+            this.label_ElePoint.TabIndex = 52;
52
+            this.label_ElePoint.Text = "高程点所在图层选择:";
53
+            // 
54
+            // comboBox_blc
55
+            // 
56
+            this.comboBox_blc.FormattingEnabled = true;
57
+            this.comboBox_blc.Items.AddRange(new object[] {
58
+            "1:500",
59
+            "1:1000",
60
+            "1:2000",
61
+            "1:5000"});
62
+            this.comboBox_blc.Location = new System.Drawing.Point(248, 201);
63
+            this.comboBox_blc.Margin = new System.Windows.Forms.Padding(4);
64
+            this.comboBox_blc.Name = "comboBox_blc";
65
+            this.comboBox_blc.Size = new System.Drawing.Size(161, 23);
66
+            this.comboBox_blc.TabIndex = 59;
67
+            // 
68
+            // label_Jqx
69
+            // 
70
+            this.label_Jqx.AutoSize = true;
71
+            this.label_Jqx.Location = new System.Drawing.Point(79, 151);
72
+            this.label_Jqx.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
73
+            this.label_Jqx.Name = "label_Jqx";
74
+            this.label_Jqx.Size = new System.Drawing.Size(150, 15);
75
+            this.label_Jqx.TabIndex = 56;
76
+            this.label_Jqx.Text = "计曲线所在图层选择:";
77
+            // 
78
+            // label_Blc
79
+            // 
80
+            this.label_Blc.AutoSize = true;
81
+            this.label_Blc.Location = new System.Drawing.Point(79, 204);
82
+            this.label_Blc.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
83
+            this.label_Blc.Name = "label_Blc";
84
+            this.label_Blc.Size = new System.Drawing.Size(90, 15);
85
+            this.label_Blc.TabIndex = 58;
86
+            this.label_Blc.Text = "比例尺选择:";
87
+            // 
88
+            // comboBox_ElePoint
89
+            // 
90
+            this.comboBox_ElePoint.FormattingEnabled = true;
91
+            this.comboBox_ElePoint.Location = new System.Drawing.Point(248, 33);
92
+            this.comboBox_ElePoint.Margin = new System.Windows.Forms.Padding(4);
93
+            this.comboBox_ElePoint.MaxDropDownItems = 30;
94
+            this.comboBox_ElePoint.Name = "comboBox_ElePoint";
95
+            this.comboBox_ElePoint.Size = new System.Drawing.Size(161, 23);
96
+            this.comboBox_ElePoint.TabIndex = 53;
97
+            // 
98
+            // comboBox_jqx
99
+            // 
100
+            this.comboBox_jqx.FormattingEnabled = true;
101
+            this.comboBox_jqx.Location = new System.Drawing.Point(248, 143);
102
+            this.comboBox_jqx.Margin = new System.Windows.Forms.Padding(4);
103
+            this.comboBox_jqx.MaxDropDownItems = 30;
104
+            this.comboBox_jqx.Name = "comboBox_jqx";
105
+            this.comboBox_jqx.Size = new System.Drawing.Size(161, 23);
106
+            this.comboBox_jqx.TabIndex = 57;
107
+            // 
108
+            // comboBox_sqx
109
+            // 
110
+            this.comboBox_sqx.FormattingEnabled = true;
111
+            this.comboBox_sqx.Location = new System.Drawing.Point(248, 86);
112
+            this.comboBox_sqx.Margin = new System.Windows.Forms.Padding(4);
113
+            this.comboBox_sqx.MaxDropDownItems = 30;
114
+            this.comboBox_sqx.Name = "comboBox_sqx";
115
+            this.comboBox_sqx.Size = new System.Drawing.Size(161, 23);
116
+            this.comboBox_sqx.TabIndex = 55;
117
+            // 
118
+            // label_Sqx
119
+            // 
120
+            this.label_Sqx.AutoSize = true;
121
+            this.label_Sqx.Location = new System.Drawing.Point(79, 94);
122
+            this.label_Sqx.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
123
+            this.label_Sqx.Name = "label_Sqx";
124
+            this.label_Sqx.Size = new System.Drawing.Size(150, 15);
125
+            this.label_Sqx.TabIndex = 54;
126
+            this.label_Sqx.Text = "首曲线所在图层选择:";
127
+            // 
128
+            // btn_Cancel
129
+            // 
130
+            this.btn_Cancel.Location = new System.Drawing.Point(291, 257);
131
+            this.btn_Cancel.Margin = new System.Windows.Forms.Padding(4);
132
+            this.btn_Cancel.Name = "btn_Cancel";
133
+            this.btn_Cancel.Size = new System.Drawing.Size(100, 29);
134
+            this.btn_Cancel.TabIndex = 61;
135
+            this.btn_Cancel.Text = "取 消";
136
+            this.btn_Cancel.UseVisualStyleBackColor = true;
137
+            this.btn_Cancel.Click += new System.EventHandler(this.btn_Cancel_Click);
138
+            // 
139
+            // btn_OK
140
+            // 
141
+            this.btn_OK.Location = new System.Drawing.Point(140, 256);
142
+            this.btn_OK.Margin = new System.Windows.Forms.Padding(4);
143
+            this.btn_OK.Name = "btn_OK";
144
+            this.btn_OK.Size = new System.Drawing.Size(100, 29);
145
+            this.btn_OK.TabIndex = 60;
146
+            this.btn_OK.Text = "确 定";
147
+            this.btn_OK.UseVisualStyleBackColor = true;
148
+            this.btn_OK.Click += new System.EventHandler(this.btn_OK_Click);
149
+            // 
150
+            // PLError_Overlay
151
+            // 
152
+            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
153
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
154
+            this.ClientSize = new System.Drawing.Size(512, 316);
155
+            this.Controls.Add(this.btn_Cancel);
156
+            this.Controls.Add(this.btn_OK);
157
+            this.Controls.Add(this.label_ElePoint);
158
+            this.Controls.Add(this.comboBox_blc);
159
+            this.Controls.Add(this.label_Jqx);
160
+            this.Controls.Add(this.label_Blc);
161
+            this.Controls.Add(this.comboBox_ElePoint);
162
+            this.Controls.Add(this.comboBox_jqx);
163
+            this.Controls.Add(this.comboBox_sqx);
164
+            this.Controls.Add(this.label_Sqx);
165
+            this.Name = "PLError_Overlay";
166
+            this.Text = "点线矛盾检查";
167
+            this.Load += new System.EventHandler(this.PLError_Load);
168
+            this.ResumeLayout(false);
169
+            this.PerformLayout();
170
+
171
+        }
172
+
173
+        #endregion
174
+
175
+        private System.Windows.Forms.Label label_ElePoint;
176
+        private System.Windows.Forms.ComboBox comboBox_blc;
177
+        private System.Windows.Forms.Label label_Jqx;
178
+        private System.Windows.Forms.Label label_Blc;
179
+        private System.Windows.Forms.ComboBox comboBox_ElePoint;
180
+        private System.Windows.Forms.ComboBox comboBox_jqx;
181
+        private System.Windows.Forms.ComboBox comboBox_sqx;
182
+        private System.Windows.Forms.Label label_Sqx;
183
+        private System.Windows.Forms.Button btn_Cancel;
184
+        private System.Windows.Forms.Button btn_OK;
185
+    }
186
+}

+ 177
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/PLError_Overlay.cs 查看文件

@@ -0,0 +1,177 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.ComponentModel;
4
+using System.Data;
5
+using System.Drawing;
6
+using System.Linq;
7
+using System.Text;
8
+using System.Threading.Tasks;
9
+using System.Windows.Forms;
10
+using Autodesk.AutoCAD.EditorInput;
11
+using Autodesk.AutoCAD.DatabaseServices;
12
+using Autodesk.AutoCAD.Geometry;
13
+
14
+namespace CADTools
15
+{
16
+    public partial class PLError_Overlay : Form
17
+    {
18
+        public PLError_Overlay()
19
+        {
20
+            InitializeComponent();
21
+        }
22
+
23
+        private void PLError_Load(object sender, EventArgs e)
24
+        {
25
+            //if (MainClass.Flag == "PLError" )
26
+            //{
27
+            //    this.Text = "点线矛盾";
28
+            //}
29
+            if (MainClass.Flag == "PLOverlap")
30
+            {
31
+                this.Text = "点线重叠";
32
+            }
33
+            this.comboBox_ElePoint.DropDownStyle = ComboBoxStyle.DropDownList;
34
+            this.comboBox_blc.DropDownStyle = ComboBoxStyle.DropDownList;
35
+            this.comboBox_sqx.DropDownStyle = ComboBoxStyle.DropDownList;
36
+            this.comboBox_jqx.DropDownStyle = ComboBoxStyle.DropDownList;
37
+
38
+            //this.MaximizeBox = false;
39
+            //this.StartPosition = FormStartPosition.CenterScreen;
40
+
41
+
42
+            //参数清零
43
+            //CheckPLOverlay.EleLayerName = null;
44
+            //CheckPLOverlay.sqx = null;
45
+            //CheckPLOverlay.jqx = null;
46
+            //CheckPLOverlay.blc = 0;
47
+
48
+
49
+            //自动填充下拉框
50
+            Database database = Autodesk.AutoCAD.DatabaseServices.HostApplicationServices.WorkingDatabase;
51
+            using (Transaction traction = database.TransactionManager.StartTransaction())
52
+            {
53
+                //存放所有图层名
54
+                List<string> alllayername = new List<string>();
55
+                LayerTable layertable = traction.GetObject(database.LayerTableId, OpenMode.ForRead) as LayerTable;
56
+                foreach (ObjectId objid in layertable)
57
+                {
58
+                    LayerTableRecord layertablerecord = traction.GetObject(objid, OpenMode.ForRead) as LayerTableRecord;
59
+                    alllayername.Add(layertablerecord.Name);
60
+                }
61
+                alllayername.Sort();
62
+
63
+                for (int i = 0; i < alllayername.Count; i++)
64
+                {
65
+                    this.comboBox_ElePoint.Items.Add(alllayername[i]);
66
+                    this.comboBox_sqx.Items.Add(alllayername[i]);
67
+                    this.comboBox_jqx.Items.Add(alllayername[i]);
68
+                }
69
+
70
+                if (alllayername.Contains("8300"))
71
+                {
72
+                    int index = alllayername.IndexOf("8300");
73
+                    this.comboBox_ElePoint.SelectedIndex = index;
74
+                }
75
+                if (alllayername.Contains("8110"))
76
+                {
77
+                    int index = alllayername.IndexOf("8110");
78
+                    this.comboBox_sqx.SelectedIndex = index;
79
+                }
80
+                if (alllayername.Contains("8120"))
81
+                {
82
+                    int index = alllayername.IndexOf("8120");
83
+                    this.comboBox_jqx.SelectedIndex = index;
84
+                }
85
+                traction.Commit();
86
+            }
87
+        }
88
+
89
+        private void btn_OK_Click(object sender, EventArgs e)
90
+        {
91
+            if (MainClass.Flag == "PLOverlap")
92
+            {
93
+                if (comboBox_ElePoint.Text == "")
94
+                {
95
+                    Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("请选择高程点图层");
96
+                    return;
97
+                }
98
+                if (comboBox_blc.Text == "")
99
+                {
100
+                    Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("请选择比例尺");
101
+                    return;
102
+                }
103
+                if (comboBox_sqx.Text == "")
104
+                {
105
+                    Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("请选择首曲线图层");
106
+                    return;
107
+                }
108
+                if (comboBox_jqx.Text == "")
109
+                {
110
+                    Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("请选择计曲线图层");
111
+                    return;
112
+                }
113
+
114
+                CheckPLOverlay.EleLayerName = comboBox_ElePoint.Text;
115
+                CheckPLOverlay.sqx = comboBox_sqx.Text;
116
+                CheckPLOverlay.jqx = comboBox_jqx.Text;
117
+
118
+                //比例尺
119
+                string blctext = comboBox_blc.Text;
120
+                int blcindex = blctext.LastIndexOf(':');
121
+                string strblc = blctext.Substring(blcindex + 1);
122
+                CheckPLOverlay.blc = Convert.ToInt32(strblc);
123
+
124
+                this.Close();
125
+                CheckPLOverlay plcon = new CheckPLOverlay();
126
+                plcon.contourch();
127
+            }
128
+
129
+            //if (MainClass.Flag == "PLError")
130
+            //{
131
+
132
+            //    if (comboBox_ElePoint.Text == "")
133
+            //    {
134
+            //        Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("请选择高程点图层");
135
+            //        return;
136
+            //    }
137
+            //    if (comboBox_blc.Text == "")
138
+            //    {
139
+            //        Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("请选择比例尺");
140
+            //        return;
141
+            //    }
142
+            //    if (comboBox_sqx.Text == "")
143
+            //    {
144
+            //        Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("请选择首曲线图层");
145
+            //        return;
146
+            //    }
147
+            //    if (comboBox_jqx.Text == "")
148
+            //    {
149
+            //        Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("请选择计曲线图层");
150
+            //        return;
151
+            //    }
152
+
153
+            //    ChPLContradiction1.elevationLayer = comboBox_ElePoint.Text;
154
+            //    ChPLContradiction1.sqx = comboBox_sqx.Text;
155
+            //    ChPLContradiction1.jqx = comboBox_jqx.Text;
156
+
157
+
158
+            //    //比例尺
159
+            //    string blctext = comboBox_blc.Text;
160
+            //    int blcindex = blctext.LastIndexOf(':');
161
+            //    string strblc = blctext.Substring(blcindex + 1);
162
+            //    int rade = Convert.ToInt32(strblc);
163
+            //    ChPLContradiction1.blc = rade;
164
+
165
+            //    this.Close();
166
+            //    //ChPLContradiction chplc = new ChPLContradiction();
167
+            //    ChPLContradiction1 chplc = new ChPLContradiction1();
168
+            //    chplc.Check();
169
+            //}
170
+        }
171
+
172
+        private void btn_Cancel_Click(object sender, EventArgs e)
173
+        {
174
+            this.Close();
175
+        }
176
+    }
177
+}

+ 120
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/PLError_Overlay.resx 查看文件

@@ -0,0 +1,120 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<root>
3
+  <!-- 
4
+    Microsoft ResX Schema 
5
+    
6
+    Version 2.0
7
+    
8
+    The primary goals of this format is to allow a simple XML format 
9
+    that is mostly human readable. The generation and parsing of the 
10
+    various data types are done through the TypeConverter classes 
11
+    associated with the data types.
12
+    
13
+    Example:
14
+    
15
+    ... ado.net/XML headers & schema ...
16
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
17
+    <resheader name="version">2.0</resheader>
18
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
19
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
20
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
21
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
22
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
24
+    </data>
25
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
26
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
27
+        <comment>This is a comment</comment>
28
+    </data>
29
+                
30
+    There are any number of "resheader" rows that contain simple 
31
+    name/value pairs.
32
+    
33
+    Each data row contains a name, and value. The row also contains a 
34
+    type or mimetype. Type corresponds to a .NET class that support 
35
+    text/value conversion through the TypeConverter architecture. 
36
+    Classes that don't support this are serialized and stored with the 
37
+    mimetype set.
38
+    
39
+    The mimetype is used for serialized objects, and tells the 
40
+    ResXResourceReader how to depersist the object. This is currently not 
41
+    extensible. For a given mimetype the value must be set accordingly:
42
+    
43
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
44
+    that the ResXResourceWriter will generate, however the reader can 
45
+    read any of the formats listed below.
46
+    
47
+    mimetype: application/x-microsoft.net.object.binary.base64
48
+    value   : The object must be serialized with 
49
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
50
+            : and then encoded with base64 encoding.
51
+    
52
+    mimetype: application/x-microsoft.net.object.soap.base64
53
+    value   : The object must be serialized with 
54
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
55
+            : and then encoded with base64 encoding.
56
+
57
+    mimetype: application/x-microsoft.net.object.bytearray.base64
58
+    value   : The object must be serialized into a byte array 
59
+            : using a System.ComponentModel.TypeConverter
60
+            : and then encoded with base64 encoding.
61
+    -->
62
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
64
+    <xsd:element name="root" msdata:IsDataSet="true">
65
+      <xsd:complexType>
66
+        <xsd:choice maxOccurs="unbounded">
67
+          <xsd:element name="metadata">
68
+            <xsd:complexType>
69
+              <xsd:sequence>
70
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
71
+              </xsd:sequence>
72
+              <xsd:attribute name="name" use="required" type="xsd:string" />
73
+              <xsd:attribute name="type" type="xsd:string" />
74
+              <xsd:attribute name="mimetype" type="xsd:string" />
75
+              <xsd:attribute ref="xml:space" />
76
+            </xsd:complexType>
77
+          </xsd:element>
78
+          <xsd:element name="assembly">
79
+            <xsd:complexType>
80
+              <xsd:attribute name="alias" type="xsd:string" />
81
+              <xsd:attribute name="name" type="xsd:string" />
82
+            </xsd:complexType>
83
+          </xsd:element>
84
+          <xsd:element name="data">
85
+            <xsd:complexType>
86
+              <xsd:sequence>
87
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
88
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
89
+              </xsd:sequence>
90
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
91
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
92
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
93
+              <xsd:attribute ref="xml:space" />
94
+            </xsd:complexType>
95
+          </xsd:element>
96
+          <xsd:element name="resheader">
97
+            <xsd:complexType>
98
+              <xsd:sequence>
99
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
100
+              </xsd:sequence>
101
+              <xsd:attribute name="name" type="xsd:string" use="required" />
102
+            </xsd:complexType>
103
+          </xsd:element>
104
+        </xsd:choice>
105
+      </xsd:complexType>
106
+    </xsd:element>
107
+  </xsd:schema>
108
+  <resheader name="resmimetype">
109
+    <value>text/microsoft-resx</value>
110
+  </resheader>
111
+  <resheader name="version">
112
+    <value>2.0</value>
113
+  </resheader>
114
+  <resheader name="reader">
115
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116
+  </resheader>
117
+  <resheader name="writer">
118
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119
+  </resheader>
120
+</root>

+ 114
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/PicPts.Designer.cs 查看文件

@@ -0,0 +1,114 @@
1
+
2
+namespace CADTools
3
+{
4
+    partial class PicPts
5
+    {
6
+        /// <summary>
7
+        /// Required designer variable.
8
+        /// </summary>
9
+        private System.ComponentModel.IContainer components = null;
10
+
11
+        /// <summary>
12
+        /// Clean up any resources being used.
13
+        /// </summary>
14
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
15
+        protected override void Dispose(bool disposing)
16
+        {
17
+            if (disposing && (components != null))
18
+            {
19
+                components.Dispose();
20
+            }
21
+            base.Dispose(disposing);
22
+        }
23
+
24
+        #region Windows Form Designer generated code
25
+
26
+        /// <summary>
27
+        /// Required method for Designer support - do not modify
28
+        /// the contents of this method with the code editor.
29
+        /// </summary>
30
+        private void InitializeComponent()
31
+        {
32
+            this.label_Decimal = new System.Windows.Forms.Label();
33
+            this.comboBox_Decimal = new System.Windows.Forms.ComboBox();
34
+            this.btn_Cancel = new System.Windows.Forms.Button();
35
+            this.btn_OK = new System.Windows.Forms.Button();
36
+            this.SuspendLayout();
37
+            // 
38
+            // label_Decimal
39
+            // 
40
+            this.label_Decimal.AutoSize = true;
41
+            this.label_Decimal.Location = new System.Drawing.Point(91, 54);
42
+            this.label_Decimal.Margin = new System.Windows.Forms.Padding(4, 0, 4, 0);
43
+            this.label_Decimal.Name = "label_Decimal";
44
+            this.label_Decimal.Size = new System.Drawing.Size(142, 15);
45
+            this.label_Decimal.TabIndex = 32;
46
+            this.label_Decimal.Text = "坐标保留的小数位数";
47
+            // 
48
+            // comboBox_Decimal
49
+            // 
50
+            this.comboBox_Decimal.FormattingEnabled = true;
51
+            this.comboBox_Decimal.Items.AddRange(new object[] {
52
+            "0",
53
+            "1",
54
+            "2",
55
+            "3",
56
+            "4",
57
+            "5",
58
+            "6",
59
+            "7",
60
+            "8",
61
+            "9"});
62
+            this.comboBox_Decimal.Location = new System.Drawing.Point(250, 51);
63
+            this.comboBox_Decimal.Margin = new System.Windows.Forms.Padding(4);
64
+            this.comboBox_Decimal.Name = "comboBox_Decimal";
65
+            this.comboBox_Decimal.Size = new System.Drawing.Size(124, 23);
66
+            this.comboBox_Decimal.TabIndex = 31;
67
+            // 
68
+            // btn_Cancel
69
+            // 
70
+            this.btn_Cancel.Location = new System.Drawing.Point(265, 113);
71
+            this.btn_Cancel.Margin = new System.Windows.Forms.Padding(4);
72
+            this.btn_Cancel.Name = "btn_Cancel";
73
+            this.btn_Cancel.Size = new System.Drawing.Size(100, 29);
74
+            this.btn_Cancel.TabIndex = 34;
75
+            this.btn_Cancel.Text = "取 消";
76
+            this.btn_Cancel.UseVisualStyleBackColor = true;
77
+            this.btn_Cancel.Click += new System.EventHandler(this.btn_Cancel_Click);
78
+            // 
79
+            // btn_OK
80
+            // 
81
+            this.btn_OK.Location = new System.Drawing.Point(114, 112);
82
+            this.btn_OK.Margin = new System.Windows.Forms.Padding(4);
83
+            this.btn_OK.Name = "btn_OK";
84
+            this.btn_OK.Size = new System.Drawing.Size(100, 29);
85
+            this.btn_OK.TabIndex = 33;
86
+            this.btn_OK.Text = "确 定";
87
+            this.btn_OK.UseVisualStyleBackColor = true;
88
+            this.btn_OK.Click += new System.EventHandler(this.btn_OK_Click);
89
+            // 
90
+            // PicPts
91
+            // 
92
+            this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 15F);
93
+            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
94
+            this.ClientSize = new System.Drawing.Size(465, 190);
95
+            this.Controls.Add(this.btn_Cancel);
96
+            this.Controls.Add(this.btn_OK);
97
+            this.Controls.Add(this.label_Decimal);
98
+            this.Controls.Add(this.comboBox_Decimal);
99
+            this.Name = "PicPts";
100
+            this.Text = "节点提取";
101
+            this.Load += new System.EventHandler(this.PicPts_Load);
102
+            this.ResumeLayout(false);
103
+            this.PerformLayout();
104
+
105
+        }
106
+
107
+        #endregion
108
+
109
+        private System.Windows.Forms.Label label_Decimal;
110
+        private System.Windows.Forms.ComboBox comboBox_Decimal;
111
+        private System.Windows.Forms.Button btn_Cancel;
112
+        private System.Windows.Forms.Button btn_OK;
113
+    }
114
+}

+ 43
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/PicPts.cs 查看文件

@@ -0,0 +1,43 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.ComponentModel;
4
+using System.Data;
5
+using System.Drawing;
6
+using System.Linq;
7
+using System.Text;
8
+using System.Threading.Tasks;
9
+using System.Windows.Forms;
10
+
11
+namespace CADTools
12
+{
13
+    public partial class PicPts : Form
14
+    {
15
+        public PicPts()
16
+        {
17
+            InitializeComponent();
18
+        }
19
+
20
+        private void btn_OK_Click(object sender, EventArgs e)
21
+        {
22
+            if (string.IsNullOrEmpty(comboBox_Decimal.Text) == true)
23
+            {
24
+                Autodesk.AutoCAD.ApplicationServices.Application.ShowAlertDialog("请选择小数位数!");
25
+                return;
26
+            }
27
+            PickupPoint pickuppt = new PickupPoint();
28
+            string num = comboBox_Decimal.SelectedText;
29
+            this.Close();
30
+            pickuppt.PickupPt(num);
31
+        }
32
+
33
+        private void PicPts_Load(object sender, EventArgs e)
34
+        {
35
+            this.comboBox_Decimal.DropDownStyle = ComboBoxStyle.DropDownList;
36
+        }
37
+
38
+        private void btn_Cancel_Click(object sender, EventArgs e)
39
+        {
40
+            this.Close();
41
+        }
42
+    }
43
+}

+ 120
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/PicPts.resx 查看文件

@@ -0,0 +1,120 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<root>
3
+  <!-- 
4
+    Microsoft ResX Schema 
5
+    
6
+    Version 2.0
7
+    
8
+    The primary goals of this format is to allow a simple XML format 
9
+    that is mostly human readable. The generation and parsing of the 
10
+    various data types are done through the TypeConverter classes 
11
+    associated with the data types.
12
+    
13
+    Example:
14
+    
15
+    ... ado.net/XML headers & schema ...
16
+    <resheader name="resmimetype">text/microsoft-resx</resheader>
17
+    <resheader name="version">2.0</resheader>
18
+    <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
19
+    <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
20
+    <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
21
+    <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
22
+    <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
23
+        <value>[base64 mime encoded serialized .NET Framework object]</value>
24
+    </data>
25
+    <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
26
+        <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
27
+        <comment>This is a comment</comment>
28
+    </data>
29
+                
30
+    There are any number of "resheader" rows that contain simple 
31
+    name/value pairs.
32
+    
33
+    Each data row contains a name, and value. The row also contains a 
34
+    type or mimetype. Type corresponds to a .NET class that support 
35
+    text/value conversion through the TypeConverter architecture. 
36
+    Classes that don't support this are serialized and stored with the 
37
+    mimetype set.
38
+    
39
+    The mimetype is used for serialized objects, and tells the 
40
+    ResXResourceReader how to depersist the object. This is currently not 
41
+    extensible. For a given mimetype the value must be set accordingly:
42
+    
43
+    Note - application/x-microsoft.net.object.binary.base64 is the format 
44
+    that the ResXResourceWriter will generate, however the reader can 
45
+    read any of the formats listed below.
46
+    
47
+    mimetype: application/x-microsoft.net.object.binary.base64
48
+    value   : The object must be serialized with 
49
+            : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
50
+            : and then encoded with base64 encoding.
51
+    
52
+    mimetype: application/x-microsoft.net.object.soap.base64
53
+    value   : The object must be serialized with 
54
+            : System.Runtime.Serialization.Formatters.Soap.SoapFormatter
55
+            : and then encoded with base64 encoding.
56
+
57
+    mimetype: application/x-microsoft.net.object.bytearray.base64
58
+    value   : The object must be serialized into a byte array 
59
+            : using a System.ComponentModel.TypeConverter
60
+            : and then encoded with base64 encoding.
61
+    -->
62
+  <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
63
+    <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
64
+    <xsd:element name="root" msdata:IsDataSet="true">
65
+      <xsd:complexType>
66
+        <xsd:choice maxOccurs="unbounded">
67
+          <xsd:element name="metadata">
68
+            <xsd:complexType>
69
+              <xsd:sequence>
70
+                <xsd:element name="value" type="xsd:string" minOccurs="0" />
71
+              </xsd:sequence>
72
+              <xsd:attribute name="name" use="required" type="xsd:string" />
73
+              <xsd:attribute name="type" type="xsd:string" />
74
+              <xsd:attribute name="mimetype" type="xsd:string" />
75
+              <xsd:attribute ref="xml:space" />
76
+            </xsd:complexType>
77
+          </xsd:element>
78
+          <xsd:element name="assembly">
79
+            <xsd:complexType>
80
+              <xsd:attribute name="alias" type="xsd:string" />
81
+              <xsd:attribute name="name" type="xsd:string" />
82
+            </xsd:complexType>
83
+          </xsd:element>
84
+          <xsd:element name="data">
85
+            <xsd:complexType>
86
+              <xsd:sequence>
87
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
88
+                <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
89
+              </xsd:sequence>
90
+              <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
91
+              <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
92
+              <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
93
+              <xsd:attribute ref="xml:space" />
94
+            </xsd:complexType>
95
+          </xsd:element>
96
+          <xsd:element name="resheader">
97
+            <xsd:complexType>
98
+              <xsd:sequence>
99
+                <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
100
+              </xsd:sequence>
101
+              <xsd:attribute name="name" type="xsd:string" use="required" />
102
+            </xsd:complexType>
103
+          </xsd:element>
104
+        </xsd:choice>
105
+      </xsd:complexType>
106
+    </xsd:element>
107
+  </xsd:schema>
108
+  <resheader name="resmimetype">
109
+    <value>text/microsoft-resx</value>
110
+  </resheader>
111
+  <resheader name="version">
112
+    <value>2.0</value>
113
+  </resheader>
114
+  <resheader name="reader">
115
+    <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
116
+  </resheader>
117
+  <resheader name="writer">
118
+    <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
119
+  </resheader>
120
+</root>

+ 174
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/PickupPoint.cs 查看文件

@@ -0,0 +1,174 @@
1
+using System;
2
+using System.Collections.Generic;
3
+using System.Linq;
4
+using System.Text;
5
+using System.Threading.Tasks;
6
+
7
+using Autodesk.AutoCAD.ApplicationServices;
8
+using Autodesk.AutoCAD.DatabaseServices;
9
+using Autodesk.AutoCAD.EditorInput;
10
+using Autodesk.AutoCAD.Geometry;
11
+using System.Windows.Forms;
12
+using System.IO;
13
+
14
+namespace CADTools
15
+{
16
+    class PickupPoint
17
+    {
18
+        public void PickupPt(string num)
19
+        {
20
+            Document document = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
21
+            Database db = HostApplicationServices.WorkingDatabase;
22
+
23
+            Editor ed = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.Editor;
24
+
25
+            TypedValue[] value = new TypedValue[]
26
+            {
27
+                new TypedValue((int)DxfCode.Start,"LWPOLYLINE,POLYLINE")
28
+            };//设置筛选条件
29
+            SelectionFilter filter = new SelectionFilter(value);
30
+
31
+            //选择区域中全部对象
32
+            //PromptSelectionResult psr = ed.SelectAll(filter);
33
+            // 要求在图形区域中手动选择对象
34
+            PromptSelectionResult psr = ed.GetSelection(filter);
35
+            SelectionSet selectionset = psr.Value;
36
+
37
+            if (psr.Status == PromptStatus.OK)
38
+            {
39
+                ObjectId[] obj = new ObjectId[selectionset.Count];
40
+                obj = selectionset.GetObjectIds();
41
+                List<Point3d> AllPoints = new List<Point3d>();
42
+                List<string> FinalPoints = new List<string>();
43
+                string decimalnum = "F" + num;
44
+                string ele = " ";
45
+
46
+                for (int i = 0; i < obj.Length; i++)
47
+                {
48
+                    DocumentLock documentlock = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.LockDocument();
49
+                    using (Transaction trans = db.TransactionManager.StartTransaction())
50
+                    {
51
+                        Point3dCollection coll = new Point3dCollection();
52
+                        ObjectId objid = obj[i];
53
+                        Entity entity = (Entity)trans.GetObject(objid, OpenMode.ForWrite);
54
+
55
+                        if (entity is Polyline)
56
+                        {
57
+                            Polyline line = entity as Polyline;
58
+                            //line.GetStretchPoints(coll);
59
+                            int vertexNum = line.NumberOfVertices;
60
+                            Point3d point;
61
+                            // 遍历获取多段线顶点坐标
62
+                            for (int ii = 0; ii < vertexNum; ii++)
63
+                            {
64
+                                point = line.GetPoint3dAt(ii);
65
+                                coll.Add(point);
66
+                            }
67
+                            ele = line.Elevation.ToString();
68
+                        }
69
+                        else if (entity is Polyline2d)
70
+                        {
71
+                            Polyline2d line = entity as Polyline2d;
72
+                            //line.GetStretchPoints(coll);
73
+                            foreach (ObjectId id in line)
74
+                            {
75
+                                Vertex2d vx = (Vertex2d)trans.GetObject(id, OpenMode.ForRead);
76
+                                if (vx.VertexType != Vertex2dType.SplineControlVertex)
77
+                                {
78
+                                    coll.Add(vx.Position);
79
+                                }
80
+                            }
81
+                            ele = line.Elevation.ToString();
82
+                        }
83
+                        else if(entity is Polyline3d)
84
+                        {
85
+                            Polyline3d line = entity as Polyline3d;
86
+                            foreach (ObjectId id in line)
87
+                            {
88
+                                PolylineVertex3d vx3d = (PolylineVertex3d)trans.GetObject(id,
89
+                                    OpenMode.ForRead);
90
+                                coll.Add(vx3d.Position);
91
+                            }
92
+                            ele = "三维多段线";
93
+                        }
94
+
95
+                        #region//无用
96
+                        ////检查选择的多段线是否有重复点,如果有就移除
97
+                        //for (int ii = 0; ii < coll.Count - 1; ii++)
98
+                        //{
99
+                        //    for (int iii = ii + 1; iii < ii + 21; iii++)
100
+                        //    {
101
+                        //        if (iii == coll.Count + 1)
102
+                        //            break;
103
+
104
+                        //        string x1 = coll[ii].X.ToString(decimalnum);
105
+                        //        string y1 = coll[ii].Y.ToString(decimalnum);
106
+
107
+                        //        string x2 = coll[iii].X.ToString(decimalnum);
108
+                        //        string y2 = coll[iii].Y.ToString(decimalnum);
109
+
110
+                        //        if (x1 == x2 && y1 == y2)
111
+                        //        {
112
+                        //            coll.RemoveAt(iii);
113
+                        //        }
114
+                        //        else
115
+                        //        {
116
+                        //            continue;
117
+                        //        }
118
+                        //    }
119
+                        //}
120
+                        #endregion
121
+
122
+                        for (int j = 0; j < coll.Count; j++)
123
+                        {
124
+                            AllPoints.Add(coll[j]);
125
+                        }
126
+                        trans.Commit();
127
+                    }
128
+                    documentlock.Dispose();
129
+
130
+                    for (int ii = 0; ii < AllPoints.Count; ii++)
131
+                    {
132
+                        if (ii == 0)
133
+                            FinalPoints.Add(ele);
134
+                        string x = AllPoints[ii].X.ToString(decimalnum);
135
+                        string y = AllPoints[ii].Y.ToString(decimalnum);
136
+                        string z = AllPoints[ii].Z.ToString(decimalnum);
137
+                        string res = string.Join(" ", new string[] { x, y, z });
138
+                        FinalPoints.Add(res);
139
+                    }
140
+                    AllPoints.Clear();
141
+                }
142
+                //保存文件对话框
143
+                System.Windows.Forms.SaveFileDialog save = new System.Windows.Forms.SaveFileDialog();
144
+                save.Filter = "文本文件(*.txt)|*.txt";
145
+                //FolderBrowserDialog dialog = new FolderBrowserDialog();
146
+                //dialog.Description = "请选择文件路径";
147
+                //保存文件是否记录上一次文件目录
148
+                save.RestoreDirectory = true;
149
+                if (save.ShowDialog() == DialogResult.OK)
150
+                {
151
+                    string savePath = save.FileName;
152
+                    File.WriteAllLines(savePath, FinalPoints, Encoding.UTF8);
153
+                    ed.WriteMessage("保存成功\n");
154
+                }
155
+                else
156
+                {
157
+                    MessageBox.Show("保存失败\n");
158
+                }
159
+                //if (dialog.ShowDialog() == DialogResult.OK)
160
+                //{
161
+                //    string foldPath = dialog.SelectedPath;
162
+                //    string savePath = foldPath + "\\" + ele + ".txt";
163
+                //    File.WriteAllLines(savePath, FinalPoints, Encoding.UTF8);
164
+                //    ed.WriteMessage("\n保存成功");
165
+                //}
166
+            }
167
+            else
168
+            {
169
+                ed.WriteMessage("\n多段线选择失败");
170
+            }
171
+            
172
+        }
173
+    }
174
+}

+ 36
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/Properties/AssemblyInfo.cs 查看文件

@@ -0,0 +1,36 @@
1
+using System.Reflection;
2
+using System.Runtime.CompilerServices;
3
+using System.Runtime.InteropServices;
4
+
5
+// 有关程序集的一般信息由以下
6
+// 控制。更改这些特性值可修改
7
+// 与程序集关联的信息。
8
+[assembly: AssemblyTitle("CADTools")]
9
+[assembly: AssemblyDescription("")]
10
+[assembly: AssemblyConfiguration("")]
11
+[assembly: AssemblyCompany("")]
12
+[assembly: AssemblyProduct("CADTools")]
13
+[assembly: AssemblyCopyright("Copyright ©  2026")]
14
+[assembly: AssemblyTrademark("")]
15
+[assembly: AssemblyCulture("")]
16
+
17
+// 将 ComVisible 设置为 false 会使此程序集中的类型
18
+//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型
19
+//请将此类型的 ComVisible 特性设置为 true。
20
+[assembly: ComVisible(false)]
21
+
22
+// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23
+[assembly: Guid("3ea75ae9-d4b2-415a-8646-756159376fff")]
24
+
25
+// 程序集的版本信息由下列四个值组成: 
26
+//
27
+//      主版本
28
+//      次版本
29
+//      生成号
30
+//      修订号
31
+//
32
+//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值
33
+//通过使用 "*",如下所示:
34
+// [assembly: AssemblyVersion("1.0.*")]
35
+[assembly: AssemblyVersion("1.0.0.0")]
36
+[assembly: AssemblyFileVersion("1.0.0.0")]

+ 0
- 0
加密后软件工具/CAD插件工具/Autocad源代码/CADTools/CADTools/Properties/Resources.Designer.cs 查看文件


部分文件因为文件数量过多而无法显示

正在加载...
取消
保存