├── .gitignore
├── LICENSE
├── README.md
├── Source
├── Geo7.App
│ ├── Geo7.AutoCAD.csproj
│ ├── Geo7.BricsCAD.csproj
│ ├── Geo7.ZwCAD.csproj
│ ├── Geo7App.cs
│ ├── Properties
│ │ ├── AssemblyInfo.cs
│ │ ├── Resources.Designer.cs
│ │ └── Resources.resx
│ ├── Resources
│ │ ├── ConvertDgnTxt.png
│ │ ├── Export.png
│ │ ├── ExportTxt.png
│ │ ├── Import.png
│ │ ├── Orto.png
│ │ ├── Slope.png
│ │ ├── comment_add.png
│ │ ├── delete-objects.png
│ │ ├── delete.png
│ │ ├── deselect-all.png
│ │ ├── find-next.png
│ │ ├── find-prev.png
│ │ ├── find-text.png
│ │ ├── find.png
│ │ ├── information.png
│ │ ├── key.png
│ │ ├── quick-select.png
│ │ ├── select-all.png
│ │ ├── select-object.png
│ │ ├── select-rect.png
│ │ └── warning.png
│ ├── Specific.AutoCAD
│ │ ├── AcControllers.cs
│ │ ├── Geo7App.AutoCAD.cs
│ │ ├── PackageContents.xml
│ │ └── RibbonUtils.cs
│ ├── Specific.BricsCAD
│ │ └── Geo7App.BricsCAD.cs
│ ├── Tools
│ │ ├── BlockExpText
│ │ │ ├── BlockExpTextCommand.cs
│ │ │ ├── BlockExpTextPresenter.cs
│ │ │ ├── BlockExpTextWindow.xaml
│ │ │ └── BlockExpTextWindow.xaml.cs
│ │ ├── BlockFind
│ │ │ ├── BlockFindCommand.cs
│ │ │ ├── BlockFindPage.xaml
│ │ │ ├── BlockFindPage.xaml.cs
│ │ │ └── BlockFindPresenter.cs
│ │ ├── BlockImpText
│ │ │ ├── BlockImpTextCommand.cs
│ │ │ ├── BlockImpTextPresenter.cs
│ │ │ ├── BlockImpTextWindow.xaml
│ │ │ └── BlockImpTextWindow.xaml.cs
│ │ ├── BlockInsert
│ │ │ └── BlockInsertCommand.cs
│ │ ├── BlockSelect
│ │ │ ├── BlockSelectPresenter.cs
│ │ │ ├── BlockSelectWindow.xaml
│ │ │ └── BlockSelectWindow.xaml.cs
│ │ ├── BlockSettigns
│ │ │ ├── BlockSettingsCommand.cs
│ │ │ ├── BlockSettingsPresenter.cs
│ │ │ ├── BlockSettingsWindow.xaml
│ │ │ └── BlockSettingsWindow.xaml.cs
│ │ ├── ConvertDgnTexts
│ │ │ └── ConvertDgnTextsCommand.cs
│ │ ├── OrthoDist
│ │ │ ├── OrthoDistCommand.cs
│ │ │ └── OrtoCommand.cs
│ │ ├── PtsLnDist
│ │ │ └── PtsLnDistCommand.cs
│ │ ├── Slope
│ │ │ └── SlopeCommand.cs
│ │ └── TextExpText
│ │ │ └── ExportTextsCommand.cs
│ ├── cui
│ │ ├── Benchmark.png
│ │ ├── ControlPoint.png
│ │ ├── ConvertDgnTxt.png
│ │ ├── CrossPoint.png
│ │ ├── ElevationPoint.png
│ │ ├── ExportTxt.png
│ │ ├── FixedPoint.png
│ │ ├── Geo7.cui
│ │ ├── MarkPoint.png
│ │ ├── MeasuredPoint.png
│ │ ├── OrthoDist.png
│ │ ├── Orto.png
│ │ ├── Slope.png
│ │ └── SquarePoint.png
│ └── dwg
│ │ └── Geo7.dwg
├── Geo7.Shared
│ ├── Ac.cs
│ ├── AcCommand.cs
│ ├── AcTransaction.cs
│ ├── Classes
│ │ └── ObjectIds.cs
│ ├── Entities
│ │ ├── AcAttribute.cs
│ │ ├── AcBlock.cs
│ │ ├── AcCurve.cs
│ │ ├── AcEntity.cs
│ │ ├── AcExtensions.cs
│ │ ├── AcLine.cs
│ │ ├── AcPolyline.cs
│ │ └── AcText.cs
│ ├── Geo7.Shared.projitems
│ ├── Geo7.Shared.shproj
│ └── Utils
│ │ ├── DwgDb.cs
│ │ ├── Polygons.cs
│ │ └── RemoveDuplicates.cs
├── Geo7.sln
└── Install
│ └── Geo7.iss
└── release-info.md
/.gitignore:
--------------------------------------------------------------------------------
1 | ## Ignore Visual Studio temporary files, build results, and
2 | ## files generated by popular Visual Studio add-ons.
3 |
4 | # User-specific files
5 | *.suo
6 | *.user
7 | *.sln.docstates
8 |
9 | # Build results
10 | [Dd]ebug/
11 | [Dd]ebugPublic/
12 | [Rr]elease/
13 | [Rr]eleases/
14 | x64/
15 | x86/
16 | build/
17 | bld/
18 | [Bb]in/
19 | [Oo]bj/
20 |
21 | # Roslyn cache directories
22 | *.ide/
23 |
24 | # MSTest test Results
25 | [Tt]est[Rr]esult*/
26 | [Bb]uild[Ll]og.*
27 |
28 | #NUNIT
29 | *.VisualState.xml
30 | TestResult.xml
31 |
32 | # Build Results of an ATL Project
33 | [Dd]ebugPS/
34 | [Rr]eleasePS/
35 | dlldata.c
36 |
37 | *_i.c
38 | *_p.c
39 | *_i.h
40 | *.ilk
41 | *.meta
42 | *.obj
43 | *.pch
44 | *.pdb
45 | *.pgc
46 | *.pgd
47 | *.rsp
48 | *.sbr
49 | *.tlb
50 | *.tli
51 | *.tlh
52 | *.tmp
53 | *.tmp_proj
54 | *.log
55 | *.vspscc
56 | *.vssscc
57 | .builds
58 | *.pidb
59 | *.svclog
60 | *.scc
61 |
62 | # Chutzpah Test files
63 | _Chutzpah*
64 |
65 | # Visual C++ cache files
66 | ipch/
67 | *.aps
68 | *.ncb
69 | *.opensdf
70 | *.sdf
71 | *.cachefile
72 |
73 | # Visual Studio profiler
74 | *.psess
75 | *.vsp
76 | *.vspx
77 |
78 | # TFS 2012 Local Workspace
79 | $tf/
80 |
81 | # Guidance Automation Toolkit
82 | *.gpState
83 |
84 | # ReSharper is a .NET coding add-in
85 | _ReSharper*/
86 | *.[Rr]e[Ss]harper
87 | *.DotSettings.user
88 |
89 | # JustCode is a .NET coding addin-in
90 | .JustCode
91 |
92 | # TeamCity is a build add-in
93 | _TeamCity*
94 |
95 | # DotCover is a Code Coverage Tool
96 | *.dotCover
97 |
98 | # NCrunch
99 | _NCrunch_*
100 | .*crunch*.local.xml
101 |
102 | # MightyMoose
103 | *.mm.*
104 | AutoTest.Net/
105 |
106 | # Web workbench (sass)
107 | .sass-cache/
108 |
109 | # Installshield output folder
110 | [Ee]xpress/
111 |
112 | # DocProject is a documentation generator add-in
113 | DocProject/buildhelp/
114 | DocProject/Help/*.HxT
115 | DocProject/Help/*.HxC
116 | DocProject/Help/*.hhc
117 | DocProject/Help/*.hhk
118 | DocProject/Help/*.hhp
119 | DocProject/Help/Html2
120 | DocProject/Help/html
121 |
122 | # Click-Once directory
123 | publish/
124 |
125 | # Publish Web Output
126 | *.[Pp]ublish.xml
127 | *.azurePubxml
128 | # TODO: Comment the next line if you want to checkin your web deploy settings
129 | # but database connection strings (with potential passwords) will be unencrypted
130 | *.pubxml
131 | *.publishproj
132 |
133 | # NuGet Packages
134 | *.nupkg
135 | # The packages folder can be ignored because of Package Restore
136 | **/packages/*
137 | # except build/, which is used as an MSBuild target.
138 | !**/packages/build/
139 | # If using the old MSBuild-Integrated Package Restore, uncomment this:
140 | #!**/packages/repositories.config
141 |
142 | # Windows Azure Build Output
143 | csx/
144 | *.build.csdef
145 |
146 | # Windows Store app package directory
147 | AppPackages/
148 |
149 | # Others
150 | sql/
151 | *.Cache
152 | ClientBin/
153 | [Ss]tyle[Cc]op.*
154 | ~$*
155 | *~
156 | *.dbmdl
157 | *.dbproj.schemaview
158 | *.pfx
159 | *.publishsettings
160 | node_modules/
161 |
162 | # RIA/Silverlight projects
163 | Generated_Code/
164 |
165 | # Backup & report files from converting an old project file
166 | # to a newer Visual Studio version. Backup files are not needed,
167 | # because we have git ;-)
168 | _UpgradeReport_Files/
169 | Backup*/
170 | UpgradeLog*.XML
171 | UpgradeLog*.htm
172 |
173 | # SQL Server files
174 | *.mdf
175 | *.ldf
176 |
177 | # Business Intelligence projects
178 | *.rdl.data
179 | *.bim.layout
180 | *.bim_*.settings
181 |
182 | # Microsoft Fakes
183 | FakesAssemblies/
184 | /install
185 | /Source/Geo7.App/dwg/Geo7-pl.bak
186 | /Source/Geo7.App/dwg/Geo7.bak
187 | /Source/Geo7.App/dwg/Blocks
188 | /Source/Geo7.App/Resources/Svg
189 | /Source/Geo7.App/Resources/Points
190 | /Source/Geo7.App/Resources/Png16
191 | /Source/Geo7.App/Resources/Bmp
192 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2015 Kuba Szostak
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
23 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Geo7
2 | Tools for AutoCAD and BricsCAD
3 |
4 | ## Features
5 | * Import/export point coordinates (plain ASCII text, CSV, Tab delimited text, ...)
6 | * Find block by point ID/Number
7 | * Calculate slope between points
8 |
9 | 
10 |
11 | ---
12 | ### Downlad and install
13 | * [Download Geo7](https://github.com/kubaszostak/Geo7/releases)
14 | * [Run Geo7 at BricsCAD startup](https://github.com/kubaszostak/Geo7/issues/9)
15 |
16 | ---
17 | * [Wsparcie](http://geo7.userecho.com/)
18 | * [Nowości](http://geo7.userecho.com/topics/22-nowa-wersja-geo7/direction-down/)
19 |
--------------------------------------------------------------------------------
/Source/Geo7.App/Geo7.AutoCAD.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {E6D1502A-A0B6-4DE6-A875-CCB76C45E386}
8 | Library
9 | Properties
10 | Geo7
11 | Geo7.AutoCAD
12 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
13 | v4.0.3
14 | 512
15 |
16 |
17 | true
18 | full
19 | false
20 | ..\..\Bin\Geo7.AutoCAD.2013.bundle\
21 | TRACE;DEBUG;AutoCAD
22 | prompt
23 | 4
24 |
25 |
26 | pdbonly
27 | true
28 | bin\Release\
29 | TRACE
30 | prompt
31 | 4
32 |
33 |
34 |
35 | ..\..\..\Lib\Arx2013\AcCoreMgd.dll
36 | False
37 |
38 |
39 | ..\..\..\Lib\Arx2013\AcDbMgd.dll
40 | False
41 |
42 |
43 | ..\..\..\Lib\Arx2013\AcMgd.dll
44 | False
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 | BlockExpTextWindow.xaml
69 |
70 |
71 |
72 | BlockFindPage.xaml
73 |
74 |
75 |
76 |
77 |
78 | BlockImpTextWindow.xaml
79 |
80 |
81 |
82 |
83 | BlockSelectWindow.xaml
84 |
85 |
86 |
87 |
88 | BlockSettingsWindow.xaml
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 | PreserveNewest
100 |
101 |
102 | PreserveNewest
103 |
104 |
105 | PreserveNewest
106 |
107 |
108 | PreserveNewest
109 |
110 |
111 | PreserveNewest
112 |
113 |
114 | PreserveNewest
115 |
116 |
117 | PreserveNewest
118 |
119 |
120 | PreserveNewest
121 |
122 |
123 | PreserveNewest
124 |
125 |
126 | PreserveNewest
127 |
128 |
129 | PreserveNewest
130 |
131 |
132 | PreserveNewest
133 |
134 |
135 | PreserveNewest
136 |
137 |
138 |
139 |
140 | PreserveNewest
141 |
142 |
143 | PreserveNewest
144 |
145 |
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
169 |
170 |
171 | MSBuild:Compile
172 | Designer
173 |
174 |
175 | MSBuild:Compile
176 | Designer
177 |
178 |
179 | MSBuild:Compile
180 | Designer
181 |
182 |
183 | MSBuild:Compile
184 | Designer
185 |
186 |
187 | MSBuild:Compile
188 | Designer
189 |
190 |
191 |
192 |
193 | {90c02122-0e35-4068-b39f-86b3134eb703}
194 | KSz.App.Wpf
195 |
196 |
197 |
198 |
199 |
206 |
--------------------------------------------------------------------------------
/Source/Geo7.App/Geo7.BricsCAD.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {290809C6-7644-43EF-9F48-EFD3FBEC3A5C}
8 | Library
9 | Properties
10 | Geo7
11 | Geo7.BricsCAD
12 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
13 | v4.0
14 | 512
15 |
16 |
17 |
18 | true
19 | full
20 | false
21 | ..\..\Bin\BricsCAD_V15\Support\Geo7\
22 | TRACE;DEBUG;BricsCAD
23 | prompt
24 | 4
25 |
26 |
27 | pdbonly
28 | true
29 | ..\..\Bin\BricsCAD_V15\Support\Geo7\
30 | TRACE;BricsCAD
31 | prompt
32 | 4
33 |
34 |
35 |
36 | ..\..\..\Lib\Brx15\BrxMgd.dll
37 | False
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 | ..\..\..\Lib\Brx15\TD_Mgd.dll
53 | False
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 | True
63 | True
64 | Resources.resx
65 |
66 |
67 |
68 |
69 |
70 | BlockExpTextWindow.xaml
71 |
72 |
73 |
74 | BlockFindPage.xaml
75 |
76 |
77 |
78 |
79 | BlockImpTextWindow.xaml
80 |
81 |
82 |
83 |
84 | BlockSelectWindow.xaml
85 |
86 |
87 |
88 |
89 | BlockSettingsWindow.xaml
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 | ResXFileCodeGenerator
102 | Designer
103 | Resources.Designer.cs
104 |
105 |
106 |
107 |
108 |
109 | PreserveNewest
110 |
111 |
112 | PreserveNewest
113 |
114 |
115 | PreserveNewest
116 |
117 |
118 | PreserveNewest
119 |
120 |
121 | PreserveNewest
122 |
123 |
124 | PreserveNewest
125 |
126 |
127 | PreserveNewest
128 |
129 |
130 | PreserveNewest
131 |
132 |
133 | PreserveNewest
134 |
135 |
136 | PreserveNewest
137 |
138 |
139 | PreserveNewest
140 |
141 |
142 | PreserveNewest
143 |
144 |
145 | PreserveNewest
146 |
147 |
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 | PreserveNewest
169 |
170 |
171 | Always
172 |
173 |
174 |
175 |
176 | Designer
177 | MSBuild:Compile
178 |
179 |
180 |
181 |
182 | MSBuild:Compile
183 | Designer
184 |
185 |
186 | Designer
187 | MSBuild:Compile
188 |
189 |
190 | Designer
191 | MSBuild:Compile
192 |
193 |
194 | Designer
195 | MSBuild:Compile
196 |
197 |
198 |
199 |
200 | {90c02122-0e35-4068-b39f-86b3134eb703}
201 | KSz.App.Wpf
202 |
203 |
204 |
205 |
206 |
213 |
--------------------------------------------------------------------------------
/Source/Geo7.App/Geo7.ZwCAD.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {4C0E14BC-F7FC-4AC1-93FB-A829D64C7342}
8 | Library
9 | Properties
10 | Geo7
11 | Geo7.ZwCAD
12 | {60dc8134-eba5-43b8-bcc9-bb4bc16c2548};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
13 | v4.0.3
14 | 512
15 |
16 |
17 | true
18 | full
19 | false
20 | ..\..\Bin\ZwCAD\
21 | TRACE;DEBUG;ZwCAD
22 | prompt
23 | 4
24 |
25 |
26 | pdbonly
27 | true
28 | bin\Release\
29 | TRACE
30 | prompt
31 | 4
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
54 |
--------------------------------------------------------------------------------
/Source/Geo7.App/Geo7App.cs:
--------------------------------------------------------------------------------
1 | using Geo7.Tools;
2 | using System.Threading;
3 | using System;
4 | using System.Globalization;
5 | using System.Linq;
6 |
7 | #if AutoCAD
8 | using Autodesk.AutoCAD.Runtime;
9 | using Autodesk.AutoCAD.DatabaseServices;
10 | using Autodesk.AutoCAD.Geometry;
11 | using Autodesk.AutoCAD.Colors;
12 | using Autodesk.AutoCAD.ApplicationServices;
13 | using Autodesk.AutoCAD.Windows;
14 | using Autodesk.AutoCAD.EditorInput;
15 | #endif
16 |
17 | #if BricsCAD
18 | using Teigha.Runtime;
19 | using Teigha.DatabaseServices;
20 | using Teigha.Geometry;
21 | using Teigha.Colors;
22 | using Bricscad.ApplicationServices;
23 | using Bricscad.Windows;
24 | using Bricscad.EditorInput;
25 | #endif
26 |
27 |
28 |
29 | [assembly: ExtensionApplication(typeof(Geo7.Geo7App))]
30 | [assembly: CommandClass(typeof(Geo7.Geo7App))]
31 |
32 | namespace Geo7
33 | {
34 | partial class Geo7App : IExtensionApplication
35 | {
36 | public const string AppName = "Geo7";
37 | public const string WebSite = "https://github.com/kubaszostak/geo7";
38 | private static PaletteSet ToolsPalettes = null;
39 | private string cuiMenuGroupName = "Geo7";
40 |
41 | public void Initialize()
42 | {
43 | try
44 | {
45 | StartupCheck();
46 | AppServices.Log.Add("Initialize() ...");
47 | InternalInit();
48 | ShowRibbon();
49 | cuiMenuGroupName = Ac.LoadCUI(Geo7App.Geo7CUI);
50 | LoadNonStaticCUI();
51 | AppServices.Log.Add("Initialize(): Done.");
52 | Ac.WriteLn(AppName + " loaded.");
53 | }
54 | catch (System.Exception ex)
55 | {
56 | Ac.WriteError(ex, this.GetType().Name + ".Initialize()", null);
57 | }
58 | AppServices.Log.Add("Initialize(): Done.");
59 | }
60 |
61 |
62 | public void Terminate()
63 | {
64 | Ac.UnloadCUI(cuiMenuGroupName);
65 | AppServices.Log.Add("Terminate(): Application closed.");
66 | }
67 |
68 | public static string Geo7Dwg
69 | {
70 | get
71 | {
72 | if (Ac.IsPolish)
73 | return Ac.AssemblyPath + "\\Dwg\\Geo7.dwg";
74 | else
75 | return Ac.AssemblyPath + "\\Dwg\\Geo7.dwg";
76 | }
77 | }
78 | public static string Geo7CUI
79 | {
80 | get
81 | {
82 | if (Ac.IsPolish)
83 | return Ac.AssemblyPath + "\\cui\\Geo7.cui";
84 | else
85 | return Ac.AssemblyPath + "\\cui\\Geo7.cui";
86 | }
87 | }
88 |
89 |
90 | private void LoadNonStaticCUI()
91 | {
92 | //TODO: Non static CUI items (insert point)
93 | // http://forums.autodesk.com/t5/net/accessing-toolbars-and-buttons-programatically/td-p/3182594
94 | }
95 |
96 | partial void InternalInit();
97 | partial void ShowRibbon();
98 |
99 | public void StartupCheck()
100 | {
101 | AppServices.Log.NewSection();
102 | AppServices.Log.Add("Starting application: {0}, Version {1}...", Geo7App.AppName, Ac.AssemblyVersion.ToString());
103 | AppServices.Log.Add("CAD App Version: " + Ac.Version);
104 | AppServices.Log.Add("Geo7 binary path: " + Ac.AssemblyPath);
105 | AppServices.Log.AddLn();
106 |
107 | if (!System.IO.File.Exists(Geo7App.Geo7Dwg))
108 | {
109 | Ac.WriteError(SysUtils.Strings.FileNotFound, Geo7App.Geo7Dwg);
110 | }
111 |
112 | }
113 |
114 | private static string[] mDefPointBlockNames = null;
115 | public static string[] DefPointBlockNames
116 | {
117 | get
118 | {
119 | if (mDefPointBlockNames == null)
120 | mDefPointBlockNames = AcDwgDb.GetBlockNames(Geo7App.Geo7Dwg, true).OrderBy(n => n).ToArray();
121 |
122 | return mDefPointBlockNames;
123 | }
124 | }
125 |
126 | private void AddPalettes()
127 | {
128 | try
129 | {
130 | AppServices.Log.Add("AddPalettes()...");
131 | if (ToolsPalettes == null)
132 | {
133 | // use constructor with Guid so that we can save/load user data
134 | ToolsPalettes = new PaletteSet(AppName);
135 | ToolsPalettes.MinimumSize = new System.Drawing.Size(300, 300);
136 | //ToolsPalettes.Size = new System.Drawing.Size(300, 500);
137 | //ToolsPalettes.Style = PaletteSetStyles.ShowTabForSingle | PaletteSetStyles.ShowAutoHideButton | PaletteSetStyles.ShowCloseButton;
138 | ToolsPalettes.Visible = true;
139 | //ToolsPalettes.KeepFocus = true;
140 | //ToolsPalettes.Add("Tools", new ToolsPallete());
141 | //AddPalette(new ToolPalettes.BlocksPalette());
142 | //AddPalette(new ToolPalettes.PolygonsPalette());
143 | //AddPalette(new ToolPalettes.InfoPalette()); // Tą zawsze wczytaj, żeby można było wczytać licencje
144 | }
145 | AppServices.Log.Add("AddPalettes():Done.");
146 | }
147 | catch (System.Exception ex)
148 | {
149 | Ac.WriteLn("Geo7: Error showing Tools Palette");
150 | Ac.WriteError(ex, this.GetType().Name + ".AddPalettes()", null);
151 | }
152 | }
153 |
154 |
155 | [CommandMethod("G7Log")]
156 | public void ShowLogFile()
157 | {
158 | Ac.WriteLn("Opening " + AppServices.Log.LogFilePath + "...");
159 | System.Diagnostics.Process.Start(AppServices.Log.LogFilePath);
160 | }
161 |
162 |
163 | [CommandMethod("G7")]
164 | public void PrintInfo()
165 | {
166 | Ac.WriteLn(Geo7App.AppName);
167 | Ac.WriteLn("Version: " + Ac.AssemblyVersion.ToString());
168 | Ac.WriteLn("Geo7 binary path: " + Ac.AssemblyPath);
169 | Ac.WriteLn("Geo7 log file: " + AppServices.Log.LogFilePath);
170 |
171 | ShowRibbon();
172 | }
173 |
174 | [CommandMethod("G7Info")]
175 | public void InfoDialog()
176 | {
177 | string s = Geo7App.AppName;
178 | s += "\r\nVersion: " + Ac.AssemblyVersion;
179 | s += "\r\n\r\n" + Geo7App.WebSite;
180 |
181 | Ac.ShowMsg(s);
182 | }
183 |
184 | [CommandMethod("G7MakeSuggestion")]
185 | public void MakeSuggestion()
186 | {
187 | System.Diagnostics.Process.Start("http://geo7.userecho.com/");
188 | }
189 |
190 |
191 |
192 | [CommandMethod("G7CreatePolygons")]
193 | public void CreatePolygonsCommand()
194 | {
195 | DocumentLock docLock = Ac.Doc.LockDocument();
196 | AcPolygonsCreator.Run();
197 | docLock.Dispose();
198 | }
199 |
200 | [CommandMethod("G7TextPolygons")]
201 | public void JoinPolygonsWithTextCommand()
202 | {
203 | new AcJoinPolygonsWithTexts().Run();
204 | }
205 |
206 | [CommandMethod("G7ConvertDgnTexts")]
207 | public void ConvertDgnTexts()
208 | {
209 | new ConvertDgnTextsCommand().Execute();
210 | }
211 |
212 | [CommandMethod("G7LANG")]
213 | public static void WhichLanguage()
214 | {
215 | var cId = SystemObjects.DynamicLinker.ProductLcid;
216 | var cId2 = Ac.LocaleId;
217 | var cult = new CultureInfo(cId2);
218 | var ed = Ac.Editor;
219 | var ver = Ac.Version;
220 | Ac.WriteLn("\nLanguage of your AutoCAD product is {0}.",cult.EnglishName);
221 | Ac.WriteLn(Thread.CurrentThread.CurrentCulture.EnglishName);
222 | Ac.WriteLn(Thread.CurrentThread.CurrentUICulture.EnglishName);
223 | }
224 |
225 | [CommandMethod("G7ImportPoints" )]
226 | public static void BlockImport()
227 | {
228 | new BlockImpTextCommand().Execute();
229 | }
230 |
231 | [CommandMethod("G7ExportPoints")]
232 | public static void BlockExport()
233 | {
234 | new BlockExpTextCommand().Execute();
235 | }
236 |
237 | [CommandMethod("G7ExportTexts")]
238 | public static void ExportTexts()
239 | {
240 | new TextExpTextCommand().Execute();
241 | }
242 |
243 | [CommandMethod("G7PointSettings")]
244 | public static void BlockSettings()
245 | {
246 | new BlockSettingsCommand().Execute();
247 | }
248 |
249 | [CommandMethod("G7InsertPoint")]
250 | public static void InsertPoint()
251 | {
252 | new BlockInsertCommand(null).Execute();
253 | }
254 |
255 | [CommandMethod("G7Slope", CommandFlags.Modal)]
256 | public static void Slope()
257 | {
258 | new SlopeCommand().Execute();
259 | }
260 |
261 | [CommandMethod("G7OrthoDist", CommandFlags.Modal)]
262 | public static void OrthoDist()
263 | {
264 | new OrthoDistCommand().Execute();
265 | }
266 |
267 | [CommandMethod("G7PtsLnDist", CommandFlags.Modal)]
268 | public static void PtLnDist()
269 | {
270 | new PtsLnDistCommand().Execute();
271 | }
272 |
273 | [CommandMethod("G7BugTest", CommandFlags.Modal)]
274 | public static void BugTest()
275 | {
276 | }
277 |
278 |
279 | }
280 | }
281 |
--------------------------------------------------------------------------------
/Source/Geo7.App/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // General Information about an assembly is controlled through the following
6 | // set of attributes. Change these attribute values to modify the information
7 | // associated with an assembly.
8 | [assembly: AssemblyTitle("Geo7")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("Geo7")]
13 | [assembly: AssemblyCopyright("Copyright © 2015 Kuba Szostak")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | // Setting ComVisible to false makes the types in this assembly not visible
18 | // to COM components. If you need to access a type in this assembly from
19 | // COM, set the ComVisible attribute to true on that type.
20 | [assembly: ComVisible(false)]
21 |
22 | // The following GUID is for the ID of the typelib if this project is exposed to COM
23 | [assembly: Guid("290809c6-7644-43ef-9f48-efd3fbec3a5c")]
24 |
25 | // Version information for an assembly consists of the following four values:
26 | //
27 | // Major Version
28 | // Minor Version
29 | // Build Number
30 | // Revision
31 | //
32 | // You can specify all the values or you can default the Build and Revision Numbers
33 | // by using the '*' as shown below:
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("3.0.*")]
36 | //[assembly: AssemblyFileVersion("3.0.*")]
37 |
--------------------------------------------------------------------------------
/Source/Geo7.App/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace Geo7.Properties {
12 | using System;
13 |
14 |
15 | ///
16 | /// A strongly-typed resource class, for looking up localized strings, etc.
17 | ///
18 | // This class was auto-generated by the StronglyTypedResourceBuilder
19 | // class via a tool like ResGen or Visual Studio.
20 | // To add or remove a member, edit your .ResX file then rerun ResGen
21 | // with the /str option, or rebuild your VS project.
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources {
26 |
27 | private static global::System.Resources.ResourceManager resourceMan;
28 |
29 | private static global::System.Globalization.CultureInfo resourceCulture;
30 |
31 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32 | internal Resources() {
33 | }
34 |
35 | ///
36 | /// Returns the cached ResourceManager instance used by this class.
37 | ///
38 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
39 | internal static global::System.Resources.ResourceManager ResourceManager {
40 | get {
41 | if (object.ReferenceEquals(resourceMan, null)) {
42 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Geo7.Properties.Resources", typeof(Resources).Assembly);
43 | resourceMan = temp;
44 | }
45 | return resourceMan;
46 | }
47 | }
48 |
49 | ///
50 | /// Overrides the current thread's CurrentUICulture property for all
51 | /// resource lookups using this strongly typed resource class.
52 | ///
53 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
54 | internal static global::System.Globalization.CultureInfo Culture {
55 | get {
56 | return resourceCulture;
57 | }
58 | set {
59 | resourceCulture = value;
60 | }
61 | }
62 |
63 | ///
64 | /// Looks up a localized resource of type System.Drawing.Bitmap.
65 | ///
66 | internal static System.Drawing.Bitmap ConvertDgnTxt {
67 | get {
68 | object obj = ResourceManager.GetObject("ConvertDgnTxt", resourceCulture);
69 | return ((System.Drawing.Bitmap)(obj));
70 | }
71 | }
72 |
73 | ///
74 | /// Looks up a localized resource of type System.Drawing.Bitmap.
75 | ///
76 | internal static System.Drawing.Bitmap Delete {
77 | get {
78 | object obj = ResourceManager.GetObject("Delete", resourceCulture);
79 | return ((System.Drawing.Bitmap)(obj));
80 | }
81 | }
82 |
83 | ///
84 | /// Looks up a localized resource of type System.Drawing.Bitmap.
85 | ///
86 | internal static System.Drawing.Bitmap DeleteObjects {
87 | get {
88 | object obj = ResourceManager.GetObject("DeleteObjects", resourceCulture);
89 | return ((System.Drawing.Bitmap)(obj));
90 | }
91 | }
92 |
93 | ///
94 | /// Looks up a localized resource of type System.Drawing.Bitmap.
95 | ///
96 | internal static System.Drawing.Bitmap Export {
97 | get {
98 | object obj = ResourceManager.GetObject("Export", resourceCulture);
99 | return ((System.Drawing.Bitmap)(obj));
100 | }
101 | }
102 |
103 | ///
104 | /// Looks up a localized resource of type System.Drawing.Bitmap.
105 | ///
106 | internal static System.Drawing.Bitmap Orto {
107 | get {
108 | object obj = ResourceManager.GetObject("Orto", resourceCulture);
109 | return ((System.Drawing.Bitmap)(obj));
110 | }
111 | }
112 | }
113 | }
114 |
--------------------------------------------------------------------------------
/Source/Geo7.App/Properties/Resources.resx:
--------------------------------------------------------------------------------
1 |
2 |
3 |
62 |
63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
87 |
88 |
89 |
90 |
91 |
92 |
93 |
94 |
95 |
96 |
97 |
98 |
99 |
100 |
101 |
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | text/microsoft-resx
110 |
111 |
112 | 2.0
113 |
114 |
115 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
118 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
119 |
120 |
121 |
122 | ..\Resources\ConvertDgnTxt.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
123 |
124 |
125 | ..\Resources\delete.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
126 |
127 |
128 | ..\Resources\delete-objects.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
129 |
130 |
131 | ..\Resources\Export.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
132 |
133 |
134 | ..\Resources\Orto.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
135 |
136 |
--------------------------------------------------------------------------------
/Source/Geo7.App/Resources/ConvertDgnTxt.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KubaSzostak/Geo7/f6e4f6f7913b8ec59c5f8151397e6c3a6e9e2d0f/Source/Geo7.App/Resources/ConvertDgnTxt.png
--------------------------------------------------------------------------------
/Source/Geo7.App/Resources/Export.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KubaSzostak/Geo7/f6e4f6f7913b8ec59c5f8151397e6c3a6e9e2d0f/Source/Geo7.App/Resources/Export.png
--------------------------------------------------------------------------------
/Source/Geo7.App/Resources/ExportTxt.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KubaSzostak/Geo7/f6e4f6f7913b8ec59c5f8151397e6c3a6e9e2d0f/Source/Geo7.App/Resources/ExportTxt.png
--------------------------------------------------------------------------------
/Source/Geo7.App/Resources/Import.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KubaSzostak/Geo7/f6e4f6f7913b8ec59c5f8151397e6c3a6e9e2d0f/Source/Geo7.App/Resources/Import.png
--------------------------------------------------------------------------------
/Source/Geo7.App/Resources/Orto.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KubaSzostak/Geo7/f6e4f6f7913b8ec59c5f8151397e6c3a6e9e2d0f/Source/Geo7.App/Resources/Orto.png
--------------------------------------------------------------------------------
/Source/Geo7.App/Resources/Slope.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KubaSzostak/Geo7/f6e4f6f7913b8ec59c5f8151397e6c3a6e9e2d0f/Source/Geo7.App/Resources/Slope.png
--------------------------------------------------------------------------------
/Source/Geo7.App/Resources/comment_add.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KubaSzostak/Geo7/f6e4f6f7913b8ec59c5f8151397e6c3a6e9e2d0f/Source/Geo7.App/Resources/comment_add.png
--------------------------------------------------------------------------------
/Source/Geo7.App/Resources/delete-objects.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KubaSzostak/Geo7/f6e4f6f7913b8ec59c5f8151397e6c3a6e9e2d0f/Source/Geo7.App/Resources/delete-objects.png
--------------------------------------------------------------------------------
/Source/Geo7.App/Resources/delete.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KubaSzostak/Geo7/f6e4f6f7913b8ec59c5f8151397e6c3a6e9e2d0f/Source/Geo7.App/Resources/delete.png
--------------------------------------------------------------------------------
/Source/Geo7.App/Resources/deselect-all.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KubaSzostak/Geo7/f6e4f6f7913b8ec59c5f8151397e6c3a6e9e2d0f/Source/Geo7.App/Resources/deselect-all.png
--------------------------------------------------------------------------------
/Source/Geo7.App/Resources/find-next.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KubaSzostak/Geo7/f6e4f6f7913b8ec59c5f8151397e6c3a6e9e2d0f/Source/Geo7.App/Resources/find-next.png
--------------------------------------------------------------------------------
/Source/Geo7.App/Resources/find-prev.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KubaSzostak/Geo7/f6e4f6f7913b8ec59c5f8151397e6c3a6e9e2d0f/Source/Geo7.App/Resources/find-prev.png
--------------------------------------------------------------------------------
/Source/Geo7.App/Resources/find-text.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KubaSzostak/Geo7/f6e4f6f7913b8ec59c5f8151397e6c3a6e9e2d0f/Source/Geo7.App/Resources/find-text.png
--------------------------------------------------------------------------------
/Source/Geo7.App/Resources/find.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KubaSzostak/Geo7/f6e4f6f7913b8ec59c5f8151397e6c3a6e9e2d0f/Source/Geo7.App/Resources/find.png
--------------------------------------------------------------------------------
/Source/Geo7.App/Resources/information.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KubaSzostak/Geo7/f6e4f6f7913b8ec59c5f8151397e6c3a6e9e2d0f/Source/Geo7.App/Resources/information.png
--------------------------------------------------------------------------------
/Source/Geo7.App/Resources/key.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KubaSzostak/Geo7/f6e4f6f7913b8ec59c5f8151397e6c3a6e9e2d0f/Source/Geo7.App/Resources/key.png
--------------------------------------------------------------------------------
/Source/Geo7.App/Resources/quick-select.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KubaSzostak/Geo7/f6e4f6f7913b8ec59c5f8151397e6c3a6e9e2d0f/Source/Geo7.App/Resources/quick-select.png
--------------------------------------------------------------------------------
/Source/Geo7.App/Resources/select-all.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KubaSzostak/Geo7/f6e4f6f7913b8ec59c5f8151397e6c3a6e9e2d0f/Source/Geo7.App/Resources/select-all.png
--------------------------------------------------------------------------------
/Source/Geo7.App/Resources/select-object.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KubaSzostak/Geo7/f6e4f6f7913b8ec59c5f8151397e6c3a6e9e2d0f/Source/Geo7.App/Resources/select-object.png
--------------------------------------------------------------------------------
/Source/Geo7.App/Resources/select-rect.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KubaSzostak/Geo7/f6e4f6f7913b8ec59c5f8151397e6c3a6e9e2d0f/Source/Geo7.App/Resources/select-rect.png
--------------------------------------------------------------------------------
/Source/Geo7.App/Resources/warning.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KubaSzostak/Geo7/f6e4f6f7913b8ec59c5f8151397e6c3a6e9e2d0f/Source/Geo7.App/Resources/warning.png
--------------------------------------------------------------------------------
/Source/Geo7.App/Specific.AutoCAD/AcControllers.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Windows.Media;
6 | using System.Windows.Interop;
7 | using System.Windows;
8 | using System.Windows.Media.Imaging;
9 | using System.Drawing;
10 |
11 |
12 | #if AutoCAD
13 | using Autodesk.AutoCAD.Runtime;
14 | using Autodesk.AutoCAD.DatabaseServices;
15 | using Autodesk.AutoCAD.Geometry;
16 | using Autodesk.AutoCAD.Colors;
17 | using Autodesk.AutoCAD.ApplicationServices;
18 | using Autodesk.AutoCAD.Windows;
19 | using Autodesk.AutoCAD.EditorInput;
20 |
21 | using AcApp = Autodesk.AutoCAD.ApplicationServices.Application;
22 | #endif
23 |
24 | #if BricsCAD
25 | using Teigha.Runtime;
26 | using Teigha.DatabaseServices;
27 | using Teigha.Geometry;
28 | using Teigha.Colors;
29 | using Bricscad.ApplicationServices;
30 | using Bricscad.Windows;
31 | using Bricscad.EditorInput;
32 |
33 | using AcApp = Bricscad.ApplicationServices.Application;
34 | #endif
35 |
36 | namespace Geo7.Controllers
37 | {
38 | public class AcControllers
39 | {
40 |
41 | AcControllers()
42 | {
43 |
44 | }
45 |
46 |
47 | public static ImageSource GetImageSource(System.Drawing.Image img)
48 | {
49 |
50 | System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(img);
51 | using (bmp)
52 | {
53 | return Imaging.CreateBitmapSourceFromHBitmap(bmp.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions());
54 | }
55 | }
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/Source/Geo7.App/Specific.AutoCAD/Geo7App.AutoCAD.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace Geo7
7 | {
8 | partial class Geo7ToolsApp
9 | {
10 | partial void InternalInit()
11 | {
12 | AppLog.Add("Initialize(): Ribbon.RibbonUtils.Init()...");
13 | RibbonUtils.Init();
14 | }
15 | partial void ShowRibbon()
16 | {
17 | RibbonUtils.ShowGeo7Ribbon();
18 | }
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/Source/Geo7.App/Specific.AutoCAD/PackageContents.xml:
--------------------------------------------------------------------------------
1 |
2 |
8 |
9 |
10 |
11 |
16 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Source/Geo7.App/Specific.BricsCAD/Geo7App.BricsCAD.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace Geo7.Specific.BricsCAD
7 | {
8 | class BricsCAD
9 | {
10 | }
11 | }
12 |
--------------------------------------------------------------------------------
/Source/Geo7.App/Tools/BlockExpText/BlockExpTextCommand.cs:
--------------------------------------------------------------------------------
1 |
2 |
3 | using System;
4 | using System.Collections.Generic;
5 | using System.IO;
6 | using System.Linq;
7 | using System.Text;
8 | using System.Windows.Forms;
9 | using Geo7.Windows;
10 |
11 | namespace Geo7.Tools
12 | {
13 |
14 | public class BlockExpTextCommand : AcCommand
15 | {
16 | protected override void ExecuteCore()
17 | {
18 | if (Ac.GetBlockNames(true, true).Count< 1)
19 | throw new System.Exception(AppServices.Strings.BlocksNotFond);
20 |
21 | var selWnd = new BlockSelectWindow(OnBlocksSelected);
22 | Ac.ShowModal(selWnd);
23 | }
24 |
25 | private void OnBlocksSelected(List blockRefs)
26 | {
27 | var expWnd = new BlockExpTextWindow(blockRefs);
28 | Ac.ShowModal(expWnd);
29 | }
30 |
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/Source/Geo7.App/Tools/BlockExpText/BlockExpTextPresenter.cs:
--------------------------------------------------------------------------------
1 |
2 | #if AutoCAD
3 | using Autodesk.AutoCAD.Runtime;
4 | using Autodesk.AutoCAD.DatabaseServices;
5 | using Autodesk.AutoCAD.Geometry;
6 | using Autodesk.AutoCAD.ApplicationServices;
7 | using Autodesk.AutoCAD.EditorInput;
8 | using Autodesk.AutoCAD.Windows;
9 | #endif
10 |
11 | #if BricsCAD
12 | using Teigha.Runtime;
13 | using Teigha.DatabaseServices;
14 | using Teigha.Geometry;
15 | using Bricscad.ApplicationServices;
16 | using Bricscad.EditorInput;
17 | using Bricscad.Windows;
18 | #endif
19 |
20 | using System;
21 | using System.Collections.Generic;
22 | using System.IO;
23 | using System.Linq;
24 | using System.Text;
25 | using System.Windows.Input;
26 |
27 |
28 | namespace Geo7.Tools
29 | {
30 |
31 | public class BlockExpTextPresenter : PointTextStorageWriter
32 | {
33 | public BlockExpTextPresenter(List blockRefs)
34 | {
35 | if (blockRefs?.Count < 1)
36 | {
37 | throw new ArgumentException(this.GetType().Name + " initialization failed: empty AcBlockRef list");
38 | }
39 |
40 | _blockRefs = blockRefs;
41 | this.UseCode = false; // To export code use this.UseAdditionalFields instead
42 | this.SampleData = ToPoint(blockRefs.First());
43 |
44 | this.AddHeader(Ac.Db.Filename);
45 | //this.AddHeader(Ac.Doc.Name);
46 | this.AddHeader(DateTime.Now.ToShortDateString());
47 |
48 | UpdateAdditionalFieldNames(blockRefs.FirstOrDefault());
49 | }
50 |
51 | private List _blockRefs;
52 |
53 | public int BlockCount { get { return _blockRefs.Count; } }
54 |
55 |
56 | private void UpdateAdditionalFieldNames(AcBlockRef sampleBlockRef)
57 | {
58 | this.AdditionalFieldNames.Clear();
59 | this.AdditionalFieldNames.Add("Layer");
60 | this.AdditionalFieldNames.Add("Block");
61 |
62 | foreach (var attr in sampleBlockRef.Attributes)
63 | {
64 | this.AdditionalFieldNames.Add("Attr_" + attr.Tag);
65 | }
66 | }
67 |
68 | private bool _useHeightAttribute;
69 | public bool UseHeightAttribute
70 | {
71 | get { return _useHeightAttribute; }
72 | set { OnPropertyChanged(ref _useHeightAttribute, value, nameof(UseHeightAttribute)); }
73 | }
74 |
75 |
76 | public string ValidIdAttributes { get { return Ac.IdAttributeTags.Join(", "); } }
77 | public string ValidHeightAttributes { get { return Ac.HeightAttributeTags.Join(", "); } }
78 |
79 |
80 | protected override void OnSampleDataChanged()
81 | {
82 | base.OnSampleDataChanged();
83 | }
84 |
85 |
86 | private XyzPoint ToPoint(AcBlockRef block)
87 | {
88 | var pt = new XyzPoint();
89 |
90 | pt.X = block.Position.X;
91 | pt.Y = block.Position.Y;
92 | pt.Z = block.Position.Z;
93 |
94 | // Do not change coordinates order, this will be done by PointTextStorageWriter.GetPointFields()
95 | //if (this.ChangeCoordinatesOrder)
96 | //{
97 | // pt.X = block.Position.Y;
98 | // pt.Y = block.Position.X;
99 | //}
100 |
101 | if (block.IdAttribute != null)
102 | pt.Id = block.IdAttribute.TextString;
103 |
104 | if (block.CodeAttribute != null)
105 | pt.Code = block.CodeAttribute.TextString;
106 |
107 | if (this.UseHeightAttribute)
108 | {
109 | double hAttrVal = 0.0;
110 | if (block.HeightAttribute != null)
111 | {
112 | var hAttr = block.HeightAttribute.TextString;
113 | hAttr.TryParse(ref hAttrVal);
114 | }
115 | pt.Z = hAttrVal;
116 | }
117 |
118 | pt.AdditionalFields.Clear();
119 | pt.AdditionalFields.Add(block.Layer);
120 | pt.AdditionalFields.Add(block.Name);
121 | foreach (var attr in block.Attributes)
122 | {
123 | pt.AdditionalFields.Add(attr.TextString);
124 | }
125 |
126 | pt.Coord1.Precision = CoordinatesPrecision;
127 | pt.Coord2.Precision = CoordinatesPrecision;
128 | pt.Coord3.Precision = ThirdCoordinatePrecision;
129 |
130 | return pt;
131 |
132 | }
133 |
134 | private PointRepository GetPoints()
135 | {
136 | var points = new PointRepository();
137 |
138 | foreach (var bl in _blockRefs)
139 | {
140 | points.Add(ToPoint(bl));
141 | }
142 | return points;
143 | }
144 |
145 | public override IList GetPointFields(XyzPoint point)
146 | {
147 | return base.GetPointFields(point);
148 | }
149 |
150 | private void Export()
151 | {
152 | var dlg = AppServices.SaveFileDialog;
153 | var storage = dlg.ShowTextLinesWritersDialog(Ac.GetLastFileName("points"));
154 | if (storage == null)
155 | return;
156 |
157 | using (storage)
158 | {
159 | Ac.SetLastFileName("points", dlg.FilePath);
160 | base.WritePoints(storage, this.GetPoints());
161 | }
162 | }
163 |
164 | public ICommand ExportCommand
165 | {
166 | get { return new DelegateCommand(Export); }
167 | }
168 | }
169 |
170 |
171 | }
172 |
--------------------------------------------------------------------------------
/Source/Geo7.App/Tools/BlockExpText/BlockExpTextWindow.xaml:
--------------------------------------------------------------------------------
1 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
20 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
35 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 | X,Y coordinates:
56 |
61 |
62 |
63 | Z coordinate:
64 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
83 |
84 |
90 |
98 |
99 |
100 |
101 |
102 |
103 |
--------------------------------------------------------------------------------
/Source/Geo7.App/Tools/BlockExpText/BlockExpTextWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Windows;
4 | using Geo7.Tools;
5 |
6 | namespace Geo7.Windows
7 | {
8 | ///
9 | /// Interaction logic for BlockExportWindow.xaml
10 | ///
11 | public partial class BlockExpTextWindow : System.Windows.Window
12 | {
13 | public BlockExpTextWindow(List blockRefs)
14 | {
15 | InitializeComponent();
16 | DataContext = new BlockExpTextPresenter(blockRefs);
17 | }
18 |
19 | private void BtnCancel_Click(object sender, RoutedEventArgs e)
20 | {
21 | this.Close();
22 | }
23 |
24 | private void BtnSelectBlocks_Click(object sender, RoutedEventArgs e)
25 | {
26 | }
27 |
28 | private void BtnOK_Click(object sender, RoutedEventArgs e)
29 | {
30 | this.Close();
31 | }
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/Source/Geo7.App/Tools/BlockFind/BlockFindCommand.cs:
--------------------------------------------------------------------------------
1 |
2 |
3 | #if AutoCAD
4 | using Autodesk.AutoCAD.Runtime;
5 | using Autodesk.AutoCAD.DatabaseServices;
6 | using Autodesk.AutoCAD.Geometry;
7 | using Autodesk.AutoCAD.ApplicationServices;
8 | using Autodesk.AutoCAD.EditorInput;
9 | using Autodesk.AutoCAD.Windows;
10 | #endif
11 |
12 | #if BricsCAD
13 | using Teigha.Runtime;
14 | using Teigha.DatabaseServices;
15 | using Teigha.Geometry;
16 | using Bricscad.ApplicationServices;
17 | using Bricscad.EditorInput;
18 | using Bricscad.Windows;
19 | #endif
20 |
21 |
22 | using System;
23 | using System.Collections.Generic;
24 | using System.Linq;
25 | using System.Text;
26 | using System.Windows.Forms.Integration;
27 | using Geo7.ToolPalettes;
28 |
29 |
30 | namespace Geo7.Tools
31 | {
32 |
33 | public class BlockFindCommand : PaletteCommand
34 | {
35 | public BlockFindCommand()
36 | {
37 | this.DisplayName = AppServices.Strings.FindBlock;
38 | //this.SmallImage = Resources.Find;
39 | }
40 |
41 | private static PaletteSet palletteSet;
42 |
43 | protected override void ExecuteCore()
44 | {
45 | // use constructor with Guid so that we can save/load user data
46 | if (palletteSet == null)
47 | {
48 | palletteSet = new PaletteSet(AppServices.Strings.FindBlock);
49 | //palletteSet.MinimumSize = new System.Drawing.Size(300, 300);
50 | //ToolsPalettes.Size = new System.Drawing.Size(300, 500);
51 | //ToolsPalettes.Style = PaletteSetStyles.ShowTabForSingle | PaletteSetStyles.ShowAutoHideButton | PaletteSetStyles.ShowCloseButton;
52 | //ToolsPalettes.KeepFocus = true;
53 | AddPalette(palletteSet, new BlockFindPage());
54 | }
55 | palletteSet.Visible = true;
56 | }
57 | }
58 | }
59 |
--------------------------------------------------------------------------------
/Source/Geo7.App/Tools/BlockFind/BlockFindPage.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
13 |
17 |
18 |
19 |
20 |
21 |
29 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
--------------------------------------------------------------------------------
/Source/Geo7.App/Tools/BlockFind/BlockFindPage.xaml.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Windows;
6 | using System.Windows.Controls;
7 | using System.Windows.Data;
8 | using System.Windows.Documents;
9 | using System.Windows.Input;
10 | using System.Windows.Media;
11 | using System.Windows.Media.Imaging;
12 | using System.Windows.Navigation;
13 | using System.Windows.Shapes;
14 | using Geo7;
15 | using Geo7.Tools;
16 |
17 | namespace Geo7.ToolPalettes
18 | {
19 | ///
20 | /// Interaction logic for BlocksPalette.xaml
21 | ///
22 | public partial class BlockFindPage : Page
23 | {
24 | public BlockFindPage()
25 | {
26 | InitializeComponent();
27 | DataContext = new BlockFindPresenter();
28 | }
29 |
30 | private void BlockSettingsButton_Click(object sender, RoutedEventArgs e)
31 | {
32 | //Ac.ShowModal(new BlockSettingsWindow());
33 | }
34 |
35 | private void Find_KeyDown(object sender, KeyEventArgs e)
36 | {
37 | if (e.Key == Key.Enter)
38 | {
39 | this.UpdateLayout();
40 | (DataContext as BlockFindPresenter).FindCommand.Execute(null);
41 | }
42 | }
43 |
44 | private void ImageButton_Click(object sender, RoutedEventArgs e)
45 | {
46 |
47 | }
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/Source/Geo7.App/Tools/BlockFind/BlockFindPresenter.cs:
--------------------------------------------------------------------------------
1 |
2 |
3 | #if AutoCAD
4 | using Autodesk.AutoCAD.Runtime;
5 | using Autodesk.AutoCAD.DatabaseServices;
6 | using Autodesk.AutoCAD.Geometry;
7 | using Autodesk.AutoCAD.ApplicationServices;
8 | using Autodesk.AutoCAD.EditorInput;
9 | using Autodesk.AutoCAD.Windows;
10 | #endif
11 |
12 | #if BricsCAD
13 | using Teigha.Runtime;
14 | using Teigha.DatabaseServices;
15 | using Teigha.Geometry;
16 | using Bricscad.ApplicationServices;
17 | using Bricscad.EditorInput;
18 | using Bricscad.Windows;
19 | #endif
20 |
21 |
22 | using System;
23 | using System.Collections.Generic;
24 | using System.Linq;
25 | using System.Text;
26 | using System.Windows.Input;
27 |
28 | namespace Geo7.Tools
29 | {
30 | public class BlockFindPresenter : Presenter
31 | {
32 | public BlockFindPresenter()
33 | {
34 | FindCommand = new AcDelegateCommand(Find, CanFind);
35 | FindNextCommand = new AcDelegateCommand(FindNext, CanFind);
36 | FoundInfoVisibility = System.Windows.Visibility.Collapsed;
37 | }
38 |
39 | public string FindText { get; set; }
40 | public ICommand FindCommand { get; set; }
41 | public ICommand FindNextCommand { get; set; }
42 |
43 |
44 | private List Find(string text)
45 | {
46 | var findList = new List();
47 | if (string.IsNullOrEmpty(text))
48 | {
49 | return findList;
50 | }
51 | var findTextLower = text.Trim().ToLower();
52 |
53 | using (var trans = Ac.StartTransaction())
54 | {
55 | var blockRefs = trans.GetAllEntities().Where(b => b.AttributeCollection.Count > 0);
56 | foreach (var block in blockRefs)
57 | {
58 | if (!trans.IsDisplayed(block))
59 | continue;
60 | for (int iAttr = 0; iAttr < block.AttributeCollection.Count; iAttr++)
61 | {
62 | var attrId = block.AttributeCollection[iAttr];
63 | var attr = trans.GetObject(attrId);
64 | if (!attr.Visible || attr.Invisible)
65 | continue;
66 | if (attr.TextString.ToLower().Contains(findTextLower))
67 | {
68 | var fti = new FindTextInfo();
69 | fti.Text = attr.TextString;
70 | fti.Position = block.Position;
71 | fti.Source = block.Name + "." + attr.Tag;
72 | findList.Add(fti);
73 | }
74 | }
75 | }
76 | }
77 | return findList;
78 | }
79 |
80 | private void Find()
81 | {
82 | var findList = Find(FindText);
83 | FindList = findList;
84 |
85 | if (findList.Count > 0)
86 | {
87 | var selItem = findList.FirstOrDefault(i => i.Text == FindText); // Najpierw spróbuj znaleźć dokładny tekst
88 | if (selItem == null)
89 | selItem = findList.FirstOrDefault(i => i.Text.ToLower() == FindText.ToLower()); // Potem szukaj Case Insensitive
90 | if (selItem == null)
91 | selItem = findList.First(); // Jeżeli ciągle nic nie znajdzie - ustaw pierwszy z brzegu
92 |
93 | SelectedItem = selItem;
94 | SetFoundInfo(null);
95 | }
96 | else
97 | {
98 | SetFoundInfo(string.Format(AppServices.Strings.XNotFound, FindText));
99 | }
100 |
101 | this.OnPropertyChanged(nameof(FindList));
102 | }
103 |
104 | private void FindNext()
105 | {
106 | if (FindText == null)
107 | {
108 | return;
109 | }
110 |
111 | int findNo;
112 | try
113 | {
114 | findNo = FindText.ToInt();
115 | }
116 | catch (System.Exception ex)
117 | {
118 | SetFoundInfo(ex.Message);
119 | return;
120 | }
121 | FindText = (++findNo).ToString();
122 | this.OnPropertyChanged(nameof(FindText));
123 | Find();
124 | }
125 |
126 | private bool CanFind()
127 | {
128 | return Ac.Db != null;
129 | //return !string.IsNullOrEmpty(FindText);
130 | }
131 |
132 | public System.Windows.Visibility FoundInfoVisibility { get; set; }
133 | public string FoundInfo { get; set; }
134 |
135 | private void SetFoundInfo(string info)
136 | {
137 | if (string.IsNullOrEmpty(info))
138 | {
139 | FoundInfoVisibility = System.Windows.Visibility.Collapsed;
140 | }
141 | else
142 | {
143 | FoundInfo = info;
144 | FoundInfoVisibility = System.Windows.Visibility.Visible;
145 | }
146 | OnPropertyChanged(nameof(FoundInfoVisibility));
147 | OnPropertyChanged(nameof(FoundInfo));
148 | }
149 |
150 | public IEnumerable FindList { get; set; }
151 |
152 | private FindTextInfo mSelectedItem;
153 | public FindTextInfo SelectedItem
154 | {
155 | get
156 | {
157 | return mSelectedItem;
158 | }
159 | set
160 | {
161 | mSelectedItem = value;
162 | if (mSelectedItem != null)
163 | {
164 | Ac.ZoomTo(mSelectedItem.Position);
165 | }
166 | }
167 | }
168 |
169 | public class FindTextInfo
170 | {
171 | public string Text { get; set; }
172 | public Point3d Position { get; set; }
173 | public string Source { get; set; }
174 | }
175 |
176 | }
177 | }
178 |
--------------------------------------------------------------------------------
/Source/Geo7.App/Tools/BlockImpText/BlockImpTextCommand.cs:
--------------------------------------------------------------------------------
1 | using Geo7.Windows;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.IO;
5 | using System.Linq;
6 | using System.Text;
7 | using System.Windows.Forms;
8 |
9 |
10 |
11 | namespace Geo7.Tools
12 | {
13 |
14 | public class BlockImpTextCommand : AcCommand
15 | {
16 | protected override void ExecuteCore()
17 | {
18 | var dlg = AppServices.OpenFileDialog;
19 | var storage = dlg.ShowTextLinesReadersDialog(Ac.GetLastFileName("points"));
20 | if (storage == null)
21 | return;
22 |
23 | using (storage)
24 | {
25 | Ac.SetLastFileName("points", dlg.FilePath);
26 | var presenter = new BlockImpTextPresenter(storage);
27 | var wnd = new BlockImpTextWindow();
28 | wnd.DataContext = presenter;
29 |
30 | if (Ac.ShowModal(wnd))
31 | {
32 | presenter.Import();
33 | }
34 | }
35 | }
36 |
37 | private void Wnd_Closed(object sender, EventArgs e)
38 | {
39 | throw new NotImplementedException();
40 | }
41 | }
42 |
43 |
44 |
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/Source/Geo7.App/Tools/BlockImpText/BlockImpTextPresenter.cs:
--------------------------------------------------------------------------------
1 |
2 |
3 | #if AutoCAD
4 | using Autodesk.AutoCAD.Runtime;
5 | using Autodesk.AutoCAD.DatabaseServices;
6 | using Autodesk.AutoCAD.Geometry;
7 | using Autodesk.AutoCAD.ApplicationServices;
8 | using Autodesk.AutoCAD.EditorInput;
9 | using Autodesk.AutoCAD.Windows;
10 | #endif
11 |
12 | #if BricsCAD
13 | using Teigha.Runtime;
14 | using Teigha.DatabaseServices;
15 | using Teigha.Geometry;
16 | using Bricscad.ApplicationServices;
17 | using Bricscad.EditorInput;
18 | using Bricscad.Windows;
19 | #endif
20 |
21 |
22 | using System;
23 | using System.Collections.Generic;
24 | using System.IO;
25 | using System.Linq;
26 | using System.Text;
27 | using System.Windows.Input;
28 |
29 |
30 |
31 | namespace Geo7.Tools
32 | {
33 |
34 |
35 | public class BlockImpTextPresenter : PointTextStorageReader
36 | {
37 |
38 | public BlockImpTextPresenter(TextLinesReader storage)
39 | {
40 | var blNames = new List(Geo7App.DefPointBlockNames);
41 | var existingBlNames = Ac.GetBlockNames(false, true);
42 | foreach (var blName in existingBlNames)
43 | {
44 | if (!blNames.Contains(blName))
45 | blNames.Add(blName);
46 | }
47 |
48 | this.BlockNames = blNames; // WinForms BindingSource accepts only IList or IListSource
49 | this.BlockName = this.BlockNames.FirstOrDefault();
50 |
51 | this.Storage = storage;
52 | this.FileName = System.IO.Path.GetFileName(Storage.Path);
53 | this.SampleLine = storage.GetSampleLine();
54 |
55 | OnSettingsChanged();
56 | }
57 |
58 | public TextLinesReader Storage { get; private set; }
59 |
60 | public string FileName { get; private set; }
61 |
62 | public List BlockNames { get; private set; }
63 |
64 | private string _blockName;
65 | public string BlockName
66 | {
67 | get { return _blockName; }
68 | set
69 | {
70 | if (OnPropertyChanged(ref _blockName, value, nameof(BlockName)))
71 | {
72 | this.BlockHAttr = GetBlockHAttr();
73 | }
74 | }
75 | }
76 |
77 | private string _blockHAttr;
78 | public string BlockHAttr
79 | {
80 | get { return _blockHAttr; }
81 | set { OnPropertyChanged(ref _blockHAttr, value, nameof(BlockHAttr)); }
82 | }
83 |
84 | private string GetBlockHAttr()
85 | {
86 | if (Geo7App.DefPointBlockNames.Contains(BlockName))
87 | return "H";
88 |
89 | using (var docLock = Ac.Doc.LockDocument())
90 | using (var trans = Ac.StartTransaction())
91 | {
92 | if (!trans.BlockTable.Has(this.BlockName))
93 | return "";
94 |
95 | var blockDef = trans.GetBlockDef(BlockName);
96 | if (blockDef.HeightAttribute == null)
97 | return "";
98 |
99 | return blockDef.HeightAttribute;
100 | }
101 | }
102 |
103 |
104 | private bool _saveThirdCoordinateAsHeightAttribute = false;
105 | public bool SaveThirdCoordinateAsHeightAttribute
106 | {
107 | get { return _saveThirdCoordinateAsHeightAttribute; }
108 | set { OnPropertyChanged(ref _saveThirdCoordinateAsHeightAttribute, value, nameof(SaveThirdCoordinateAsHeightAttribute)); }
109 | }
110 |
111 | private string _heightAttributePrecision = "[Auto]";
112 | public string HeightAttributePrecision
113 | {
114 | get { return _heightAttributePrecision; }
115 | set { OnPropertyChanged(ref _heightAttributePrecision, value, nameof(HeightAttributePrecision)); }
116 | }
117 |
118 | public string[] HeightAttributePrecisions { get; } = new string[] { "[Auto]", "0", "0.0", "0.00", "0.000", "0.0000" };
119 |
120 |
121 |
122 | private void AddPointsToDrawing(ICollection points)
123 | {
124 | AcDwgDb.ImportMissedBlockDef(this.BlockName, Geo7App.Geo7Dwg);
125 |
126 | using (var docLock = Ac.Doc.LockDocument())
127 | {
128 | using (var trans = Ac.StartTransaction())
129 | {
130 | var blockScale = trans.GetSavedBlockScale(BlockName);
131 | var blockDef = trans.GetBlockDef(this.BlockName);
132 | Ac.InitProgress(AppServices.Strings.LoadingPoints, points.Count);
133 |
134 | foreach (var pt in points)
135 | {
136 | // Do not change X,Y coordinates - it was already done through this.ReadPoints(this.Storage, points);
137 | var blockPos = pt.ToPoint3d(this.IgnoreThirdCoordinate);
138 | var blockRef = blockDef.AddBlockRef(blockPos, trans);
139 | blockRef.Scale = blockScale;
140 |
141 | if (blockRef.Attributes.Count > 0)
142 | SetAttributes(blockRef, pt);
143 |
144 | //blockRef.Dispose();
145 | Ac.ProgressStep();
146 | }
147 | Ac.ClearProgress();
148 | //blockDef.Dispose();
149 | trans.Commit();
150 | }
151 | //Debug.WriteLine(docLock);
152 | }
153 | }
154 |
155 |
156 | private void SetAttributes(AcBlockRef blockRef, XyzPoint pt)
157 | {
158 | if (blockRef.IdAttribute != null)
159 | {
160 | blockRef.IdAttribute.TextString = pt.Id;
161 | }
162 |
163 | var attrH = blockRef.HeightAttribute;
164 | if ((attrH != null) && (this.SaveThirdCoordinateAsHeightAttribute))
165 | {
166 | if (this.HeightAttributePrecision.StartsWith("0"))
167 | {
168 | attrH.TextString = pt.Z.ToString(this.HeightAttributePrecision);
169 | }
170 | else
171 | {
172 | attrH.TextString = pt.Z.ToString();
173 | }
174 | }
175 |
176 | var attrCode = blockRef.CodeAttribute;
177 | if ((attrCode != null) && (this.UseCode))
178 | attrCode.TextString = pt.Code;
179 | }
180 |
181 | private void ReadSamplePoints(PointRepository repository)
182 | {
183 | repository.Add(new XyzPoint() { Id = "A", X = 1, Y = 5, Z = 1.1 });
184 | repository.Add(new XyzPoint() { Id = "B", X = 8, Y = 2, Z = 2.22 });
185 | repository.Add(new XyzPoint() { Id = "C", X = 2, Y = 9, Z = 3.333 });
186 | repository.Add(new XyzPoint() { Id = "D", X = 8, Y = 4, Z = 4.4444 });
187 | }
188 |
189 |
190 | public void Import()
191 | {
192 | Ac.WriteLn(AppServices.Strings.Loading);
193 | var points = new PointRepository();
194 | this.ReadPoints(this.Storage, points);
195 | //this.ReadSamplePoints(points);
196 |
197 | AddPointsToDrawing(points);
198 |
199 | var min = points.Min.ToPoint3d();
200 | var max = points.Max.ToPoint3d();
201 | Ac.ZoomTo(min, max);
202 |
203 | Ac.WriteLn(AppServices.Strings.XPointsLoaded, points.Count);
204 | }
205 |
206 | }
207 |
208 | }
209 |
--------------------------------------------------------------------------------
/Source/Geo7.App/Tools/BlockImpText/BlockImpTextWindow.xaml:
--------------------------------------------------------------------------------
1 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 | File name:
30 |
31 |
32 |
33 |
34 | Sample line:
35 |
36 |
37 |
38 |
39 | File format:
40 |
41 |
42 |
43 |
44 | Sample data:
45 |
46 |
47 |
48 |
49 |
50 |
51 | Block name:
52 |
53 |
54 |
55 |
56 |
57 |
58 | Change X,Y coordinates order
59 | Ignore Z coordinate (set Z=0.00)
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 | Save Z coordinate as block attribute
68 |
69 |
70 |
71 |
72 |
73 | Z coordinate precision:
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
--------------------------------------------------------------------------------
/Source/Geo7.App/Tools/BlockImpText/BlockImpTextWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 |
4 |
5 | namespace Geo7.Windows
6 | {
7 | ///
8 | /// Interaction logic for BlocksImportWindow.xaml
9 | ///
10 | public partial class BlockImpTextWindow : System.Windows.Window
11 | {
12 | public BlockImpTextWindow()
13 | {
14 | InitializeComponent();
15 | }
16 |
17 |
18 | private void BtnClose_Click(object sender, RoutedEventArgs e)
19 | {
20 | //this.Close(); this.IsCancel = true
21 | }
22 |
23 |
24 | private void BtnOK_Click(object sender, RoutedEventArgs e)
25 | {
26 | //AppServices.Dialog.ShowInfo("BtnOK_Click");
27 | this.DialogResult = true;
28 | this.Close();
29 | }
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/Source/Geo7.App/Tools/BlockInsert/BlockInsertCommand.cs:
--------------------------------------------------------------------------------
1 |
2 |
3 | using System;
4 |
5 | namespace Geo7.Tools
6 | {
7 | class BlockInsertCommand : AcCommand
8 | {
9 |
10 | public BlockInsertCommand(string blockName)
11 | {
12 | this.BlockName = blockName;
13 | }
14 |
15 | private string _blockName;
16 | public string BlockName {
17 | get { return _blockName; }
18 | set
19 | {
20 | _blockName = value;
21 | LastBlockName = value;
22 | using (var trans = Ac.StartTransaction(false))
23 | {
24 | BlockScale = trans.GetSavedBlockScale(BlockName);
25 | }
26 | }
27 | }
28 |
29 | private double _blockScale = 1.0;
30 | public double BlockScale
31 | {
32 | get
33 | {
34 | return _blockScale;
35 | }
36 | set
37 | {
38 | if (value <= 0.0)
39 | _blockScale = 1.0;
40 | else
41 | _blockScale = value;
42 | }
43 | }
44 |
45 |
46 | private static string pointId = "1";
47 |
48 | private static string _lastBlockName = "";
49 | public static string LastBlockName
50 | {
51 | get
52 | {
53 | return _lastBlockName;
54 | }
55 | set
56 | {
57 | if (!string.IsNullOrEmpty(value))
58 | _lastBlockName = value;
59 | }
60 | }
61 |
62 |
63 | protected override void ExecuteCore()
64 | {
65 | InitBlockName();
66 | do
67 | {
68 | var ptRes = Ac.Editor.GetPoint("\r\n" + AppServices.Strings.EnterInsertionPoint);
69 | if (!ptRes.IsOK())
70 | return;
71 |
72 | var insPnt = ptRes.Value;
73 |
74 | var idOpt = Ac.Editor.GetPromptStringOptions("r\n" + AppServices.Strings.EnterPointId, pointId, false, true);
75 | var idRes = Ac.Editor.GetString(idOpt);
76 | if (!idRes.IsOK())
77 | return;
78 |
79 | pointId = idRes.StringResult;
80 |
81 | using (var trans = Ac.StartTransaction(true))
82 | {
83 | var blockDef = trans.GetBlockDef(BlockName);
84 | var blockRef = blockDef.AddBlockRef(insPnt, trans);
85 | blockRef.Scale = this.BlockScale;
86 | blockRef.SetIdAttribute(pointId);
87 |
88 | trans.Commit();
89 | }
90 |
91 | pointId = pointId.NextPointId();
92 |
93 | } while (true);
94 |
95 | }
96 |
97 |
98 | private void InitBlockName()
99 | {
100 | if (!string.IsNullOrEmpty(BlockName))
101 | return;
102 |
103 | var bnOpt = Ac.Editor.GetPromptStringOptions("\r\n" + AppServices.Strings.EnterBlockName, LastBlockName, false, true);
104 | var bnRes = Ac.Editor.GetString(bnOpt);
105 | if (!bnRes.IsOK())
106 | return;
107 |
108 | var blockName = bnRes.StringResult;
109 | if (string.IsNullOrEmpty(blockName))
110 | {
111 | //InitBlockName();
112 | return;
113 | }
114 |
115 | AcDwgDb.ImportMissedBlockDef(blockName, Geo7App.Geo7Dwg);
116 | this.BlockName = blockName;
117 | }
118 |
119 | }
120 |
121 |
122 | }
123 |
--------------------------------------------------------------------------------
/Source/Geo7.App/Tools/BlockSelect/BlockSelectPresenter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Windows.Input;
5 |
6 | namespace Geo7.Tools
7 | {
8 |
9 | public delegate void BlockRefsAction(List blockRefs);
10 |
11 | class BlockSelectPresenter : Presenter
12 | {
13 | public BlockSelectPresenter(System.Windows.Window wnd, BlockRefsAction action)
14 | {
15 | _window = wnd;
16 | _action = action;
17 | BlockNames = Ac.GetBlockNames(true, true).ToList(); // WinForms BindingSource accepts only IList or IListSource
18 | BlockName = BlockNames.FirstOrDefault();
19 | }
20 |
21 |
22 | private System.Windows.Window _window;
23 | private AcObjectIds _selectedIds = new AcObjectIds();
24 | private BlockRefsAction _action;
25 |
26 |
27 | public void AddSelectedIds(AcObjectIds ids)
28 | {
29 | _selectedIds.AddItems(ids);
30 | OnPropertyChanged(nameof(HasSelectedBlocks));
31 | OnPropertyChanged(nameof(SelectedBlockCount));
32 | }
33 |
34 | private void ClearSelectedIds()
35 | {
36 | _selectedIds.Clear();
37 | OnPropertyChanged(nameof(HasSelectedBlocks));
38 | OnPropertyChanged(nameof(SelectedBlockCount));
39 |
40 | }
41 | public bool HasSelectedBlocks { get { return this._selectedIds.Count > 0; } }
42 | public int SelectedBlockCount { get { return this._selectedIds.Count; } }
43 |
44 | public ICommand ClearSeclectedBlocksCommand
45 | {
46 | get { return new DelegateCommand(ClearSelectedIds, () => { return HasSelectedBlocks; }); }
47 | }
48 |
49 | public void SelectAllBlocks()
50 | {
51 | using (var docLoc = Ac.Doc.LockDocument())
52 | {
53 | var selectedBlocks = Ac.Editor.GetAllBlocks(this.BlockName);
54 | AddSelectedIds(selectedBlocks);
55 | }
56 | }
57 |
58 | public ICommand SelectAllBlocksCommand
59 | {
60 | get { return new DelegateCommand(SelectAllBlocks); }
61 | }
62 |
63 |
64 | public List GetSelectedBlocks()
65 | {
66 | var res = new List();
67 | using (var trans = Ac.StartTransaction())
68 | {
69 | foreach (var id in _selectedIds)
70 | {
71 | var block = new AcBlockRef(id, trans);
72 | res.Add(block);
73 | }
74 | }
75 |
76 | return res;
77 | }
78 |
79 | private void SelectBlocks()
80 | {
81 | using (var docLock = Ac.Doc.LockDocument())
82 | using (var ui = Ac.StartUserInteraction(_window))
83 | {
84 | var selectedBlocks = Ac.Editor.GetBlocks(BlockName);
85 | AddSelectedIds(selectedBlocks);
86 | ui.End();
87 | }
88 | }
89 |
90 | public ICommand SelectBlocksCommand
91 | {
92 | get { return new DelegateCommand(SelectBlocks); }
93 | }
94 |
95 | public List BlockNames { get; private set; }
96 |
97 | private string _blockName;
98 | public string BlockName
99 | {
100 | get { return _blockName; }
101 | set { OnPropertyChanged(ref _blockName, value, nameof(this.BlockName)); }
102 | }
103 |
104 |
105 | public ICommand SelectCommand
106 | {
107 | get { return new DelegateCommand(() => { _action(this.GetSelectedBlocks()); }, () => { return HasSelectedBlocks; }); }
108 | }
109 | }
110 | }
111 |
--------------------------------------------------------------------------------
/Source/Geo7.App/Tools/BlockSelect/BlockSelectWindow.xaml:
--------------------------------------------------------------------------------
1 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
27 |
28 |
29 |
30 |
38 |
39 |
40 |
41 |
42 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
62 |
63 |
69 |
77 |
78 |
79 |
80 |
81 |
--------------------------------------------------------------------------------
/Source/Geo7.App/Tools/BlockSelect/BlockSelectWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Windows;
2 |
3 | namespace Geo7.Tools
4 | {
5 | ///
6 | /// Interaction logic for BlockSelectWindow.xaml
7 | ///
8 | public partial class BlockSelectWindow : Window
9 | {
10 | public BlockSelectWindow(BlockRefsAction action)
11 | {
12 | InitializeComponent();
13 | DataContext = new BlockSelectPresenter(this, action);
14 | }
15 |
16 |
17 | private void BtnCancel_Click(object sender, RoutedEventArgs e)
18 | {
19 | this.Close();
20 | }
21 |
22 | private void BtnOK_Click(object sender, RoutedEventArgs e)
23 | {
24 | this.Close();
25 | }
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/Source/Geo7.App/Tools/BlockSettigns/BlockSettingsCommand.cs:
--------------------------------------------------------------------------------
1 | using Geo7.Windows;
2 | using System;
3 | using System.Collections.Generic;
4 | using System.Linq;
5 | using System.Text;
6 |
7 | namespace Geo7.Tools
8 | {
9 |
10 | public class BlockSettingsCommand : AcCommand
11 | {
12 | protected override void ExecuteCore()
13 | {
14 | var presenter = new BlocksSettingsPresenter();
15 | if (presenter.BlockList.Count < 1)
16 | throw new System.Exception(AppServices.Strings.BlocksNotFond);
17 |
18 | var wnd = new BlockSettingsWindow();
19 | wnd.DataContext = presenter;
20 | Ac.ShowModal(wnd);
21 | }
22 |
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/Source/Geo7.App/Tools/BlockSettigns/BlockSettingsPresenter.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Windows.Input;
5 |
6 | namespace Geo7.Tools
7 | {
8 |
9 |
10 | public class BlocksSettingsPresenter : Presenter
11 | {
12 | public BlocksSettingsPresenter()
13 | {
14 | using (var trans = Ac.StartTransaction())
15 | {
16 | BlockList = trans.BlockDefs.Where(b => (b.HasAttributes) && (b.HasReferences)).ToList();
17 | }
18 |
19 | SelectedBlock = BlockList.FirstOrDefault();
20 | }
21 |
22 | public List BlockList { get; private set; }
23 |
24 | public void Save()
25 | {
26 | //Ac.InitProgress("Saving block data...", SelectedBlock.BlockCount);
27 |
28 | using (var docLock = Ac.Doc.LockDocument())
29 | using (var trans = Ac.StartTransaction())
30 | {
31 | var blockDef = trans.GetBlockDef(SelectedBlock.Name);
32 | foreach (var attr in blockDef.Attributes)
33 | {
34 | // Update BlockDef from 'editable' property value
35 | var attrPresenter = SelectedBlock.GetAttribute(attr.Tag);
36 | attr.Invisible = !attrPresenter.AttrVisiblePresenter;
37 | }
38 |
39 | var blockRefs = blockDef.GetBlocks(trans);
40 | foreach (var blockRef in blockRefs)
41 | {
42 | blockRef.ResetBlock();
43 | blockRef.Scale = SelectedBlockScale;
44 |
45 | foreach (var attr in blockRef.Attributes)
46 | {
47 | var attrPresenter = SelectedBlock.GetAttribute(attr.Tag);
48 | attr.Invisible = !attrPresenter.AttrVisiblePresenter;
49 | }
50 |
51 | Ac.ProgressStep();
52 | }
53 | trans.SetSavedBlockScale(SelectedBlock.Name, SelectedBlockScale);
54 | trans.Commit();
55 | }
56 |
57 | Ac.ClearProgress();
58 | }
59 |
60 | public ICommand SaveCommand
61 | {
62 | get { return new DelegateCommand(Save, SaveCanExecute); }
63 | }
64 |
65 |
66 | private bool SaveCanExecute()
67 | {
68 | return SelectedBlock != null;
69 | }
70 |
71 | private AcBlockDef mSelectedBlock;
72 | public AcBlockDef SelectedBlock
73 | {
74 | get
75 | {
76 | return mSelectedBlock;
77 | }
78 | set
79 | {
80 | mSelectedBlock = value;
81 | if (mSelectedBlock == null)
82 | {
83 | SelectedBlockScale = 1.0;
84 | SelectedBlockRefCount = 0;
85 | }
86 | else
87 | {
88 | using (var docLock = Ac.Doc.LockDocument())
89 | using (var trans = Ac.StartTransaction())
90 | {
91 | SelectedBlockScale = SelectedBlock.FirstBlock(trans).Scale;
92 | SelectedBlockRefCount = SelectedBlock.BlockCount;
93 | }
94 | }
95 | OnPropertyChanged(nameof(SelectedBlock));
96 | OnPropertyChanged(nameof(SelectedBlockScale));
97 | OnPropertyChanged(nameof(SelectedBlockRefCount));
98 | OnPropertyChanged(nameof(SelectedBlockAttributes));
99 | }
100 | }
101 |
102 | public int SelectedBlockRefCount { get; private set; }
103 |
104 | public IEnumerable SelectedBlockAttributes
105 | {
106 | get
107 | {
108 | if (SelectedBlock == null)
109 | return new List();
110 | return SelectedBlock.Attributes;
111 | }
112 | }
113 |
114 | public double SelectedBlockScale { get; set; }
115 |
116 | }
117 | }
118 |
--------------------------------------------------------------------------------
/Source/Geo7.App/Tools/BlockSettigns/BlockSettingsWindow.xaml:
--------------------------------------------------------------------------------
1 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
26 |
27 |
28 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/Source/Geo7.App/Tools/BlockSettigns/BlockSettingsWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | namespace Geo7.Windows
2 | {
3 | ///
4 | /// Interaction logic for BlocksSettings.xaml
5 | ///
6 | public partial class BlockSettingsWindow : System.Windows.Window
7 | {
8 | public BlockSettingsWindow()
9 | {
10 | InitializeComponent();
11 | }
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/Source/Geo7.App/Tools/ConvertDgnTexts/ConvertDgnTextsCommand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Linq;
3 |
4 |
5 |
6 | namespace Geo7.Tools
7 | {
8 | public class ConvertDgnTextsCommand : AcCommand
9 | {
10 | public ConvertDgnTextsCommand()
11 | {
12 | this.DisplayName = AppServices.Strings.ConvertDgnTexts;
13 | this.Description = AppServices.Strings.ConvertDgnTextsDsc;
14 | this.SmallImage = null;// Resources.ConvertDgnTxt;
15 | }
16 |
17 | protected override void ExecuteCore()
18 | {
19 | using (var trans = Ac.StartTransaction())
20 | {
21 | var txtEnts = trans.GetAllDBText();
22 | Ac.InitProgress(AppServices.Strings.ProcessingData, txtEnts.Count());
23 | int txtChanged = 0;
24 | foreach (var tEnt in txtEnts)
25 | {
26 | var acText = ConvertDgnText(tEnt.TextString);
27 | if (acText != tEnt.TextString)
28 | {
29 | tEnt.UpgradeOpen();
30 | tEnt.TextString = acText;
31 | txtChanged++;
32 | Ac.ProgressStep();
33 | }
34 | }
35 | trans.Commit();
36 | Ac.WriteLn(AppServices.Strings.XEntitesUpdated, txtChanged);
37 | }
38 | }
39 |
40 | private string ConvertDgnText(string dgnText)
41 | {
42 | dgnText = dgnText.Replace("%%234", "ę");
43 | dgnText = dgnText.Replace("%%202", "Ę");
44 | dgnText = dgnText.Replace("%%243", "ó");
45 | dgnText = dgnText.Replace("%%211", "Ó");
46 | dgnText = dgnText.Replace("%%185", "ą");
47 | dgnText = dgnText.Replace("%%165", "Ą");
48 | dgnText = dgnText.Replace("%%156", "ś");
49 | dgnText = dgnText.Replace("%%140", "Ś");
50 | dgnText = dgnText.Replace("%%179", "ł");
51 | dgnText = dgnText.Replace("%%163", "Ł");
52 | dgnText = dgnText.Replace("%%191", "ż");
53 | dgnText = dgnText.Replace("%%175", "Ż");
54 | dgnText = dgnText.Replace("%%159", "ź");
55 | dgnText = dgnText.Replace("%%143", "Ź");
56 | dgnText = dgnText.Replace("%%230", "ć");
57 | dgnText = dgnText.Replace("%%198", "Ć");
58 | dgnText = dgnText.Replace("%%241", "ń");
59 | dgnText = dgnText.Replace("%%209", "Ń");
60 |
61 | //dgnText = dgnText.Replace("³", "ł");
62 | dgnText = dgnText.Replace("¿", "ż");
63 | dgnText = dgnText.Replace("ê", "ę");
64 | dgnText = dgnText.Replace("ñ", "ń");
65 | dgnText = dgnText.Replace("³", "ł");
66 | dgnText = dgnText.Replace("¹", "ą");
67 | dgnText = dgnText.Replace("¥", "Ą");
68 | dgnText = dgnText.Replace("¯", "Ż");
69 | dgnText = dgnText.Replace("£", "Ł");
70 | dgnText = dgnText.Replace("Æ", "Ć");
71 | dgnText = dgnText.Replace("Ê", "Ę");
72 | dgnText = dgnText.Replace("Ñ", "Ń");
73 |
74 |
75 |
76 |
77 | return dgnText;
78 | }
79 | }
80 | }
81 |
--------------------------------------------------------------------------------
/Source/Geo7.App/Tools/OrthoDist/OrthoDistCommand.cs:
--------------------------------------------------------------------------------
1 | #if AutoCAD
2 | using Autodesk.AutoCAD.Runtime;
3 | using Autodesk.AutoCAD.DatabaseServices;
4 | using Autodesk.AutoCAD.Geometry;
5 | using Autodesk.AutoCAD.ApplicationServices;
6 | using Autodesk.AutoCAD.EditorInput;
7 | #endif
8 |
9 | #if BricsCAD
10 | using Teigha.Runtime;
11 | using Teigha.DatabaseServices;
12 | using Teigha.Geometry;
13 | using Bricscad.ApplicationServices;
14 | using Bricscad.EditorInput;
15 | #endif
16 |
17 | using System;
18 | using System.Collections.Generic;
19 | using System.Linq;
20 | using System.Text;
21 |
22 | namespace Geo7.Tools
23 | {
24 | public class OrthoDistCommand : AcCommand
25 | {
26 |
27 |
28 | double TextHeight = 1.0;
29 | OrthoTextPos TextPos = OrthoTextPos.Auto;
30 | Line2d BaseLine = new Line2d();
31 |
32 | protected override void ExecuteCore()
33 | {
34 | this.DisplayErrormMessageBox = false;
35 |
36 | if (!GetBaseLine())
37 | return;
38 | if (!GetTextHeight())
39 | return;
40 | if (!GetTextPos())
41 | return;
42 |
43 | Ac.WriteLn("Ortho Text: " + Ac.ToString(this.TextHeight) + ", " + this.TextPos.ToString());
44 |
45 | do
46 | {
47 | if (!AddOrthoDist())
48 | return;
49 |
50 | } while (true);
51 | }
52 |
53 | private bool GetBaseLine()
54 | {
55 | var ptRes = Ac.Editor.GetPoint("\r\n" + AppServices.Strings.EnterStartPoint);
56 | if (!ptRes.IsOK())
57 | return false;
58 |
59 | var startPt = ptRes.Value;
60 |
61 | var epPrtOpts = Ac.Editor.GetPromptPointOptions("\r\n" + AppServices.Strings.EnterEndPoint, startPt, true);
62 | ptRes = Ac.Editor.GetPoint(epPrtOpts);
63 | if (!ptRes.IsOK())
64 | return false;
65 |
66 | var endPt = ptRes.Value;
67 | this.BaseLine = new Line2d(startPt.Convert2d(), endPt.Convert2d());
68 | return true;
69 | }
70 |
71 | private bool GetTextHeight()
72 | {
73 | this.TextHeight = Ac.GetValue("OrthoDist.TextHeight").ToDouble();
74 | if (this.TextHeight <= 0.0)
75 | this.TextHeight = 1.0;
76 |
77 | var opts = new PromptDistanceOptions(AppServices.Strings.EnterTextHeight);
78 | opts.DefaultValue = this.TextHeight;
79 | opts.Only2d = true;
80 | opts.UseDashedLine = true;
81 | opts.UseBasePoint = false;
82 |
83 | var res = Ac.Editor.GetDistance(opts);
84 | if (res.Status != PromptStatus.OK)
85 | return false;
86 |
87 | this.TextHeight = res.Value;
88 | return true;
89 | }
90 |
91 | private bool GetTextPos()
92 | {
93 | this.TextPos = TextToPos(Ac.GetValue("OrthoDist.TextPos"));
94 |
95 | // http://help.autodesk.com/view/ACD/2016/ENU/?guid=GUID-DF40DD82-FD27-43C5-B7D2-E75646B2E47E
96 | var opts = new PromptKeywordOptions(AppServices.Strings.EnterTextPosition);
97 | opts.Keywords.Add("Left");
98 | opts.Keywords.Add("Right");
99 | //opts.Keywords.Default = this.TextPos.ToString();
100 | opts.AppendKeywordsToMessage = true;
101 | //opts.AllowNone = true;
102 | //opts.AllowArbitraryInput = true;
103 |
104 | //var optsStr = opts.Keywords.GetDisplayString(false);
105 | var res = Ac.Editor.GetKeywords(opts);
106 | if (res.Status != PromptStatus.OK)
107 | return false;
108 |
109 | this.TextPos = TextToPos(res.StringResult);
110 | return true;
111 | }
112 |
113 | private OrthoTextPos TextToPos(string s)
114 | {
115 | switch (s)
116 | {
117 | case "Right":
118 | return OrthoTextPos.Right;
119 | default:
120 | return OrthoTextPos.Left;
121 | }
122 | }
123 |
124 | private bool AddOrthoDist()
125 | {
126 | var res = Ac.Editor.GetPoint(AppServices.Strings.EnterPoint);
127 | if (res.Status != PromptStatus.OK)
128 | return false;
129 | var pt = res.Value.Convert2d();
130 |
131 | var lnPt = BaseLine.GetClosestPointTo(pt, Tolerance.Global).Point;
132 | var lnPt3d = (new Point3d(lnPt.X, lnPt.Y, 0.0));
133 |
134 | var dist = BaseLine.GetDistanceTo(pt);
135 | var distStr = Ac.ToString(dist);
136 |
137 | using (var trans = Ac.StartTransaction())
138 | {
139 | var txt =new DBText();
140 | txt.TextString = distStr;
141 |
142 | if (this.TextPos == OrthoTextPos.Left)
143 | txt.Justify = AttachmentPoint.MiddleRight;
144 | else
145 | txt.Justify = AttachmentPoint.MiddleLeft;
146 | //txt.HorizontalMode = TextHorizontalMode.TextRight;
147 |
148 | txt.Rotation = BaseLine.Direction.Angle - (Math.PI / 2.0);
149 | txt.Height = this.TextHeight;
150 | txt.Position = lnPt3d;
151 | txt.AlignmentPoint = lnPt3d; // Must be set if Justify is changed
152 |
153 | trans.AddEntity(txt);
154 | trans.Commit();
155 | Ac.Write(distStr);
156 | }
157 |
158 | return true;
159 | }
160 | }
161 |
162 | public enum OrthoTextPos
163 | {
164 | Auto,
165 | Left,
166 | Right
167 | }
168 | }
169 |
--------------------------------------------------------------------------------
/Source/Geo7.App/Tools/OrthoDist/OrtoCommand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 |
7 | namespace Geo7.Tools
8 | {
9 | public class OrtoCommand : AcCommand
10 | {
11 | public OrtoCommand()
12 | {
13 | this.DisplayName = AppServices.Strings.Orto;
14 | this.Description = AppServices.Strings.OrtoDsc;
15 | //this.SmallImage = Resources.Orto;
16 | }
17 |
18 | protected override void ExecuteCore()
19 | {
20 | var lastPolarMode = (Int16)Ac.GetSystemVariable("POLARMODE");
21 | var lastAutoSnap = (Int16)Ac.GetSystemVariable("AUTOSNAP");
22 | var angDir = Ac.GetSystemVariable("ANGDIR");
23 | var angBase = Ac.GetSystemVariable("ANGBASE");
24 |
25 | try
26 | {
27 | // Gdy jest ustawiony CLOCKWISE AC uważa, że 100g=>300g, więc ustaw wartości zerowe
28 | Ac.SetSystemVariable("ANGDIR", Convert.ToInt16(0));
29 | Ac.SetSystemVariable("ANGBASE", 0.0);
30 |
31 | Ac.SetSystemVariable("POLARANG", OrtoAngle); // Set polar angle value
32 | Ac.SetSystemVariable("POLARMODE", lastPolarMode | 1); //Turns on relative tracking
33 | Ac.SetSystemVariable("AUTOSNAP", 8 | lastAutoSnap); //Turns on polar tracking
34 | }
35 | finally
36 | {
37 | // A potem wróć do wartości poprzednich
38 | Ac.SetSystemVariable("ANGDIR", angDir);
39 | Ac.SetSystemVariable("ANGBASE", angBase);
40 | }
41 |
42 | Ac.ExecuteCommand("_pline ");
43 | }
44 |
45 |
46 | private double OrtoAngle = Math.PI / 2.0;
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/Source/Geo7.App/Tools/PtsLnDist/PtsLnDistCommand.cs:
--------------------------------------------------------------------------------
1 | #if AutoCAD
2 | using Autodesk.AutoCAD.Runtime;
3 | using Autodesk.AutoCAD.DatabaseServices;
4 | using Autodesk.AutoCAD.Geometry;
5 | using Autodesk.AutoCAD.ApplicationServices;
6 | using Autodesk.AutoCAD.EditorInput;
7 | #endif
8 |
9 | #if BricsCAD
10 | using Teigha.Runtime;
11 | using Teigha.DatabaseServices;
12 | using Teigha.Geometry;
13 | using Bricscad.ApplicationServices;
14 | using Bricscad.EditorInput;
15 | #endif
16 |
17 | using System;
18 | using System.Collections.Generic;
19 | using System.Linq;
20 | using System.Text;
21 | using Geo7.Windows;
22 |
23 | namespace Geo7.Tools
24 | {
25 | public class PtsLnDistCommand : AcCommand
26 | {
27 | ObjectId DimStyleId;
28 | ObjectId LineId;
29 |
30 | protected override void ExecuteCore()
31 | {
32 | this.DisplayErrormMessageBox = false;
33 | this.DimStyleId = AcDwgDb.ImportMissedDimStyle("G7-Diff", Geo7App.Geo7Dwg);
34 |
35 | LineId = Ac.Editor.GetPolyline("\r\n" + AppServices.Strings.SelectLine + ": ");
36 |
37 | if (LineId.IsValid)
38 | {
39 | Ac.WriteLn(AppServices.Strings.SelectBlock);
40 | var selWnd = new BlockSelectWindow(OnBlocksSelected);
41 | Ac.ShowModal(selWnd);
42 | }
43 | }
44 |
45 | private void OnBlocksSelected(List blockRefs)
46 | {
47 | using (var trans = Ac.StartTransaction())
48 | {
49 | var ln = trans.GetObject(this.LineId);
50 | if ((ln.StartPoint.Z != 0.0) || (ln.EndPoint.Z != 0.0))
51 | Ac.WriteLn("WARNING: Line is not on plane (Elevation != 0.0; Z != 0)");
52 |
53 | var ln2d = ln.ConvertTo(false);
54 | //ln2d.Elevation = 0;
55 | //foreach (Vertex2d pt in ln2d)
56 | //{
57 | // Ac.WriteLn(pt.Position.ToString());
58 | //}
59 |
60 | foreach (var bl in blockRefs)
61 | {
62 | var blPt2d = new Point3d(bl.Position.X, bl.Position.Y, 0.0);
63 | var lnPt = ln2d.GetClosestPointTo(blPt2d, false);
64 | lnPt = new Point3d(lnPt.X, lnPt.Y, 0.0);
65 |
66 | AlignedDimension dim = new AlignedDimension(blPt2d, lnPt, lnPt, null, this.DimStyleId);
67 | dim.LayerId = trans.CurrentLayer.Id;
68 |
69 | trans.AddEntity(dim);
70 | }
71 | ln2d.Dispose();
72 | trans.Commit();
73 | }
74 | }
75 |
76 | }
77 |
78 |
79 | }
--------------------------------------------------------------------------------
/Source/Geo7.App/Tools/Slope/SlopeCommand.cs:
--------------------------------------------------------------------------------
1 | #if AutoCAD
2 | using Autodesk.AutoCAD.Runtime;
3 | using Autodesk.AutoCAD.DatabaseServices;
4 | using Autodesk.AutoCAD.Geometry;
5 | using Autodesk.AutoCAD.ApplicationServices;
6 | using Autodesk.AutoCAD.EditorInput;
7 | #endif
8 |
9 | #if BricsCAD
10 | using Teigha.Runtime;
11 | using Teigha.DatabaseServices;
12 | using Teigha.Geometry;
13 | using Bricscad.ApplicationServices;
14 | using Bricscad.EditorInput;
15 | #endif
16 |
17 | using System;
18 | using System.Collections.Generic;
19 | using System.Linq;
20 | using System.Text;
21 |
22 |
23 | namespace Geo7.Tools
24 | {
25 | public class SlopeCommand : AcCommand
26 | {
27 | protected override void ExecuteCore()
28 | {
29 | this.DisplayErrormMessageBox = false;
30 | this.DimStyleId = AcDwgDb.ImportMissedDimStyle("G7-Slope", Geo7App.Geo7Dwg);
31 |
32 | do
33 | {
34 | PromptPointResult ptRes = Ac.Editor.GetPoint("\r\n" + AppServices.Strings.EnterStartPoint);
35 | if (!ptRes.IsOK())
36 | return;
37 | var startPnt = ptRes.Value;
38 |
39 | var epPrtOpts = Ac.Editor.GetPromptPointOptions("\r\n" + AppServices.Strings.EnterEndPoint, startPnt, true);
40 | ptRes = Ac.Editor.GetPoint(epPrtOpts);
41 | if (!ptRes.IsOK())
42 | return;
43 |
44 | var endPnt = ptRes.Value;
45 |
46 | AddSlope(startPnt, endPnt);
47 |
48 | } while (true);
49 | }
50 |
51 | ObjectId DimStyleId;
52 |
53 | private void AddSlope(Point3d startPnt, Point3d endPnt)
54 | {
55 | var dx = endPnt.X - startPnt.X;
56 | var dy = endPnt.Y - startPnt.Y;
57 | var dz = endPnt.Z - startPnt.Z;
58 | Vector2d v = new Vector2d(dx, dy);
59 | var slope = dz / v.Length;
60 |
61 | using (var trans = Ac.StartTransaction())
62 | {
63 | var dimText = (slope * 100).ToString("0.0") + @"%";
64 | AlignedDimension dim = new AlignedDimension(startPnt, endPnt, startPnt, dimText, this.DimStyleId);
65 | dim.LayerId = trans.CurrentLayer.Id;
66 |
67 | trans.AddEntity(dim);
68 | trans.Commit();
69 | }
70 | }
71 |
72 | }
73 |
74 |
75 | }
76 |
--------------------------------------------------------------------------------
/Source/Geo7.App/Tools/TextExpText/ExportTextsCommand.cs:
--------------------------------------------------------------------------------
1 |
2 |
3 | #if AutoCAD
4 | using Autodesk.AutoCAD.Runtime;
5 | using Autodesk.AutoCAD.DatabaseServices;
6 | using Autodesk.AutoCAD.Geometry;
7 | using Autodesk.AutoCAD.ApplicationServices;
8 | using Autodesk.AutoCAD.EditorInput;
9 | using Autodesk.AutoCAD.Windows;
10 | #endif
11 |
12 | #if BricsCAD
13 | using Teigha.Runtime;
14 | using Teigha.DatabaseServices;
15 | using Teigha.Geometry;
16 | using Bricscad.ApplicationServices;
17 | using Bricscad.EditorInput;
18 | using Bricscad.Windows;
19 | #endif
20 |
21 |
22 | using System;
23 | using System.Collections.Generic;
24 | using System.IO;
25 | using System.Linq;
26 | using System.Text;
27 |
28 |
29 | namespace Geo7.Tools
30 | {
31 | public class TextExpTextCommand : AcCommand
32 | {
33 | public TextExpTextCommand()
34 | {
35 | this.DisplayName = AppServices.Strings.ExportTexts;
36 | this.Description = AppServices.Strings.ExportTextsDsc;
37 | //this.SmallImage = Geo7.Properties.Resources.ExportTxt;
38 | }
39 |
40 | protected override void ExecuteCore()
41 | {
42 | var dlg = AppServices.SaveFileDialog;
43 | var storage = dlg.ShowTextLinesWritersDialog(Ac.GetLastFileName("points"));
44 | if (storage == null)
45 | return;
46 |
47 |
48 | using (storage)
49 | {
50 | Ac.SetLastFileName("points", dlg.FilePath);
51 | using (var lTrans = Ac.StartTransaction())
52 | {
53 | var allTexts = lTrans.GetAllEntities().Where(ent => ent.Visible).Where(ent => !ent.TextString.IsEmpty());
54 |
55 | Ac.InitProgress(AppServices.Strings.Saving, allTexts.Count());
56 | foreach (var textEnt in allTexts)
57 | {
58 | if (lTrans.IsDisplayed(textEnt))
59 | {
60 | var x = textEnt.Position.X.ToString(XYCoordinate.DefaultPrecision);
61 | var y = textEnt.Position.Y.ToString(XYCoordinate.DefaultPrecision);
62 | var z = textEnt.Position.Z.ToString(XYCoordinate.DefaultPrecision);
63 | storage.WriteFields(textEnt.TextString, x, y, z);
64 | }
65 | Ac.ProgressStep();
66 | }
67 | Ac.WriteLn(AppServices.Strings.XPointsSaved, storage.LinesWritten);
68 | }
69 | }
70 |
71 | }
72 | }
73 | }
74 |
--------------------------------------------------------------------------------
/Source/Geo7.App/cui/Benchmark.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KubaSzostak/Geo7/f6e4f6f7913b8ec59c5f8151397e6c3a6e9e2d0f/Source/Geo7.App/cui/Benchmark.png
--------------------------------------------------------------------------------
/Source/Geo7.App/cui/ControlPoint.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KubaSzostak/Geo7/f6e4f6f7913b8ec59c5f8151397e6c3a6e9e2d0f/Source/Geo7.App/cui/ControlPoint.png
--------------------------------------------------------------------------------
/Source/Geo7.App/cui/ConvertDgnTxt.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KubaSzostak/Geo7/f6e4f6f7913b8ec59c5f8151397e6c3a6e9e2d0f/Source/Geo7.App/cui/ConvertDgnTxt.png
--------------------------------------------------------------------------------
/Source/Geo7.App/cui/CrossPoint.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KubaSzostak/Geo7/f6e4f6f7913b8ec59c5f8151397e6c3a6e9e2d0f/Source/Geo7.App/cui/CrossPoint.png
--------------------------------------------------------------------------------
/Source/Geo7.App/cui/ElevationPoint.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KubaSzostak/Geo7/f6e4f6f7913b8ec59c5f8151397e6c3a6e9e2d0f/Source/Geo7.App/cui/ElevationPoint.png
--------------------------------------------------------------------------------
/Source/Geo7.App/cui/ExportTxt.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KubaSzostak/Geo7/f6e4f6f7913b8ec59c5f8151397e6c3a6e9e2d0f/Source/Geo7.App/cui/ExportTxt.png
--------------------------------------------------------------------------------
/Source/Geo7.App/cui/FixedPoint.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KubaSzostak/Geo7/f6e4f6f7913b8ec59c5f8151397e6c3a6e9e2d0f/Source/Geo7.App/cui/FixedPoint.png
--------------------------------------------------------------------------------
/Source/Geo7.App/cui/Geo7.cui:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 | Import Points
9 | ^c^cG7ImportPoints
10 |
11 |
12 |
13 |
14 |
15 |
16 | Export Points
17 | ^c^cG7ExportPoints
18 |
19 |
20 |
21 |
22 |
23 |
24 | Point Settings
25 | ^c^cG7PointSettings
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 | Slope
34 | ^c^cG7Slope
35 |
36 |
37 |
38 |
39 |
40 |
41 | Ortho Distance
42 | G7OrthoDist
43 |
44 |
45 |
46 |
47 |
48 |
49 | About Geo7
50 | G7Info
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 | Point by block name
60 | ^c^cG7InsertPoint
61 |
62 |
63 |
64 |
65 |
66 |
67 | Control Point
68 | ^c^cG7InsertPoint;G7-ControlPoint;
69 | Fixed point of known coordinates determined by high-accuracy surveys.
70 |
71 |
72 |
73 |
74 | Benchmark
75 | ^c^cG7InsertPoint;G7-Benchmark;
76 | Permanent marker at a point of determined elevation
77 |
78 |
79 |
80 |
81 |
82 | Fixed Point
83 | ^c^cG7InsertPoint;G7-FixedPoint;
84 |
85 |
86 |
87 |
88 |
89 | Square Point
90 | ^c^cG7InsertPoint;G7-SquarePoint;
91 |
92 |
93 |
94 |
95 |
96 | Mark Point
97 | ^c^cG7InsertPoint;G7-MarkPoint;
98 |
99 |
100 |
101 |
102 |
103 | Measured Point
104 | ^c^cG7InsertPoint;G7-MeasuredPoint;
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 | Elevation Point
113 | ^c^cG7InsertPoint;G7-ElevationPoint;
114 |
115 |
116 |
117 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 | Extract Attributes
126 | ^c^c_attext
127 | Copies data from attributes to a text file
128 |
129 |
130 |
131 |
132 |
133 | Cross Point
134 | ^c^cG7InsertPoint;G7Kamien;
135 |
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 | GEO7
144 | &Geo7
145 |
146 | &Import Points
147 |
150 |
151 |
152 | &Export Points
153 |
156 |
157 |
158 | &Extract Attributes
159 |
162 |
163 |
164 |
165 |
166 |
167 | &Point Settings
168 |
171 |
172 |
173 |
174 |
175 |
176 | &Slope
177 |
180 |
181 |
182 | &Ortho Distance
183 |
186 |
187 |
188 |
189 | &About Geo7
190 |
193 |
194 |
195 |
196 | &Insert Point
197 |
198 | &Point by block name
199 |
202 |
203 |
204 |
205 | &Control Point
206 |
209 |
210 |
211 | &Benchmark
212 |
215 |
216 |
217 | &Fixed Point
218 |
221 |
222 |
223 | &Square Point
224 |
227 |
228 | &Mark Point
229 |
232 |
233 |
234 | &Measured Point
235 |
238 |
239 |
240 | &Elevation Point
241 |
244 |
245 |
246 |
247 |
248 |
249 |
250 |
251 |
252 |
253 |
254 |
255 |
256 |
257 |
258 |
259 |
260 |
261 |
262 |
263 |
264 |
265 |
266 |
267 |
268 |
269 |
270 |
271 |
272 |
273 |
--------------------------------------------------------------------------------
/Source/Geo7.App/cui/MarkPoint.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KubaSzostak/Geo7/f6e4f6f7913b8ec59c5f8151397e6c3a6e9e2d0f/Source/Geo7.App/cui/MarkPoint.png
--------------------------------------------------------------------------------
/Source/Geo7.App/cui/MeasuredPoint.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KubaSzostak/Geo7/f6e4f6f7913b8ec59c5f8151397e6c3a6e9e2d0f/Source/Geo7.App/cui/MeasuredPoint.png
--------------------------------------------------------------------------------
/Source/Geo7.App/cui/OrthoDist.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KubaSzostak/Geo7/f6e4f6f7913b8ec59c5f8151397e6c3a6e9e2d0f/Source/Geo7.App/cui/OrthoDist.png
--------------------------------------------------------------------------------
/Source/Geo7.App/cui/Orto.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KubaSzostak/Geo7/f6e4f6f7913b8ec59c5f8151397e6c3a6e9e2d0f/Source/Geo7.App/cui/Orto.png
--------------------------------------------------------------------------------
/Source/Geo7.App/cui/Slope.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KubaSzostak/Geo7/f6e4f6f7913b8ec59c5f8151397e6c3a6e9e2d0f/Source/Geo7.App/cui/Slope.png
--------------------------------------------------------------------------------
/Source/Geo7.App/cui/SquarePoint.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KubaSzostak/Geo7/f6e4f6f7913b8ec59c5f8151397e6c3a6e9e2d0f/Source/Geo7.App/cui/SquarePoint.png
--------------------------------------------------------------------------------
/Source/Geo7.App/dwg/Geo7.dwg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KubaSzostak/Geo7/f6e4f6f7913b8ec59c5f8151397e6c3a6e9e2d0f/Source/Geo7.App/dwg/Geo7.dwg
--------------------------------------------------------------------------------
/Source/Geo7.Shared/AcCommand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Windows;
6 | using System.Windows.Input;
7 | using System.Drawing;
8 | using System.Windows.Forms.Integration;
9 |
10 |
11 | #if AutoCAD
12 | using Autodesk.AutoCAD.Runtime;
13 | using Autodesk.AutoCAD.DatabaseServices;
14 | using Autodesk.AutoCAD.Geometry;
15 | using Autodesk.AutoCAD.ApplicationServices;
16 | using Autodesk.AutoCAD.EditorInput;
17 | using Autodesk.AutoCAD.Windows;
18 | #endif
19 |
20 | #if BricsCAD
21 | using Teigha.Runtime;
22 | using Teigha.DatabaseServices;
23 | using Teigha.Geometry;
24 | using Bricscad.ApplicationServices;
25 | using Bricscad.EditorInput;
26 | using Bricscad.Windows;
27 | #endif
28 |
29 | namespace System
30 | {
31 |
32 |
33 | public abstract class AcCommand : ICommand //,Teigha.Runtime.ICommandLineCallable
34 | {
35 | private static bool InProgress = false;
36 | protected bool DisplayErrormMessageBox = true;
37 |
38 | public string DisplayName { protected set; get; }
39 | public string Description { protected set; get; }
40 |
41 | public Bitmap SmallImage { protected set; get; }
42 | public Bitmap LargeImage { protected set; get; }
43 |
44 |
45 | public AcCommand()
46 | {
47 | DisplayName = this.GetType().Name;
48 | CommandManager.RequerySuggested += CanExecuteChangedRequerySuggested;
49 | }
50 |
51 | private void CanExecuteChangedRequerySuggested(object sender, EventArgs e)
52 | {
53 | }
54 |
55 | event EventHandler ICommand.CanExecuteChanged
56 | {
57 | //add { Autodesk.AutoCAD.ApplicationServices.Application.Idle += value; }
58 | //remove { Autodesk.AutoCAD.ApplicationServices.Application.Idle -= value; }
59 | add { CommandManager.RequerySuggested += value; }
60 | remove { CommandManager.RequerySuggested -= value; }
61 | }
62 |
63 | bool ICommand.CanExecute(object parameter)
64 | {
65 | return
66 | (Ac.Doc != null)
67 | && (Ac.Db != null)
68 | && (!InProgress)
69 | //&& string.IsNullOrEmpty(Ac.Doc.CommandInProgress)
70 | && CanExecuteCore() ;
71 | }
72 |
73 | void ICommand.Execute(object parameter)
74 | {
75 | if (!(this as ICommand).CanExecute(parameter))
76 | {
77 | Ac.ShowAlertDialog("Cannot execute " + this.DisplayName + " (Possible reason: there is no drawing environment)");
78 | return;
79 | }
80 |
81 | try
82 | {
83 | InProgress = true;
84 | AppServices.Log.Add(this.GetType().FullName + ": Executing...");
85 | //CommandManager.InvalidateRequerySuggested();
86 |
87 | // Requests to modify objects or access AutoCAD can occur in any context, and coming from any number of applications.
88 | // To prevent conflicts with other requests, you are responsible for locking a document before you modify it.
89 | // http://help.autodesk.com/view/ACD/2015/ENU/?guid=GUID-A2CD7540-69C5-4085-BCE8-2A8ACE16BFDD
90 | //using (var docLock = Ac.Doc.LockDocument()) -> Lock document only when needed (Button pressed)
91 |
92 | //using (var uiLock = Ac.StartUserInteraction()) -> Lock user interaction only when needed (Button pressed)
93 | {
94 | ExecuteCore();
95 | //uiLock.End();
96 | }
97 | AppServices.Log.Add(this.GetType().FullName + ": Done.");
98 | }
99 | catch (Exception ex)
100 | {
101 | Ac.WriteError(ex, this.GetType().Name + ".Execute()", this.DisplayName);
102 | if (this.DisplayErrormMessageBox)
103 | Ac.ShowAlertDialog(ex.Message);
104 | }
105 | finally
106 | {
107 | InProgress = false;
108 | Ac.ClearProgress();
109 | }
110 |
111 | var trans = Ac.Db.TransactionManager.TopTransaction;
112 | if (trans != null)
113 | trans.Abort();
114 |
115 | CommandManager.InvalidateRequerySuggested();
116 | }
117 |
118 |
119 | public void Execute()
120 | {
121 | (this as ICommand).Execute(null);
122 | }
123 |
124 | protected abstract void ExecuteCore();
125 |
126 | protected virtual bool CanExecuteCore()
127 | {
128 | return true;
129 | }
130 |
131 | }
132 |
133 | public class AcDelegateCommand : AcCommand
134 | {
135 | public AcDelegateCommand(Action executeMethod, Func canExecuteMethod)
136 | {
137 | _execMethod = executeMethod;
138 | _canExecMethod = canExecuteMethod;
139 | }
140 |
141 | private Action _execMethod;
142 | private Func _canExecMethod;
143 |
144 | protected override bool CanExecuteCore()
145 | {
146 | if (_canExecMethod != null)
147 | return _canExecMethod();
148 | else
149 | return true;
150 | }
151 |
152 | protected override void ExecuteCore()
153 | {
154 | _execMethod();
155 | }
156 | }
157 |
158 |
159 | public abstract class PaletteCommand : AcCommand
160 | {
161 | protected void AddPalette(PaletteSet paletteSet, System.Windows.Controls.Page page)
162 | {
163 | ElementHost host = new ElementHost();
164 | host.AutoSize = true;
165 | host.Dock = System.Windows.Forms.DockStyle.Fill;
166 |
167 | // Page może być tylko w Window lub Frame
168 | System.Windows.Controls.Frame pageFrame = new System.Windows.Controls.Frame();
169 | pageFrame.Content = page;
170 | host.Child = pageFrame;
171 |
172 | paletteSet.Add(page.Title, host);
173 | }
174 | }
175 |
176 | }
177 |
--------------------------------------------------------------------------------
/Source/Geo7.Shared/Classes/ObjectIds.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 |
5 | #if AutoCAD
6 | using Autodesk.AutoCAD.Runtime;
7 | using Autodesk.AutoCAD.DatabaseServices;
8 | using Autodesk.AutoCAD.Geometry;
9 | using Autodesk.AutoCAD.ApplicationServices;
10 | using Autodesk.AutoCAD.EditorInput;
11 | #endif
12 |
13 | #if BricsCAD
14 | using Teigha.Runtime;
15 | using Teigha.DatabaseServices;
16 | using Teigha.Geometry;
17 | using Bricscad.ApplicationServices;
18 | using Bricscad.EditorInput;
19 | #endif
20 |
21 | namespace System
22 | {
23 | public class AcObjectIds : HashSet
24 | {
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Source/Geo7.Shared/Entities/AcAttribute.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 |
7 | #if AutoCAD
8 | using Autodesk.AutoCAD.Runtime;
9 | using Autodesk.AutoCAD.DatabaseServices;
10 | using Autodesk.AutoCAD.Geometry;
11 | using Autodesk.AutoCAD.ApplicationServices;
12 | using Autodesk.AutoCAD.EditorInput;
13 | #endif
14 |
15 | #if BricsCAD
16 | using Teigha.Runtime;
17 | using Teigha.DatabaseServices;
18 | using Teigha.Geometry;
19 | using Bricscad.ApplicationServices;
20 | using Bricscad.EditorInput;
21 | #endif
22 |
23 | namespace System
24 | {
25 |
26 |
27 | public class AcAttributeDef : AcText
28 | {
29 | public AcAttributeDef(AcBlockDef owner, AttributeDefinition entity, AcTransaction trans)
30 | : base(entity, trans)
31 | {
32 | _tag = entity.Tag;
33 | _invisible = entity.Invisible;
34 | this.AttrVisiblePresenter = !_invisible;
35 | Owner = owner;
36 | }
37 |
38 | public AcBlockDef Owner { get; private set; }
39 |
40 | private string _tag;
41 | public string Tag
42 | {
43 | get { return _tag; }
44 | set
45 | {
46 | this.AcObject.Tag = value;
47 | _tag = value;
48 | }
49 | }
50 |
51 | private bool _invisible;
52 | public bool Invisible
53 | {
54 | get { return _invisible; }
55 | set
56 | {
57 | this.AcObject.Invisible = value;
58 | _invisible = value;
59 | this.AttrVisiblePresenter = !value;
60 | }
61 | }
62 |
63 | ///
64 | /// Use it for binding to controls only
65 | ///
66 | public bool AttrVisiblePresenter { get; set; }
67 |
68 | public override string ToString()
69 | {
70 | return Owner.Name + "." + Tag;
71 | }
72 | }
73 |
74 |
75 |
76 | public class AcAttributeRef : AcText
77 | {
78 | public AcAttributeRef(AcBlockRef owner, AttributeReference entity, AcTransaction trans)
79 | : base(entity, trans)
80 | {
81 | _tag = entity.Tag;
82 | _invisible = entity.Invisible;
83 | Owner = owner;
84 | }
85 |
86 | public AcBlockRef Owner { get; private set; }
87 |
88 | private string _tag;
89 | public string Tag
90 | {
91 | get { return _tag; }
92 | set {
93 | this.AcObject.Tag = value;
94 | _tag = value;
95 | }
96 | }
97 |
98 | private bool _invisible;
99 | public bool Invisible
100 | {
101 | get { return _invisible; }
102 | set
103 | {
104 | this.AcObject.Invisible = value;
105 | _invisible = value;
106 | }
107 | }
108 |
109 | public override string ToString()
110 | {
111 | return Owner.Name + "." + Tag;
112 | }
113 | }
114 |
115 |
116 | public abstract class AcKeyedCollection : System.Collections.ObjectModel.KeyedCollection
117 | {
118 | public TVal Find(string key)
119 | {
120 | var res = default(TVal);
121 |
122 | if (this.Dictionary == null)
123 | return res;
124 |
125 | if (string.IsNullOrEmpty(key as string))
126 | return res;
127 |
128 | key = key.ToLowerInvariant();
129 | if (this.Dictionary.TryGetValue(key, out res))
130 | return res;
131 | else
132 | return default(TVal);
133 | }
134 |
135 | public string FindFirstKey(params string[] keys)
136 | {
137 | foreach (var item in this)
138 | {
139 | foreach (var key in keys)
140 | {
141 | var itemKey = this.GetKeyForItem(item);
142 |
143 | if (string.Equals(key, itemKey, StringComparison.InvariantCultureIgnoreCase))
144 | {
145 | return itemKey;
146 | }
147 | }
148 | }
149 | return null;
150 | }
151 |
152 | }
153 |
154 | public class AcAttributeDefCollection : AcKeyedCollection
155 | {
156 | protected override string GetKeyForItem(AcAttributeDef item)
157 | {
158 | return item.Tag.ToLowerInvariant();
159 | }
160 | }
161 |
162 | public class AcAttributeRefCollection : AcKeyedCollection
163 | {
164 | protected override string GetKeyForItem(AcAttributeRef item)
165 | {
166 | return item.Tag.ToLowerInvariant();
167 | }
168 | }
169 |
170 | }
171 |
--------------------------------------------------------------------------------
/Source/Geo7.Shared/Entities/AcBlock.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | #if AutoCAD
7 | using Autodesk.AutoCAD.Runtime;
8 | using Autodesk.AutoCAD.DatabaseServices;
9 | using Autodesk.AutoCAD.Geometry;
10 | using Autodesk.AutoCAD.ApplicationServices;
11 | using Autodesk.AutoCAD.EditorInput;
12 | #endif
13 |
14 | #if BricsCAD
15 | using Teigha.Runtime;
16 | using Teigha.DatabaseServices;
17 | using Teigha.Geometry;
18 | using Bricscad.ApplicationServices;
19 | using Bricscad.EditorInput;
20 | #endif
21 |
22 |
23 | namespace System
24 | {
25 |
26 |
27 | public class AcBlockDef : AcDbObject
28 | {
29 | public AcBlockDef(BlockTableRecord obj, AcTransaction trans)
30 | : base(obj, trans)
31 | {
32 | this.Name = obj.Name;
33 | this.HasAttributes = obj.HasAttributeDefinitions;
34 |
35 | this.IsAnonymous = obj.IsAnonymous;
36 | this.IsLayout = obj.IsLayout;
37 |
38 | var blockRefIds = obj.GetBlockReferenceIds(true, true);
39 | this.BlockCount = blockRefIds.Count;
40 | this.HasReferences = blockRefIds.Count > 0;
41 |
42 | InitAttributeInfos(trans);
43 | }
44 |
45 | public string Name { get; private set; }
46 | public bool IsAnonymous { get; private set; }
47 | public bool IsLayout { get; private set; }
48 | public bool HasReferences { get; private set; }
49 | public bool HasAttributes { get; private set; }
50 | public int BlockCount { get; private set; }
51 |
52 | public string IdAttribute { get; private set; }
53 | public string HeightAttribute { get; private set; }
54 | public string CodeAttribute { get; private set; }
55 |
56 | public IEnumerable GetBlocks(AcTransaction trans)
57 | {
58 | var blockRefIds = this.GetAcObject(trans).GetBlockReferenceIds(true, true);
59 |
60 | foreach (ObjectId id in blockRefIds)
61 | {
62 | yield return new AcBlockRef(id, trans);
63 | }
64 | }
65 |
66 | public AcBlockRef FirstBlock(AcTransaction trans)
67 | {
68 | var blockRefIds = this.GetAcObject(trans).GetBlockReferenceIds(true, true);
69 |
70 | if (blockRefIds.Count > 0)
71 | return new AcBlockRef(blockRefIds[0], trans);
72 | else
73 | return null;
74 | }
75 |
76 | public AcBlockRef AddBlockRef(Point3d pos, AcTransaction trans)
77 | {
78 |
79 | //Create the block reference...
80 | var blockRef = new BlockReference(pos, this.ObjectId);
81 | blockRef.SetDatabaseDefaults(); // Default/Active layer, color, ...
82 | trans.AddEntity(blockRef); // Do it before blockRef.AttributeCollection.AppendAttribute(attRef);
83 |
84 | var attrRefs = new List();
85 | foreach (var attrDef in this.Attributes)
86 | {
87 | // this BlockDef could be initialized throught other (closed) Transaction, the same with this.Attributes
88 | var attDefObj = attrDef.GetAcObject(trans); // trans.GetObject(attrDef.ObjectId); // attrDef.AcObject;
89 | var attRef = new AttributeReference();
90 | attRef.SetAttributeFromBlock(attDefObj, blockRef.BlockTransform);
91 | attRef.SetDatabaseDefaults();
92 |
93 | if (!attDefObj.Constant)
94 | {
95 | attRef.TextString = attDefObj.TextString;
96 | }
97 |
98 | blockRef.AttributeCollection.AppendAttribute(attRef);
99 | trans.AddNewlyCreatedDBObject(attRef, true);
100 | attrRefs.Add(attRef);
101 | }
102 |
103 | return new AcBlockRef(blockRef, trans, attrRefs);
104 | }
105 |
106 |
107 |
108 | private AcAttributeDefCollection attrDict = new AcAttributeDefCollection();
109 | public ICollection Attributes
110 | {
111 | get { return attrDict; }
112 | }
113 |
114 | public AcAttributeDef GetAttribute(string tag)
115 | {
116 | return attrDict.Find(tag);
117 | }
118 |
119 | private void InitAttributeInfos(AcTransaction trans)
120 | {
121 | string firstAttr = null;
122 |
123 | foreach (ObjectId id in this.AcObject)
124 | {
125 | var blockSubEntity = trans.GetObject(id);
126 | var blockAttrDef = blockSubEntity as AttributeDefinition;
127 | if ((blockAttrDef != null) && !string.IsNullOrEmpty(blockAttrDef.Tag))
128 | {
129 | if (attrDict.Find(blockAttrDef.Tag) != null)
130 | {
131 | AppServices.Log.Add(this.GetType().Name + "." + nameof(InitAttributeInfos) + "() Warning: ");
132 | AppServices.Log.Add(" Block " + this.Name + "." +blockAttrDef.Tag+" attribute already exists");
133 | //Ac.WriteLn("Geo7 warning: Block " + this.Name + "." + blockAttrDef.Tag + " attribute already exists");
134 | }
135 | else
136 | {
137 | var attr = new AcAttributeDef(this, blockAttrDef, trans);
138 | attrDict.Add(attr);
139 | if (firstAttr == null)
140 | firstAttr = attr.Tag;
141 | }
142 | }
143 | else
144 | {
145 | blockSubEntity.Dispose();
146 | }
147 | }
148 |
149 | this.IdAttribute = attrDict.FindFirstKey(Ac.IdAttributeTags);
150 | if (this.IdAttribute == null)
151 | {
152 | this.IdAttribute = firstAttr;
153 | }
154 |
155 | this.HeightAttribute = attrDict.FindFirstKey(Ac.HeightAttributeTags);
156 | this.CodeAttribute = attrDict.FindFirstKey(Ac.CodeAttributeTags);
157 | }
158 |
159 |
160 |
161 | }
162 |
163 |
164 | public class AcBlockRef : AcEntity
165 | {
166 |
167 | public AcBlockRef(BlockReference entity, AcTransaction trans)
168 | : base(entity, trans)
169 | {
170 | this.Name = entity.Name;
171 | this.BlockDef = trans.GetBlockDef(this.Name);
172 | this.HasAttributes = this.BlockDef.HasAttributes;
173 | _position = entity.Position;
174 | _scale = entity.ScaleFactors.X;
175 | }
176 |
177 |
178 | public AcBlockRef(BlockReference entity, AcTransaction trans, IEnumerable attributes)
179 | : this(entity, trans)
180 | {
181 | foreach (var attr in attributes)
182 | {
183 | attrDict.Add(new AcAttributeRef(this, attr, trans));
184 | }
185 | InitAttributes();
186 | }
187 |
188 | public AcBlockRef(ObjectId id, AcTransaction trans)
189 | : this(trans.GetObject(id), trans)
190 | {
191 | var entity = this.AcObject;
192 | foreach (ObjectId attrId in entity.AttributeCollection)
193 | {
194 | var attr = trans.GetObject(attrId);
195 | attrDict.Add(new AcAttributeRef(this, attr, trans));
196 | }
197 | InitAttributes();
198 | }
199 |
200 | private AcAttributeRefCollection attrDict = new AcAttributeRefCollection();
201 | public ICollection Attributes
202 | {
203 | get { return attrDict; }
204 | }
205 |
206 | public AcAttributeRef GetAttribute(string tag)
207 | {
208 | if (string.IsNullOrEmpty(tag))
209 | return null;
210 |
211 | return attrDict.Find(tag.ToLower());
212 | }
213 |
214 | private void InitAttributes()
215 | {
216 | this.IdAttribute = this.GetAttribute(this.BlockDef.IdAttribute);
217 | this.HeightAttribute = this.GetAttribute(this.BlockDef.HeightAttribute);
218 | this.CodeAttribute = this.GetAttribute(this.BlockDef.CodeAttribute);
219 | }
220 |
221 |
222 | public AcBlockDef BlockDef { get; private set; }
223 | public string Name { get; private set; }
224 | public bool HasAttributes { get; private set; }
225 |
226 | public AcAttributeRef IdAttribute { get; private set; }
227 | public AcAttributeRef HeightAttribute { get; private set; }
228 | public AcAttributeRef CodeAttribute { get; private set; }
229 |
230 | public void SetIdAttribute(string text)
231 | {
232 | if (IdAttribute != null)
233 | IdAttribute.TextString = text;
234 | }
235 |
236 | private Point3d _position;
237 | public Point3d Position
238 | {
239 | get { return _position; }
240 | set
241 | {
242 | this.AcObject.Position = value;
243 | _position = value;
244 | }
245 | }
246 |
247 | public void ResetBlock()
248 | {
249 | this.AcObject.ResetBlock();
250 | }
251 |
252 | private double _scale;
253 | public double Scale
254 | {
255 | get { return _scale; }
256 | set
257 | {
258 |
259 | foreach (var attr in this.Attributes)
260 | {
261 | attr.UpgradeOpen();
262 | }
263 |
264 | double scaleFactor = value / this.AcObject.ScaleFactors.X;
265 | var scalingMtx = (Matrix3d.Scaling(scaleFactor, Position));
266 | this.AcObject.TransformBy(scalingMtx); // It scales block and attributes
267 | _scale = value;
268 |
269 | // After TransformBy() all attributes have IsWriteEnabled == true;
270 | foreach (var attr in this.Attributes)
271 | {
272 | attr.UpgradeOpen();
273 | }
274 | }
275 | }
276 |
277 | }
278 | }
279 |
--------------------------------------------------------------------------------
/Source/Geo7.Shared/Entities/AcCurve.cs:
--------------------------------------------------------------------------------
1 |
2 | #if AutoCAD
3 | using Autodesk.AutoCAD.Runtime;
4 | using Autodesk.AutoCAD.DatabaseServices;
5 | using Autodesk.AutoCAD.Geometry;
6 | using Autodesk.AutoCAD.ApplicationServices;
7 | using Autodesk.AutoCAD.EditorInput;
8 | #endif
9 |
10 | #if BricsCAD
11 | using Teigha.Runtime;
12 | using Teigha.DatabaseServices;
13 | using Teigha.Geometry;
14 | using Bricscad.ApplicationServices;
15 | using Bricscad.EditorInput;
16 | #endif
17 |
18 |
19 | using System;
20 | using System.Collections.Generic;
21 | using System.Text;
22 |
23 | namespace System
24 | {
25 | public class AcCurve : AcEntity where T:Curve
26 | {
27 |
28 | public AcCurve(T entity, AcTransaction trans)
29 | : base(entity, trans)
30 | {
31 | Area = entity.Area;
32 | Closed = entity.Closed;
33 | IsPeriodic = entity.IsPeriodic;
34 | _startPoint = entity.StartPoint;
35 | _endPoint = entity.EndPoint;
36 | }
37 |
38 | public double Area { get; private set; }
39 | public bool Closed { get; private set; }
40 | public virtual bool IsPeriodic { get; private set; }
41 |
42 |
43 | private Point3d _startPoint;
44 | public Point3d StartPoint
45 | {
46 | get { return _startPoint; }
47 | set
48 | {
49 | this.AcObject.StartPoint = value;
50 | _startPoint = value;
51 | }
52 | }
53 |
54 | private Point3d _endPoint;
55 | public virtual Point3d EndPoint
56 | {
57 | get { return _endPoint; }
58 | set
59 | {
60 | this.AcObject.EndPoint = value;
61 | _endPoint = value;
62 | }
63 | }
64 | }
65 |
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/Source/Geo7.Shared/Entities/AcEntity.cs:
--------------------------------------------------------------------------------
1 |
2 | #if AutoCAD
3 | using Autodesk.AutoCAD.Runtime;
4 | using Autodesk.AutoCAD.DatabaseServices;
5 | using Autodesk.AutoCAD.Geometry;
6 | using Autodesk.AutoCAD.ApplicationServices;
7 | using Autodesk.AutoCAD.EditorInput;
8 | #endif
9 |
10 | #if BricsCAD
11 | using Teigha.Runtime;
12 | using Teigha.DatabaseServices;
13 | using Teigha.Geometry;
14 | using Bricscad.ApplicationServices;
15 | using Bricscad.EditorInput;
16 | using System.ComponentModel;
17 | #endif
18 |
19 | using System;
20 | using System.Collections.Generic;
21 | using System.Linq;
22 | using System.Text;
23 |
24 |
25 | namespace System
26 | {
27 |
28 | public class AcDisposable : IDisposable
29 | {
30 | bool disposed = false;
31 | protected virtual void Dispose(bool disposing)
32 | {
33 | if (disposed)
34 | return;
35 |
36 | if (disposing)
37 | {
38 | //DisposeAcObject();
39 | }
40 |
41 | this.disposed = true;
42 | }
43 |
44 | public void Dispose()
45 | {
46 | Dispose(true);
47 | GC.SuppressFinalize(this);
48 | }
49 |
50 | }
51 |
52 | public class AcDbObject //: INotifyPropertyChanged
53 | {
54 | //public event PropertyChangedEventHandler PropertyChanged;
55 | }
56 |
57 | public class AcDbObject : AcDbObject where TObject : DBObject
58 | {
59 | public AcDbObject(TObject obj, AcTransaction trans)
60 | {
61 | this.ObjectId = obj.ObjectId;
62 | this.acObject = obj;
63 | }
64 |
65 | public ObjectId ObjectId { get; private set; }
66 |
67 | private TObject acObject = null;
68 | protected TObject AcObject
69 | {
70 | get
71 | {
72 | if ((this.acObject == null) || (this.acObject.IsDisposed))
73 | throw new InvalidOperationException(this.GetType().Name + ".AcObject is inaccessible.");
74 | return acObject;
75 | }
76 | }
77 |
78 | public TObject GetAcObject(AcTransaction trans)
79 | {
80 | if ((this.acObject != null) && (!this.acObject.IsDisposed))
81 | return this.acObject;
82 |
83 | return trans.GetObject(this.ObjectId);
84 | }
85 |
86 | }
87 |
88 |
89 |
90 | public class AcEntity :AcDbObject where TEntity : Entity
91 | {
92 | public AcEntity(TEntity entity, AcTransaction trans)
93 | : base(entity, trans)
94 | {
95 | _layer = entity.Layer;
96 | this.Displayed = trans.IsDisplayed(entity);
97 | }
98 |
99 | private string _layer;
100 | public string Layer
101 | {
102 | get
103 | {
104 | return _layer;
105 | }
106 | set
107 | {
108 | this.AcObject.Layer = value;
109 | _layer = value;
110 | }
111 | }
112 |
113 | public bool Displayed { get; private set; }
114 |
115 | public void UpgradeOpen()
116 | {
117 | this.AcObject.UpgradeOpen();
118 | }
119 | }
120 | }
121 |
--------------------------------------------------------------------------------
/Source/Geo7.Shared/Entities/AcExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Text;
4 | using System.Linq;
5 | using System.Data.Linq;
6 | using Geo7;
7 |
8 |
9 | #if AutoCAD
10 | using Autodesk.AutoCAD.Runtime;
11 | using Autodesk.AutoCAD.DatabaseServices;
12 | using Autodesk.AutoCAD.Geometry;
13 | using Autodesk.AutoCAD.Colors;
14 | using Autodesk.AutoCAD.ApplicationServices;
15 | using Autodesk.AutoCAD.Windows;
16 | using Autodesk.AutoCAD.EditorInput;
17 |
18 | using AcApp = Autodesk.AutoCAD.ApplicationServices.Application;
19 | #endif
20 |
21 | #if BricsCAD
22 | using Teigha.Runtime;
23 | using Teigha.DatabaseServices;
24 | using Teigha.Geometry;
25 | using Teigha.Colors;
26 | using Bricscad.ApplicationServices;
27 | using Bricscad.Windows;
28 | using Bricscad.EditorInput;
29 |
30 | using AcApp = Bricscad.ApplicationServices.Application;
31 | #endif
32 |
33 | namespace System
34 | {
35 |
36 |
37 | public static class AcPolylineEx
38 | {
39 | public static void AddVertex(this Polyline polyline, Point3d point)
40 | {
41 | //polyline.NumberOfVertices
42 | polyline.AddVertex(point.Convert2d());
43 | }
44 |
45 | public static void AddVertex(this Polyline polyline, Point2d point)
46 | {
47 | //polyline.NumberOfVertices
48 | polyline.AddVertexAt(polyline.NumberOfVertices, point, 0, 0, 0);
49 | }
50 |
51 | public static List GetPoints2d(this Polyline polyline)
52 | {
53 | List res = new List();
54 | for (int i = 0; i < polyline.NumberOfVertices; i++)
55 | {
56 | res.Add(polyline.GetPoint2dAt(i));
57 | }
58 | return res;
59 | }
60 |
61 | public static List GetPoints3d(this Polyline polyline)
62 | {
63 | List res = new List();
64 | for (int i = 0; i < polyline.NumberOfVertices; i++)
65 | {
66 | res.Add(polyline.GetPoint3dAt(i));
67 | }
68 | return res;
69 | }
70 |
71 | public static bool IsInside(this Polyline polyline, Point3d point)
72 | {
73 | var ray = new Ray();
74 | ray.BasePoint = point;
75 | ray.SecondPoint = new Point3d(point.X+100, point.Y, point.Z);
76 | Point3dCollection pntColl = new Point3dCollection();
77 | //polyline.IntersectWith(ray, Intersect.ExtendThis, pntColl, 0, 0);
78 | polyline.IntersectWith(ray, Intersect.ExtendThis, pntColl, IntPtr.Zero, IntPtr.Zero);
79 |
80 | return (pntColl.Count % 2) != 0;
81 | }
82 |
83 |
84 | }
85 |
86 | public static class AcPointEx
87 | {
88 | public static bool Equals(this Point2d thisPoint, Point2d anotherPoint)
89 | {
90 | return thisPoint.Id() == anotherPoint.Id();
91 | }
92 |
93 | public static string Id(this Point2d p, string precisionFormat)
94 | {
95 | return "[" + p.X.ToString(precisionFormat) + ";" + p.Y.ToString(precisionFormat) + "]";
96 | }
97 |
98 | public static string Id(this Point2d p)
99 | {
100 | return p.Id(Ac.LinearPrecisionFormat);
101 | }
102 |
103 | public static Point2d Convert2d(this Point3d point)
104 | {
105 | return new Point2d(point.X, point.Y);
106 |
107 | }
108 |
109 | public static Point3d ToPoint3d(this XyzPoint pt, bool ignoreZ = false)
110 | {
111 | if (ignoreZ)
112 | return new Point3d(pt.X, pt.Y, 0.0);
113 | else
114 | return new Point3d(pt.X, pt.Y, pt.Z);
115 | }
116 |
117 | public static Point3d ToPoint3dPlanar(this Point3d pt)
118 | {
119 | return new Point3d(pt.X, pt.Y, 0.0);
120 | }
121 |
122 | public static XyzPoint ToXyzPoint(this Point3d pt)
123 | {
124 | return new XyzPoint() { X = pt.X, Y = pt.Y, Z = pt.Y };
125 | }
126 |
127 | public static XyzPoint ToXyzPoint(this Point2d pt)
128 | {
129 | return new XyzPoint() { X = pt.X, Y = pt.Y};
130 | }
131 |
132 |
133 | }
134 |
135 | public static class BlockEx
136 | {
137 | }
138 |
139 | public static class EditorEx
140 | {
141 | public static bool IsOK(this PromptResult prompt)
142 | {
143 | return prompt.Status == PromptStatus.OK;
144 | }
145 |
146 | public static bool IsCancel(this PromptResult prompt)
147 | {
148 | return prompt.Status == PromptStatus.Cancel;
149 | }
150 |
151 | public static PromptPointOptions GetPromptPointOptions(this Editor ed, string prompt, Point3d basePoint, bool UseDashedLine)
152 | {
153 | var res = new PromptPointOptions(prompt);
154 | res.BasePoint = basePoint;
155 | res.UseBasePoint = true;
156 | res.UseDashedLine = UseDashedLine;
157 |
158 | return res;
159 | }
160 |
161 |
162 | public static PromptStringOptions GetPromptStringOptions(this Editor ed, string prompt, string defaultValue, bool allowSpaces, bool useDefaultValue)
163 | {
164 | var res = new PromptStringOptions(prompt);
165 | res.DefaultValue = defaultValue;
166 | res.AllowSpaces = allowSpaces;
167 | res.UseDefaultValue = useDefaultValue;
168 |
169 | return res;
170 | }
171 |
172 | public static SelectionFilter GetBlockSelectionFilter(this Editor ed, params string[] blockNames)
173 | {
174 | var values = new TypedValue[]
175 | {
176 | Ac.GetTypedValue(DxfCode.Start, "INSERT" ),
177 | Ac.GetTypedValue(DxfCode.BlockName, blockNames.Join(",") )
178 | };
179 | return new SelectionFilter(values);
180 | }
181 |
182 | public static AcObjectIds GetBlocks(this Editor ed, params string[] blockNames)
183 | {
184 | //PromptEntityOptions peo = new PromptEntityOptions("Select blocks: ");
185 | //var res = Editor.GetEntity(peo);
186 |
187 | var res = new AcObjectIds();
188 |
189 | var filter = GetBlockSelectionFilter(ed, blockNames);
190 | PromptSelectionOptions promptOpt = new PromptSelectionOptions();
191 | promptOpt.MessageForAdding = "Select blocks:";
192 |
193 | PromptSelectionResult selRes = Ac.Editor.GetSelection(promptOpt, filter);
194 | if (selRes.Status == PromptStatus.OK)
195 | res.AddItems(selRes.Value.GetObjectIds());
196 | return res;
197 | }
198 |
199 | public static AcObjectIds GetAllBlocks(this Editor ed, string blockName)
200 | {
201 | var res = new AcObjectIds();
202 | var filter = GetBlockSelectionFilter(ed, blockName);
203 | var selRes = Ac.Editor.SelectAll(filter);
204 | if (selRes.Status == PromptStatus.OK)
205 | res.AddItems(selRes.Value.GetObjectIds());
206 | return res;
207 | }
208 |
209 | public static ObjectId GetLine(this Editor ed, string prompt)
210 | {
211 | var res = ObjectId.Null;
212 |
213 | var promptOpts = new PromptEntityOptions(prompt);
214 | promptOpts.SetRejectMessage(prompt);
215 | promptOpts.AddAllowedClass(typeof(Polyline), true);
216 | promptOpts.AddAllowedClass(typeof(Line), true);
217 |
218 | var promptRes = ed.GetEntity(promptOpts);
219 |
220 | if (promptRes.Status == PromptStatus.OK)
221 | return promptRes.ObjectId;
222 | else
223 | return ObjectId.Null;
224 | }
225 |
226 | public static ObjectId GetPolyline(this Editor ed, string prompt)
227 | {
228 | var res = ObjectId.Null;
229 |
230 | var promptOpts = new PromptEntityOptions(prompt);
231 | promptOpts.SetRejectMessage(prompt);
232 | promptOpts.AddAllowedClass(typeof(Polyline), true);
233 |
234 | var promptRes = ed.GetEntity(promptOpts);
235 |
236 | if (promptRes.Status == PromptStatus.OK)
237 | return promptRes.ObjectId;
238 | else
239 | return ObjectId.Null;
240 | }
241 | }
242 | }
243 |
--------------------------------------------------------------------------------
/Source/Geo7.Shared/Entities/AcLine.cs:
--------------------------------------------------------------------------------
1 |
2 | #if AutoCAD
3 | using Autodesk.AutoCAD.Runtime;
4 | using Autodesk.AutoCAD.DatabaseServices;
5 | using Autodesk.AutoCAD.Geometry;
6 | using Autodesk.AutoCAD.ApplicationServices;
7 | using Autodesk.AutoCAD.EditorInput;
8 | #endif
9 |
10 | #if BricsCAD
11 | using Teigha.Runtime;
12 | using Teigha.DatabaseServices;
13 | using Teigha.Geometry;
14 | using Bricscad.ApplicationServices;
15 | using Bricscad.EditorInput;
16 | #endif
17 |
18 |
19 | using System;
20 | using System.Collections.Generic;
21 | using System.Text;
22 |
23 | namespace System
24 | {
25 | public class AcLine : AcCurve where T : Line
26 | {
27 | public AcLine(T entity, AcTransaction trans)
28 | : base(entity, trans)
29 | {
30 | Angle = entity.Angle;
31 | Delta = entity.Delta;
32 | Length = entity.Length;
33 |
34 | _normal = entity.Normal;
35 | _thickness = entity.Thickness;
36 | }
37 |
38 |
39 | public double Angle { get; private set; }
40 | public Vector3d Delta { get; private set; }
41 | public double Length { get; private set; }
42 |
43 | private Vector3d _normal;
44 | public Vector3d Normal
45 | {
46 | get { return _normal; }
47 | set
48 | {
49 | this.AcObject.Normal = value;
50 | _normal = value;
51 | }
52 | }
53 |
54 | private double _thickness;
55 | public double Thickness
56 | {
57 | get { return _thickness; }
58 | set
59 | {
60 | this.AcObject.Thickness = value;
61 | _thickness = value;
62 | }
63 | }
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/Source/Geo7.Shared/Entities/AcPolyline.cs:
--------------------------------------------------------------------------------
1 |
2 | #if AutoCAD
3 | using Autodesk.AutoCAD.Runtime;
4 | using Autodesk.AutoCAD.DatabaseServices;
5 | using Autodesk.AutoCAD.Geometry;
6 | using Autodesk.AutoCAD.ApplicationServices;
7 | using Autodesk.AutoCAD.EditorInput;
8 | #endif
9 |
10 | #if BricsCAD
11 | using Teigha.Runtime;
12 | using Teigha.DatabaseServices;
13 | using Teigha.Geometry;
14 | using Bricscad.ApplicationServices;
15 | using Bricscad.EditorInput;
16 | #endif
17 |
18 |
19 | using System;
20 | using System.Collections.Generic;
21 | using System.Text;
22 |
23 |
24 | namespace System
25 | {
26 | public class AcPolyline : AcCurve where T : Polyline
27 | {
28 | public AcPolyline(T entity, AcTransaction trans)
29 | : base(entity, trans)
30 | {
31 | IsOnlyLines = entity.IsOnlyLines;
32 | Length = entity.Length;
33 | NumberOfVertices = entity.NumberOfVertices;
34 |
35 | _constantWidth = entity.ConstantWidth;
36 | _elevation = entity.Elevation;
37 | _normal = entity.Normal;
38 | _plinegen = entity.Plinegen;
39 | _thickness = entity.Thickness;
40 | }
41 |
42 |
43 | public bool IsOnlyLines { get; }
44 | public double Length { get; }
45 | public int NumberOfVertices { get; private set; }
46 |
47 | private double _constantWidth;
48 | public double ConstantWidth
49 | {
50 | get { return _constantWidth; }
51 | set
52 | {
53 | this.AcObject.ConstantWidth = value;
54 | _constantWidth = value;
55 | }
56 | }
57 |
58 | private double _elevation;
59 | public double Elevation
60 | {
61 | get { return _elevation; }
62 | set
63 | {
64 | this.AcObject.Elevation = value;
65 | _elevation = value;
66 | }
67 | }
68 |
69 | private Vector3d _normal;
70 | public Vector3d Normal
71 | {
72 | get { return _normal; }
73 | set
74 | {
75 | this.AcObject.Normal = value;
76 | _normal = value;
77 | }
78 | }
79 |
80 | private bool _plinegen;
81 | public bool Plinegen
82 | {
83 | get { return _plinegen; }
84 | set
85 | {
86 | this.AcObject.Plinegen = value;
87 | _plinegen = value;
88 | }
89 | }
90 |
91 | private double _thickness;
92 | public double Thickness
93 | {
94 | get { return _thickness; }
95 | set
96 | {
97 | this.AcObject.Thickness = value;
98 | _thickness = value;
99 | }
100 | }
101 |
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/Source/Geo7.Shared/Entities/AcText.cs:
--------------------------------------------------------------------------------
1 |
2 | #if AutoCAD
3 | using Autodesk.AutoCAD.Runtime;
4 | using Autodesk.AutoCAD.DatabaseServices;
5 | using Autodesk.AutoCAD.Geometry;
6 | using Autodesk.AutoCAD.ApplicationServices;
7 | using Autodesk.AutoCAD.EditorInput;
8 | #endif
9 |
10 | #if BricsCAD
11 | using Teigha.Runtime;
12 | using Teigha.DatabaseServices;
13 | using Teigha.Geometry;
14 | using Bricscad.ApplicationServices;
15 | using Bricscad.EditorInput;
16 | using System.ComponentModel;
17 | #endif
18 |
19 | using System;
20 | using System.Collections.Generic;
21 | using System.Linq;
22 | using System.Text;
23 |
24 | namespace System
25 | {
26 | public class AcText : AcEntity where T : DBText
27 | {
28 | public AcText(T entity, AcTransaction trans)
29 | : base(entity, trans)
30 | {
31 | mPosition = entity.Position;
32 | mRotation = entity.Rotation;
33 | mTextString = entity.TextString;
34 | mHorizontalMode = entity.HorizontalMode;
35 | mVerticalMode = entity.VerticalMode;
36 | }
37 |
38 |
39 | private Point3d mPosition;
40 | public Point3d Position
41 | {
42 | get { return mPosition; }
43 | set
44 | {
45 | this.AcObject.Position = value;
46 | mPosition = value;
47 | }
48 | }
49 |
50 | public double mRotation;
51 | public double Rotation
52 | {
53 | get { return mRotation; }
54 | set
55 | {
56 | this.AcObject.Rotation = value;
57 | mRotation = value;
58 | }
59 | }
60 |
61 | private string mTextString;
62 | public string TextString
63 | {
64 | get { return mTextString; }
65 | set
66 | {
67 | this.AcObject.TextString = value;
68 | mTextString = value;
69 | }
70 | }
71 |
72 |
73 | private TextHorizontalMode mHorizontalMode;
74 | public TextHorizontalMode HorizontalMode
75 | {
76 | get { return mHorizontalMode; }
77 | set
78 | {
79 | this.AcObject.HorizontalMode = value;
80 | mHorizontalMode = value;
81 | }
82 | }
83 |
84 | private TextVerticalMode mVerticalMode;
85 | public TextVerticalMode VerticalMode
86 | {
87 | get { return mVerticalMode; }
88 | set
89 | {
90 | this.AcObject.VerticalMode = value;
91 | mVerticalMode = value;
92 | }
93 | }
94 | }
95 |
96 | public class AcText : AcText
97 | {
98 | public AcText(DBText entity, AcTransaction trans)
99 | : base(entity, trans)
100 | {
101 | }
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/Source/Geo7.Shared/Geo7.Shared.projitems:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | $(MSBuildAllProjects);$(MSBuildThisFileFullPath)
5 | true
6 | c5b77044-db60-4861-bab6-9b5ea1e4e1a9
7 |
8 |
9 | Geo7
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
--------------------------------------------------------------------------------
/Source/Geo7.Shared/Geo7.Shared.shproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | c5b77044-db60-4861-bab6-9b5ea1e4e1a9
5 | 14.0
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/Source/Geo7.Shared/Utils/DwgDb.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.IO;
5 |
6 |
7 | #if AutoCAD
8 | using Autodesk.AutoCAD.Runtime;
9 | using Autodesk.AutoCAD.DatabaseServices;
10 | using AcApp = Autodesk.AutoCAD.ApplicationServices.Application;
11 | #endif
12 |
13 | #if BricsCAD
14 | using Teigha.Runtime;
15 | using Teigha.DatabaseServices;
16 | using AcApp = Bricscad.ApplicationServices.Application;
17 | #endif
18 |
19 | namespace System
20 | {
21 |
22 | public class AcDwgDb
23 | {
24 |
25 | public static Database Open(string dwgFilePath, FileShare fileShare)
26 | {
27 | if (!File.Exists(dwgFilePath))
28 | throw new FileNotFoundException("File not found: '" + dwgFilePath + "'", dwgFilePath);
29 |
30 | var db = new Database(false, true);
31 | db.ReadDwgFile(dwgFilePath, fileShare, true, "");
32 |
33 | return db;
34 | }
35 |
36 | public static Database OpenReadonly(string dwgFilePath)
37 | {
38 | return Open(dwgFilePath, FileShare.Read);
39 | }
40 |
41 | public static List GetBlockNames(string dwgFile, bool onlyBlocksWithAttributes)
42 | {
43 | using (var db = OpenReadonly(dwgFile))
44 | using (var trans = db.StartAcTransaction(false))
45 | {
46 | var blocks = trans.BlockDefs.AsEnumerable();
47 | if (onlyBlocksWithAttributes)
48 | blocks = blocks.Where(b => b.HasAttributes);
49 | return blocks.OrderBy(b=>b.Name).Select(b => b.Name).ToList();
50 | }
51 | }
52 |
53 |
54 | private static ObjectId ImportMissedRecord(SymbolTable srcTable, string key, SymbolTable destTable)
55 | {
56 | if (string.IsNullOrEmpty(key))
57 | throw new ArgumentNullException("ImportMissedRecord(" + srcTable.GetType().Name + ".key)");
58 |
59 | if (destTable.Has(key)) // It is not missed
60 | return destTable[key];
61 |
62 | if (!srcTable.Has(key))
63 | throw new KeyNotFoundException("'" + key + "' not found in " + srcTable.GetType().Name);
64 |
65 |
66 | Ac.WriteLn("Updating " + destTable.GetType().Name + "... "); // Updating BlockTable...
67 |
68 | using (var mapping = new IdMapping())
69 | using (var sourceIds = new ObjectIdCollection())
70 | {
71 | sourceIds.Add(srcTable[key]);
72 |
73 | srcTable.Database.WblockCloneObjects(sourceIds, destTable.ObjectId, mapping, DuplicateRecordCloning.Ignore, false);
74 | Ac.Write(string.Format("'{0}' added.", key)); // G7-FixedPoint added.
75 |
76 | return destTable[key];
77 | }
78 | }
79 |
80 | public static ObjectId ImportMissedBlockDef(string blockName, string srcDwgFile)
81 | {
82 | using (var dwgDb = AcDwgDb.OpenReadonly(srcDwgFile))
83 | using (var dwgTrans = dwgDb.TransactionManager.StartTransaction())
84 | using (var acTrans = Ac.Db.TransactionManager.StartTransaction())
85 | {
86 | var dwgTable = (SymbolTable)dwgTrans.GetObject(dwgDb.BlockTableId, OpenMode.ForRead);
87 | var acTable = (SymbolTable)acTrans.GetObject(Ac.Db.BlockTableId, OpenMode.ForWrite);
88 |
89 | var blockId = ImportMissedRecord(dwgTable, blockName, acTable);
90 | using (var blockTableRec = (BlockTableRecord)acTrans.GetObject(blockId, OpenMode.ForWrite))
91 | {
92 | SendHatchesToBack(acTrans, blockTableRec);
93 | }
94 |
95 | acTrans.Commit();
96 | return blockId;
97 | }
98 | }
99 |
100 | public static ObjectId ImportMissedDimStyle(string name, string srcDwgFile)
101 | {
102 | using (var dwgDb = AcDwgDb.OpenReadonly(srcDwgFile))
103 | using (var dwgTrans = dwgDb.TransactionManager.StartTransaction())
104 | using (var acTrans = Ac.Db.TransactionManager.StartTransaction())
105 | {
106 | var dwgTable = (SymbolTable)dwgTrans.GetObject(dwgDb.DimStyleTableId, OpenMode.ForRead);
107 | var acTable = (SymbolTable)acTrans.GetObject(Ac.Db.DimStyleTableId, OpenMode.ForWrite);
108 |
109 | var res = ImportMissedRecord(dwgTable, name, acTable);
110 | acTrans.Commit();
111 | return res;
112 | }
113 | }
114 |
115 | public static ObjectId ImportMissedTextStyle(string name, string srcDwgFile)
116 | {
117 | using (var dwgDb = AcDwgDb.OpenReadonly(srcDwgFile))
118 | using (var dwgTrans = dwgDb.TransactionManager.StartTransaction())
119 | using (var acTrans = Ac.Db.TransactionManager.StartTransaction())
120 | {
121 | var dwgTable = (SymbolTable)dwgTrans.GetObject(dwgDb.TextStyleTableId, OpenMode.ForRead);
122 | var acTable = (SymbolTable)acTrans.GetObject(Ac.Db.TextStyleTableId, OpenMode.ForWrite);
123 |
124 | var res = ImportMissedRecord(dwgTable, name, acTable);
125 | acTrans.Commit();
126 | return res;
127 | }
128 | }
129 |
130 | private static void SendHatchesToBack(Transaction trans, BlockTableRecord blockTable)
131 | {
132 | using (var hatchIds = new ObjectIdCollection())
133 | {
134 | foreach (ObjectId id in blockTable)
135 | {
136 | if (id.ObjectClass.Name == "AcDbHatch")
137 | hatchIds.Add(id);
138 |
139 | /*
140 | //Use it to open the current object!
141 | using (var ent = trans.GetObject(id, OpenMode.ForRead))
142 | {
143 | if (ent is Hatch)
144 | {
145 | Ac.WriteLn(ent.ObjectId.ObjectClass.DxfName);
146 | hatchIds.Add(ent.ObjectId);
147 | }
148 | }
149 | */
150 | }
151 | using (var drawOrderTable = (DrawOrderTable)trans.GetObject(blockTable.DrawOrderTableId, OpenMode.ForWrite))
152 | {
153 | drawOrderTable.MoveToBottom(hatchIds);
154 | }
155 | }
156 | }
157 |
158 |
159 | }
160 |
161 |
162 |
163 | }
164 |
--------------------------------------------------------------------------------
/Source/Geo7.Shared/Utils/Polygons.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 |
7 | #if AutoCAD
8 | using Autodesk.AutoCAD.Runtime;
9 | using Autodesk.AutoCAD.DatabaseServices;
10 | using Autodesk.AutoCAD.Geometry;
11 | using Autodesk.AutoCAD.ApplicationServices;
12 | using Autodesk.AutoCAD.EditorInput;
13 | #endif
14 |
15 | #if BricsCAD
16 | using Teigha.Runtime;
17 | using Teigha.DatabaseServices;
18 | using Teigha.Geometry;
19 | using Bricscad.ApplicationServices;
20 | using Bricscad.EditorInput;
21 | #endif
22 |
23 | namespace System
24 | {
25 |
26 | public class AcPolygonSegment
27 | {
28 | public AcPolygonSegment(Line ln)
29 | {
30 | this.StartPoint = ln.StartPoint.Convert2d();
31 | this.EndPoint = ln.EndPoint.Convert2d();
32 | this.Azimuth = ln.Angle;
33 | }
34 |
35 | private AcPolygonSegment(Point2d s, Point2d e, Angle a)
36 | {
37 | this.StartPoint = s;
38 | this.EndPoint = e;
39 | this.Azimuth = a;
40 | }
41 |
42 | public AcPolygonSegment Reverse()
43 | {
44 | return new AcPolygonSegment(EndPoint, StartPoint, Azimuth - new Angle(180, 0, 0));
45 | }
46 |
47 | public string Id
48 | {
49 | get { return Azimuth.AsDeg.ToString("0.000000") + "; " + StartPoint.Id() + "; " + EndPoint.Id(); }
50 | }
51 |
52 |
53 | public Point2d StartPoint {get; private set; }
54 | public Point2d EndPoint { get; private set; }
55 | public Angle Azimuth { get; private set; }
56 | public Angle TempAzimuth { get; set; }
57 | }
58 |
59 |
60 | public class AcPolygonsCreator
61 | {
62 | private List Lines = new List();
63 | private Dictionary> LinesDict = new Dictionary>();
64 |
65 | public static void Run()
66 | {
67 | var pl = new AcPolygonsCreator();
68 |
69 | pl.LoadLinesData();
70 | pl.BuildPolygons();
71 | AcRemoveDuplicatedPolygons.Run();
72 | }
73 |
74 |
75 | public int LoadLinesData()
76 | {
77 | Lines.Clear();
78 | LinesDict.Clear();
79 | int res = 0;
80 | using(var trans = Ac.StartTransaction())
81 | {
82 | var acLines = trans.GetAllEntities();
83 | Ac.InitProgress(AppServices.Strings.LoadingLines, acLines.Count());
84 | foreach (var acLn in acLines)
85 | {
86 | if (acLn.Length < 0.000001)
87 | continue;
88 | var ln = new AcPolygonSegment(acLn);
89 | var lnRev = ln.Reverse();
90 |
91 | Lines.Add(ln);
92 | LinesDict.AddListItem(ln.StartPoint.Id(), ln);
93 |
94 | // Trzeba dodać odwrotną linię, bo nie zawsze startPoint jest
95 | // z tej strony, z której bym chciał
96 | Lines.Add(lnRev);
97 | LinesDict.AddListItem(lnRev.StartPoint.Id(), lnRev);
98 |
99 |
100 | res++;
101 | Ac.SetProgress(res);
102 | }
103 | Ac.ClearProgress();
104 | }
105 | return res;
106 | }
107 |
108 | internal void BuildPolygons(System.Windows.Controls.ProgressBar progressBar)
109 | {
110 | using (var trans = Ac.StartTransaction())
111 | try
112 | {
113 | progressBar.Maximum = Lines.Count;
114 | progressBar.Minimum = 0;
115 |
116 | foreach (var ln in Lines)
117 | {
118 | Polyline polyline = new Polyline();
119 | polyline.AddVertex(ln.StartPoint);
120 | if (BuildPolygon(polyline, ln.StartPoint, ln))
121 | {
122 | polyline.Closed = true;
123 | if (polyline.NumberOfVertices > 2)
124 | trans.AddEntity(polyline);
125 | }
126 | progressBar.Value = progressBar.Value + 1;
127 | System.Windows.Forms.Application.DoEvents();
128 | }
129 | trans.Commit();
130 | }
131 | catch (System.Exception ex)
132 | {
133 | Ac.WriteLn("Geo7: " + ex.Message);
134 | }
135 | }
136 |
137 | public int BuildPolygons()
138 | {
139 | int res = 0;
140 | using (var trans = Ac.StartTransaction())
141 | try
142 | {
143 | Ac.InitProgress(AppServices.Strings.CreatingPolygons, Lines.Count());
144 | foreach (var ln in Lines)
145 | {
146 | Polyline polyline = new Polyline();
147 | polyline.AddVertex(ln.StartPoint);
148 | if (BuildPolygon(polyline, ln.StartPoint, ln))
149 | {
150 | res++;
151 | polyline.Closed = true;
152 | if (polyline.NumberOfVertices > 2)
153 | trans.AddEntity(polyline);
154 | }
155 | Ac.ProgressStep();
156 | }
157 | Ac.ClearProgress();
158 | trans.Commit();
159 | }
160 | catch (System.Exception ex)
161 | {
162 | Ac.WriteLn("Geo7: "+ex.Message);
163 | }
164 | return res;
165 | }
166 |
167 | private List GetEndPointLines(AcPolygonSegment currentSegment)
168 | {
169 | List res = new List();
170 | string endPointId = currentSegment.EndPoint.Id();
171 | var endPointLines = LinesDict.GetList(endPointId);
172 | foreach (var ln in endPointLines)
173 | {
174 | // Usuń linie, które są takie same jak currentSegment
175 | if (ln.Id == currentSegment.Id)
176 | continue;
177 | if (ln.Reverse().Id == currentSegment.Id)
178 | continue;
179 | res.Add(ln);
180 | }
181 | return res;
182 | }
183 |
184 | private bool BuildPolygon(Polyline polyline, Point2d startPoint, AcPolygonSegment currentSegment)
185 | {
186 | if (currentSegment.EndPoint.Id() == startPoint.Id())
187 | return true;
188 | // Nie dodawaj ostatniego zdublowanego wertexu, bo potem przy zmianie początku polilini ID się nie zgadzają
189 |
190 | polyline.AddVertex(currentSegment.EndPoint);
191 |
192 | var endPointLines = GetEndPointLines(currentSegment);
193 | if (endPointLines.Count < 1)
194 | return false;
195 |
196 |
197 |
198 | AcPolygonSegment nextLine = GetNextLine(endPointLines, currentSegment);
199 |
200 | return BuildPolygon(polyline, startPoint, nextLine);
201 | }
202 |
203 | private AcPolygonSegment GetNextLine(List lines, AcPolygonSegment currentSegment)
204 | {
205 | Angle azimuth0 = currentSegment.Azimuth - new Angle(180, 0, 0);
206 | // UpdateTempAzimuths
207 | foreach (var ln in lines)
208 | {
209 | ln.TempAzimuth = ln.Azimuth - azimuth0;
210 | }
211 |
212 | // Get Next Line, TempAzimuth = Max
213 | AcPolygonSegment nextLine = lines.First();
214 | foreach (var ln in lines)
215 | {
216 | if (ln.TempAzimuth.AsRad > nextLine.TempAzimuth.AsRad)
217 | nextLine = ln;
218 | }
219 | return nextLine;
220 | }
221 |
222 | }
223 |
224 | public class AcJoinPolygonsWithTexts
225 | {
226 |
227 | public void Run()
228 | {
229 | using (var trans = Ac.StartTransaction())
230 | {
231 | var allTexts = trans.GetAllEntities().Where(t => !string.IsNullOrEmpty(t.TextString.Trim()));
232 | var polygons = trans.GetAllEntities().Where(p => (p.Closed == true) && (p.Length > 0.01));
233 |
234 | Ac.InitProgress(AppServices.Strings.ProcessingData, polygons.Count());
235 | foreach (var p in polygons)
236 | {
237 | var pTexts = GetTextsInPolygon(p, allTexts);
238 | ChangePolygonLayer(trans, p, pTexts);
239 | Ac.ProgressStep();
240 | }
241 | Ac.ClearProgress();
242 | trans.Commit();
243 | }
244 | }
245 |
246 | private void ChangePolygonLayer(AcTransaction trans, Polyline polygon, List texts)
247 | {
248 | polygon.UpgradeOpen();
249 | string layerName = "";
250 | if (texts.Count < 1)
251 | layerName = "#PolygonsWithoutTextInside";
252 | else if (texts.Count == 1)
253 | layerName = texts[0].TextString;
254 | else
255 | {
256 | var textStrings = from t in texts select t.TextString.Trim();
257 | string prefix = "#" + textStrings.Count().ToString() + "-";
258 | layerName = prefix + textStrings.ToList().Join("-");
259 | }
260 |
261 | layerName = Ac.GetValidName(layerName);
262 | polygon.LayerId = trans.CreateLayer(layerName);
263 | }
264 |
265 |
266 |
267 | private List GetTextsInPolygon(Polyline polygon, IEnumerable texts)
268 | {
269 | List res = new List();
270 | var curves = polygon.GetOffsetCurves(-0.01);
271 | if (curves.Count < 1)
272 | return res;
273 | var polygonOff = curves[0] as Polyline;
274 |
275 | foreach (var t in texts)
276 | {
277 | if (polygon.IsInside(t.Position))
278 | res.Add(t);
279 | }
280 | return res;
281 | }
282 |
283 | }
284 |
285 |
286 | }
287 |
--------------------------------------------------------------------------------
/Source/Geo7.Shared/Utils/RemoveDuplicates.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | #if AutoCAD
7 | using Autodesk.AutoCAD.Runtime;
8 | using Autodesk.AutoCAD.DatabaseServices;
9 | using Autodesk.AutoCAD.Geometry;
10 | using Autodesk.AutoCAD.ApplicationServices;
11 | using Autodesk.AutoCAD.EditorInput;
12 | #endif
13 |
14 | #if BricsCAD
15 | using Teigha.Runtime;
16 | using Teigha.DatabaseServices;
17 | using Teigha.Geometry;
18 | using Bricscad.ApplicationServices;
19 | using Bricscad.EditorInput;
20 | #endif
21 |
22 | namespace System
23 | {
24 | public class AcRemoveDuplicates
25 | {
26 | Dictionary> IdsDict = new Dictionary>();
27 | Dictionary> EntitiesDict = new Dictionary>();
28 |
29 | private void BuildEntitiesDict(IEnumerable entities)
30 | {
31 | foreach (var ent in entities)
32 | {
33 | var ids = GetEntityIds(ent);
34 | foreach (var id in ids)
35 | {
36 | IdsDict.AddListItem(id, ent);
37 | EntitiesDict.AddListItem(ent, id);
38 | }
39 | }
40 | }
41 |
42 | protected virtual IEnumerable GetEntityIds(Entity entity)
43 | {
44 | var res = new List();
45 | res.Add(entity.Id.ToString());
46 | return res;
47 | }
48 |
49 | public void Run(IEnumerable entities, bool showProgress)
50 | {
51 | BuildEntitiesDict(entities);
52 |
53 | if (showProgress)
54 | Ac.InitProgress(AppServices.Strings.DeletingDuplicates, entities.Count());
55 |
56 | foreach (var kv in EntitiesDict)
57 | {
58 | var ids = kv.Value;
59 | var ent = kv.Key;
60 |
61 | if (ent.IsErased)
62 | continue;
63 |
64 | foreach (var id in ids)
65 | {
66 |
67 | var duplEnts = IdsDict.GetList(id);
68 | foreach (var duplEnt in duplEnts)
69 | {
70 | if (duplEnt != ent)
71 | {
72 | duplEnt.UpgradeOpen();
73 | duplEnt.Erase();
74 | }
75 | }
76 | }
77 | if (showProgress)
78 | Ac.ProgressStep();
79 | }
80 | if (showProgress)
81 | Ac.ClearProgress();
82 | }
83 |
84 | }
85 |
86 | public class AcRemoveDuplicatedPolygons : AcRemoveDuplicates
87 | {
88 | public static void Run()
89 | {
90 | using (var trans = Ac.StartTransaction())
91 | {
92 | var polylines = trans.GetAllEntities();
93 | var polygons = polylines.Where(p => p.Closed == true).ToList();
94 | var polygonsByLength = polygons.ToLookup(p => p.Length.ToString(Ac.LinearPrecisionFormat));
95 |
96 | Ac.InitProgress(AppServices.Strings.DeletingDuplicates, polygonsByLength.Count);
97 | Ac.WriteLn(AppServices.Strings.DeletingDuplicates);
98 |
99 | foreach (var polygonsWithLength in polygonsByLength)
100 | {
101 | var ents = polygonsWithLength.ConvertTo();
102 | AcRemoveDuplicatedPolygons rdp = new AcRemoveDuplicatedPolygons();
103 | rdp.Run(ents, false);
104 | Ac.ProgressStep();
105 | }
106 | Ac.ClearProgress();
107 | trans.Commit();
108 | }
109 | }
110 | protected override IEnumerable GetEntityIds(Entity entity)
111 | {
112 | List res = new List();
113 | var poly = entity as Polyline;
114 | if (poly == null)
115 | return res;
116 |
117 | if (!poly.Closed)
118 | return res;
119 |
120 | var points = poly.GetPoints2d();
121 | var pointsRev = points.ToList();
122 | pointsRev.Reverse();
123 |
124 | res.AddRange(GetPointsIds(points));
125 | res.AddRange(GetPointsIds(pointsRev));
126 | return res;
127 | }
128 |
129 | private List GetPointsIds(List points)
130 | {
131 | List pointsIds = new List();
132 |
133 | for (int i = 0; i < points.Count; i++)
134 | {
135 | string id = GetPointsId(points);
136 | pointsIds.Add(id);
137 | var point0 = points[0];
138 | points.RemoveAt(0);
139 | points.Add(point0);
140 | }
141 | return pointsIds;
142 | }
143 |
144 | private string GetPointsId(List points)
145 | {
146 | List pointIds = new List();
147 | foreach (var p in points)
148 | {
149 | pointIds.Add(p.Id());
150 | }
151 | return pointIds.Join(", ");
152 | }
153 | }
154 |
155 |
156 |
157 | }
158 |
--------------------------------------------------------------------------------
/Source/Geo7.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.25420.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "Geo7.Shared", "Geo7.Shared\Geo7.Shared.shproj", "{C5B77044-DB60-4861-BAB6-9B5EA1E4E1A9}"
7 | EndProject
8 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Geo7.ZwCAD", "Geo7.ZwCAD\Geo7.ZwCAD.csproj", "{4C0E14BC-F7FC-4AC1-93FB-A829D64C7342}"
9 | EndProject
10 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Geo7.BricsCAD", "Geo7.App\Geo7.BricsCAD.csproj", "{290809C6-7644-43EF-9F48-EFD3FBEC3A5C}"
11 | EndProject
12 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "KSz.App.Wpf", "..\..\..\KSz.Shared\Source\KSz.App.WPF\KSz.App.Wpf.csproj", "{90C02122-0E35-4068-B39F-86B3134EB703}"
13 | EndProject
14 | Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "KSz.Shared.IO", "..\..\..\KSz.Shared\Source\KSz.Shared.IO\KSz.Shared.IO.shproj", "{82601861-55A4-4136-A647-A284214E97DB}"
15 | EndProject
16 | Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "KSz.Shared.App.WPF", "..\..\..\KSz.Shared\Source\KSz.Shared.App.WPF\KSz.Shared.App.WPF.shproj", "{3F27B031-4AD4-43FA-BF64-3104FB4715E2}"
17 | EndProject
18 | Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "KSz.Shared.Core", "..\..\..\KSz.Shared\Source\KSz.Shared.Core\KSz.Shared.Core.shproj", "{47DB778C-DC35-4C48-8F0D-C0EDB164F8F9}"
19 | EndProject
20 | Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "KSz.Shared.App.Native", "..\..\..\KSz.Shared\Source\KSz.Shared.App.Native\KSz.Shared.App.Native.shproj", "{2008A740-950E-45B5-8475-85A4A2A2123E}"
21 | EndProject
22 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Geo7.AutoCAD", "Geo7.App\Geo7.AutoCAD.csproj", "{E6D1502A-A0B6-4DE6-A875-CCB76C45E386}"
23 | EndProject
24 | Global
25 | GlobalSection(SharedMSBuildProjectFiles) = preSolution
26 | ..\..\..\KSz.Shared\Source\KSz.Shared.App.Native\KSz.Shared.NativeApp.projitems*{2008a740-950e-45b5-8475-85a4a2a2123e}*SharedItemsImports = 13
27 | Geo7.Shared\Geo7.Shared.projitems*{290809c6-7644-43ef-9f48-efd3fbec3a5c}*SharedItemsImports = 4
28 | ..\..\..\KSz.Shared\Source\KSz.Shared.App.WPF\KSz.Shared.WPF.projitems*{3f27b031-4ad4-43fa-bf64-3104fb4715e2}*SharedItemsImports = 13
29 | ..\..\..\KSz.Shared\Source\KSz.Shared.Core\KSz.Shared.Core.projitems*{47db778c-dc35-4c48-8f0d-c0edb164f8f9}*SharedItemsImports = 13
30 | ..\..\..\KSz.Shared\Source\KSz.Shared.IO\KSz.Shared.IO.projitems*{82601861-55a4-4136-a647-a284214e97db}*SharedItemsImports = 13
31 | ..\..\..\KSz.Shared\Source\KSz.Shared.App.Native\KSz.Shared.NativeApp.projitems*{90c02122-0e35-4068-b39f-86b3134eb703}*SharedItemsImports = 4
32 | ..\..\..\KSz.Shared\Source\KSz.Shared.App.WPF\KSz.Shared.WPF.projitems*{90c02122-0e35-4068-b39f-86b3134eb703}*SharedItemsImports = 4
33 | ..\..\..\KSz.Shared\Source\KSz.Shared.Core\KSz.Shared.Core.projitems*{90c02122-0e35-4068-b39f-86b3134eb703}*SharedItemsImports = 4
34 | ..\..\..\KSz.Shared\Source\KSz.Shared.Db\KSz.Shared.Data.projitems*{90c02122-0e35-4068-b39f-86b3134eb703}*SharedItemsImports = 4
35 | ..\..\..\KSz.Shared\Source\KSz.Shared.EGB\KSz.Shared.EGB.projitems*{90c02122-0e35-4068-b39f-86b3134eb703}*SharedItemsImports = 4
36 | ..\..\..\KSz.Shared\Source\KSz.Shared.IO\KSz.Shared.IO.projitems*{90c02122-0e35-4068-b39f-86b3134eb703}*SharedItemsImports = 4
37 | Geo7.Shared\Geo7.Shared.projitems*{c5b77044-db60-4861-bab6-9b5ea1e4e1a9}*SharedItemsImports = 13
38 | Geo7.Shared\Geo7.Shared.projitems*{e6d1502a-a0b6-4de6-a875-ccb76c45e386}*SharedItemsImports = 4
39 | EndGlobalSection
40 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
41 | Debug|Any CPU = Debug|Any CPU
42 | Release|Any CPU = Release|Any CPU
43 | EndGlobalSection
44 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
45 | {4C0E14BC-F7FC-4AC1-93FB-A829D64C7342}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
46 | {4C0E14BC-F7FC-4AC1-93FB-A829D64C7342}.Debug|Any CPU.Build.0 = Debug|Any CPU
47 | {4C0E14BC-F7FC-4AC1-93FB-A829D64C7342}.Release|Any CPU.ActiveCfg = Release|Any CPU
48 | {4C0E14BC-F7FC-4AC1-93FB-A829D64C7342}.Release|Any CPU.Build.0 = Release|Any CPU
49 | {290809C6-7644-43EF-9F48-EFD3FBEC3A5C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
50 | {290809C6-7644-43EF-9F48-EFD3FBEC3A5C}.Debug|Any CPU.Build.0 = Debug|Any CPU
51 | {290809C6-7644-43EF-9F48-EFD3FBEC3A5C}.Release|Any CPU.ActiveCfg = Release|Any CPU
52 | {290809C6-7644-43EF-9F48-EFD3FBEC3A5C}.Release|Any CPU.Build.0 = Release|Any CPU
53 | {90C02122-0E35-4068-B39F-86B3134EB703}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
54 | {90C02122-0E35-4068-B39F-86B3134EB703}.Debug|Any CPU.Build.0 = Debug|Any CPU
55 | {90C02122-0E35-4068-B39F-86B3134EB703}.Release|Any CPU.ActiveCfg = Release|Any CPU
56 | {90C02122-0E35-4068-B39F-86B3134EB703}.Release|Any CPU.Build.0 = Release|Any CPU
57 | {E6D1502A-A0B6-4DE6-A875-CCB76C45E386}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
58 | {E6D1502A-A0B6-4DE6-A875-CCB76C45E386}.Debug|Any CPU.Build.0 = Debug|Any CPU
59 | {E6D1502A-A0B6-4DE6-A875-CCB76C45E386}.Release|Any CPU.ActiveCfg = Release|Any CPU
60 | {E6D1502A-A0B6-4DE6-A875-CCB76C45E386}.Release|Any CPU.Build.0 = Release|Any CPU
61 | EndGlobalSection
62 | GlobalSection(SolutionProperties) = preSolution
63 | HideSolutionNode = FALSE
64 | EndGlobalSection
65 | EndGlobal
66 |
--------------------------------------------------------------------------------
/Source/Install/Geo7.iss:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/KubaSzostak/Geo7/f6e4f6f7913b8ec59c5f8151397e6c3a6e9e2d0f/Source/Install/Geo7.iss
--------------------------------------------------------------------------------
/release-info.md:
--------------------------------------------------------------------------------
1 | ## Release info
2 |
3 | ### Geo7 Tools
4 |
5 | Geo7 Tools installer for AutoCAD 2013 or newer. User interface and documentation developed in polish language.
6 |
--------------------------------------------------------------------------------