├── .gitignore
├── LICENSE.md
├── README.md
├── media
├── ExtensionMethodIntellisense.png
├── ExtensionMethods.png
├── Install.png
├── InstallCommandLine.png
├── InstallCommandLineVersion.png
└── icon.png
└── src
├── QA
├── Program.cs
└── QA.csproj
├── SolidEdge.Community.sln
└── SolidEdge.Community
├── ConnectionPointController.cs
├── ConnectionPointControllerBase.cs
├── EventSink.cs
├── Extensions
├── ApplicationExtensions.cs
├── Arc3DExtensions.cs
├── AssemblyDocumentExtensions.cs
├── DocumentsExtensions.cs
├── DraftDocumentExtensions.cs
├── DrawingViewExtensions.cs
├── EnvironmentExtensions.cs
├── Line3DExtensions.cs
├── MouseExtensions.cs
├── OccurrenceExtensions.cs
├── PartDocumentExtensions.cs
├── PropertiesExtensions.cs
├── PropertySetsExtensions.cs
├── RefPlanesExtensions.cs
├── SectionExtensions.cs
├── SheetExtensions.cs
├── SheetMetalDocumentExtensions.cs
├── SolidEdgeDocumentExtensions.cs
├── WeldmentDocumentExtensions.cs
└── WindowExtensions.cs
├── IsolatedTask.cs
├── IsolatedTaskProxy.cs
├── OleMessageFilter.cs
├── Properties
└── AssemblyInfo.cs
├── Runtime
└── InteropServices
│ ├── ComObject.cs
│ └── ComTypes
│ └── IDispatch.cs
├── SolidEdge.Community.csproj
└── SolidEdgeUtils.cs
/.gitignore:
--------------------------------------------------------------------------------
1 | #################
2 | ## Eclipse
3 | #################
4 |
5 | *.pydevproject
6 | .project
7 | .metadata
8 | bin/
9 | tmp/
10 | *.tmp
11 | *.bak
12 | *.swp
13 | *~.nib
14 | local.properties
15 | .classpath
16 | .settings/
17 | .loadpath
18 |
19 | # External tool builders
20 | .externalToolBuilders/
21 |
22 | # Locally stored "Eclipse launch configurations"
23 | *.launch
24 |
25 | # CDT-specific
26 | .cproject
27 |
28 | # PDT-specific
29 | .buildpath
30 |
31 |
32 | #################
33 | ## Visual Studio
34 | #################
35 |
36 | ## Ignore Visual Studio temporary files, build results, and
37 | ## files generated by popular Visual Studio add-ons.
38 |
39 | # User-specific files
40 | *.suo
41 | *.user
42 | *.sln.docstates
43 |
44 | # Build results
45 |
46 | [Dd]ebug/
47 | [Rr]elease/
48 | x64/
49 | #build/
50 | [Bb]in/
51 | [Oo]bj/
52 |
53 | # MSTest test Results
54 | [Tt]est[Rr]esult*/
55 | [Bb]uild[Ll]og.*
56 |
57 | *_i.c
58 | *_p.c
59 | *.ilk
60 | *.meta
61 | *.obj
62 | *.pch
63 | *.pdb
64 | *.pgc
65 | *.pgd
66 | *.rsp
67 | *.sbr
68 | *.tlb
69 | *.tli
70 | *.tlh
71 | *.tmp
72 | *.tmp_proj
73 | *.log
74 | *.vspscc
75 | *.vssscc
76 | .builds
77 | *.pidb
78 | *.log
79 | *.scc
80 |
81 | # Visual C++ cache files
82 | ipch/
83 | *.aps
84 | *.ncb
85 | *.opensdf
86 | *.sdf
87 | *.cachefile
88 |
89 | # Visual Studio profiler
90 | *.psess
91 | *.vsp
92 | *.vspx
93 |
94 | # Guidance Automation Toolkit
95 | *.gpState
96 |
97 | # ReSharper is a .NET coding add-in
98 | _ReSharper*/
99 | *.[Rr]e[Ss]harper
100 |
101 | # TeamCity is a build add-in
102 | _TeamCity*
103 |
104 | # DotCover is a Code Coverage Tool
105 | *.dotCover
106 |
107 | # NCrunch
108 | *.ncrunch*
109 | .*crunch*.local.xml
110 |
111 | # Installshield output folder
112 | [Ee]xpress/
113 |
114 | # DocProject is a documentation generator add-in
115 | DocProject/buildhelp/
116 | DocProject/Help/*.HxT
117 | DocProject/Help/*.HxC
118 | DocProject/Help/*.hhc
119 | DocProject/Help/*.hhk
120 | DocProject/Help/*.hhp
121 | DocProject/Help/Html2
122 | DocProject/Help/html
123 |
124 | # Click-Once directory
125 | publish/
126 |
127 | # Publish Web Output
128 | *.Publish.xml
129 | *.pubxml
130 |
131 | # NuGet Packages Directory
132 | ## TODO: If you have NuGet Package Restore enabled, uncomment the next line
133 | packages/
134 |
135 | # Windows Azure Build Output
136 | csx
137 | *.build.csdef
138 |
139 | # Windows Store app package directory
140 | AppPackages/
141 |
142 | # Others
143 | sql/
144 | *.Cache
145 | ClientBin/
146 | [Ss]tyle[Cc]op.*
147 | ~$*
148 | *~
149 | *.dbmdl
150 | *.[Pp]ublish.xml
151 | *.pfx
152 | *.publishsettings
153 |
154 | # RIA/Silverlight projects
155 | Generated_Code/
156 |
157 | # Backup & report files from converting an old project file to a newer
158 | # Visual Studio version. Backup files are not needed, because we have git ;-)
159 | _UpgradeReport_Files/
160 | Backup*/
161 | UpgradeLog*.XML
162 | UpgradeLog*.htm
163 |
164 | # SQL Server files
165 | App_Data/*.mdf
166 | App_Data/*.ldf
167 |
168 | #############
169 | ## Windows detritus
170 | #############
171 |
172 | # Windows image file caches
173 | Thumbs.db
174 | ehthumbs.db
175 |
176 | # Folder config file
177 | Desktop.ini
178 |
179 | # Recycle Bin used on file shares
180 | $RECYCLE.BIN/
181 |
182 | # Mac crap
183 | .DS_Store
184 |
185 |
186 | #############
187 | ## Python
188 | #############
189 |
190 | *.py[co]
191 |
192 | # Packages
193 | *.egg
194 | *.egg-info
195 | dist/
196 | #build/
197 | eggs/
198 | parts/
199 | var/
200 | sdist/
201 | develop-eggs/
202 | .installed.cfg
203 |
204 | # Installer logs
205 | pip-log.txt
206 |
207 | # Unit test / coverage reports
208 | .coverage
209 | .tox
210 |
211 | #Translations
212 | *.mo
213 |
214 | #Mr Developer
215 | .mr.developer.cfg
216 |
217 | # Added by Jason Newell
218 | .exe
219 | .dll
220 | /.vs
221 | /src/.vs
222 |
--------------------------------------------------------------------------------
/LICENSE.md:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2014 Solid Edge Community
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 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | SolidEdge.Community Repostiory
2 | ================
3 |
4 | This is the central repository for the [SolidEdge.Community](http://www.nuget.org/packages/SolidEdge.Community) NuGet package.
5 |
6 | ### Latest Releases
7 | |Library |Version |Downloads |
8 | |:-----------------|:-----------------|:-----------------|
9 | |**SolidEdge.Community**|[](https://www.nuget.org/packages/SolidEdge.Community/)|[](https://www.nuget.org/packages/SolidEdge.Community/)|
10 | |**SolidEdge.Community.AddIn**|[](https://www.nuget.org/packages/SolidEdge.Community.AddIn/)|[](https://www.nuget.org/packages/SolidEdge.Community.AddIn/)|
11 |
12 | ---
13 |
14 | ## Overview
15 | The core functionality of this package is the SolidEdge.Community.dll. This assembly extends the [Interop.SolidEdge](http://www.nuget.org/packages/Interop.SolidEdge) NuGet package and enhances the development experience. For examples of how to use the package, see the [SolidEdgeCommunity / Samples](https://github.com/SolidEdgeCommunity/Samples) repository.
16 |
17 | ## Documentation
18 | Please refer to the [SolidEdge.Community Wiki](https://github.com/SolidEdgeCommunity/SolidEdge.Community/wiki) for detailed information about the [SolidEdge.Community](http://www.nuget.org/packages/SolidEdge.Community) NuGet package.
19 |
--------------------------------------------------------------------------------
/media/ExtensionMethodIntellisense.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SolidEdgeCommunity/SolidEdge.Community/7d7ebcfc1fec4774c46033883c4a52e5edb5f38a/media/ExtensionMethodIntellisense.png
--------------------------------------------------------------------------------
/media/ExtensionMethods.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SolidEdgeCommunity/SolidEdge.Community/7d7ebcfc1fec4774c46033883c4a52e5edb5f38a/media/ExtensionMethods.png
--------------------------------------------------------------------------------
/media/Install.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SolidEdgeCommunity/SolidEdge.Community/7d7ebcfc1fec4774c46033883c4a52e5edb5f38a/media/Install.png
--------------------------------------------------------------------------------
/media/InstallCommandLine.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SolidEdgeCommunity/SolidEdge.Community/7d7ebcfc1fec4774c46033883c4a52e5edb5f38a/media/InstallCommandLine.png
--------------------------------------------------------------------------------
/media/InstallCommandLineVersion.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SolidEdgeCommunity/SolidEdge.Community/7d7ebcfc1fec4774c46033883c4a52e5edb5f38a/media/InstallCommandLineVersion.png
--------------------------------------------------------------------------------
/media/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/SolidEdgeCommunity/SolidEdge.Community/7d7ebcfc1fec4774c46033883c4a52e5edb5f38a/media/icon.png
--------------------------------------------------------------------------------
/src/QA/Program.cs:
--------------------------------------------------------------------------------
1 | using SolidEdgeCommunity;
2 | using System;
3 |
4 | namespace QA
5 | {
6 | class Program
7 | {
8 | static void Main(string[] args)
9 | {
10 | var application = SolidEdgeUtils.Connect(true);
11 | application.Visible = true;
12 | }
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/src/QA/QA.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | NET40
5 |
6 | Exe
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/src/SolidEdge.Community.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 15
4 | VisualStudioVersion = 15.0.27004.2005
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "QA", "QA\QA.csproj", "{9D948FED-8E3E-4DA5-8E44-0F6AD7DD46CE}"
7 | EndProject
8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SolidEdge.Community", "SolidEdge.Community\SolidEdge.Community.csproj", "{49DAFAF3-C18C-4B3D-9006-BBFBFEEBBCB4}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|Any CPU = Debug|Any CPU
13 | Release|Any CPU = Release|Any CPU
14 | EndGlobalSection
15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
16 | {49DAFAF3-C18C-4B3D-9006-BBFBFEEBBCB4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
17 | {49DAFAF3-C18C-4B3D-9006-BBFBFEEBBCB4}.Debug|Any CPU.Build.0 = Debug|Any CPU
18 | {49DAFAF3-C18C-4B3D-9006-BBFBFEEBBCB4}.Release|Any CPU.ActiveCfg = Release|Any CPU
19 | {49DAFAF3-C18C-4B3D-9006-BBFBFEEBBCB4}.Release|Any CPU.Build.0 = Release|Any CPU
20 | {9D948FED-8E3E-4DA5-8E44-0F6AD7DD46CE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
21 | {9D948FED-8E3E-4DA5-8E44-0F6AD7DD46CE}.Debug|Any CPU.Build.0 = Debug|Any CPU
22 | {9D948FED-8E3E-4DA5-8E44-0F6AD7DD46CE}.Release|Any CPU.ActiveCfg = Release|Any CPU
23 | {9D948FED-8E3E-4DA5-8E44-0F6AD7DD46CE}.Release|Any CPU.Build.0 = Release|Any CPU
24 | EndGlobalSection
25 | GlobalSection(SolutionProperties) = preSolution
26 | HideSolutionNode = FALSE
27 | EndGlobalSection
28 | GlobalSection(ExtensibilityGlobals) = postSolution
29 | SolutionGuid = {6FBC4A16-50F3-4031-9EB8-663F23A3B1E1}
30 | EndGlobalSection
31 | EndGlobal
32 |
--------------------------------------------------------------------------------
/src/SolidEdge.Community/ConnectionPointController.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Runtime.InteropServices.ComTypes;
5 | using System.Text;
6 | using System.Threading;
7 |
8 | namespace SolidEdgeCommunity
9 | {
10 | ///
11 | /// Default controller that handles connecting\disconnecting to COM events via IConnectionPointContainer and IConnectionPoint interfaces.
12 | ///
13 | public class ConnectionPointController
14 | {
15 | private object _sink;
16 | private Dictionary _connectionPointDictionary = new Dictionary();
17 |
18 | public ConnectionPointController(object sink)
19 | {
20 | if (sink == null) throw new ArgumentNullException("sink");
21 | _sink = sink;
22 | }
23 |
24 | ///
25 | /// Establishes a connection between a connection point object and the client's sink.
26 | ///
27 | /// Interface type of the outgoing interface whose connection point object is being requested.
28 | /// An object that implements the IConnectionPointContainer inferface.
29 | public void AdviseSink(object container) where TInterface : class
30 | {
31 | bool lockTaken = false;
32 |
33 | try
34 | {
35 | Monitor.Enter(this, ref lockTaken);
36 |
37 | // Prevent multiple event Advise() calls on same sink.
38 | if (IsSinkAdvised(container))
39 | {
40 | return;
41 | }
42 |
43 | IConnectionPointContainer cpc = null;
44 | IConnectionPoint cp = null;
45 | int cookie = 0;
46 |
47 | cpc = (IConnectionPointContainer)container;
48 | cpc.FindConnectionPoint(typeof(TInterface).GUID, out cp);
49 |
50 | if (cp != null)
51 | {
52 | cp.Advise(_sink, out cookie);
53 | _connectionPointDictionary.Add(cp, cookie);
54 | }
55 | }
56 | finally
57 | {
58 | if (lockTaken)
59 | {
60 | Monitor.Exit(this);
61 | }
62 | }
63 | }
64 |
65 | ///
66 | /// Determines if a connection between a connection point object and the client's sink is established.
67 | ///
68 | /// An object that implements the IConnectionPointContainer inferface.
69 | public bool IsSinkAdvised(object container) where TInterface : class
70 | {
71 | bool lockTaken = false;
72 |
73 | try
74 | {
75 | Monitor.Enter(this, ref lockTaken);
76 |
77 | IConnectionPointContainer cpc = null;
78 | IConnectionPoint cp = null;
79 | int cookie = 0;
80 |
81 | cpc = (IConnectionPointContainer)container;
82 | cpc.FindConnectionPoint(typeof(TInterface).GUID, out cp);
83 |
84 | if (cp != null)
85 | {
86 | if (_connectionPointDictionary.ContainsKey(cp))
87 | {
88 | cookie = _connectionPointDictionary[cp];
89 | return true;
90 | }
91 | }
92 | }
93 | finally
94 | {
95 | if (lockTaken)
96 | {
97 | Monitor.Exit(this);
98 | }
99 | }
100 |
101 | return false;
102 | }
103 |
104 | ///
105 | /// Terminates an advisory connection previously established between a connection point object and a client's sink.
106 | ///
107 | /// Interface type of the interface whose connection point object is being requested to be removed.
108 | /// An object that implements the IConnectionPointContainer inferface.
109 | public void UnadviseSink(object container) where TInterface : class
110 | {
111 | bool lockTaken = false;
112 |
113 | try
114 | {
115 | Monitor.Enter(this, ref lockTaken);
116 |
117 | IConnectionPointContainer cpc = null;
118 | IConnectionPoint cp = null;
119 | int cookie = 0;
120 |
121 | cpc = (IConnectionPointContainer)container;
122 | cpc.FindConnectionPoint(typeof(TInterface).GUID, out cp);
123 |
124 | if (cp != null)
125 | {
126 | if (_connectionPointDictionary.ContainsKey(cp))
127 | {
128 | cookie = _connectionPointDictionary[cp];
129 | cp.Unadvise(cookie);
130 | _connectionPointDictionary.Remove(cp);
131 | }
132 | }
133 | }
134 | finally
135 | {
136 | if (lockTaken)
137 | {
138 | Monitor.Exit(this);
139 | }
140 | }
141 | }
142 |
143 | ///
144 | /// Terminates all advisory connections previously established.
145 | ///
146 | public void UnadviseAllSinks()
147 | {
148 | bool lockTaken = false;
149 |
150 | try
151 | {
152 | Monitor.Enter(this, ref lockTaken);
153 | Dictionary.Enumerator enumerator = _connectionPointDictionary.GetEnumerator();
154 | while (enumerator.MoveNext())
155 | {
156 | enumerator.Current.Key.Unadvise(enumerator.Current.Value);
157 | }
158 | }
159 | finally
160 | {
161 | _connectionPointDictionary.Clear();
162 |
163 | if (lockTaken)
164 | {
165 | Monitor.Exit(this);
166 | }
167 | }
168 | }
169 | }
170 | }
171 |
--------------------------------------------------------------------------------
/src/SolidEdge.Community/ConnectionPointControllerBase.cs:
--------------------------------------------------------------------------------
1 | //using System;
2 | //using System.Collections.Generic;
3 | //using System.Linq;
4 | //using System.Runtime.InteropServices.ComTypes;
5 | //using System.Text;
6 | //using System.Threading;
7 |
8 | //namespace SolidEdgeCommunity
9 | //{
10 | // ///
11 | // /// Controller base class that handles connecting\disconnecting to COM events via IConnectionPointContainer and IConnectionPoint interfaces.
12 | // ///
13 | // public abstract class ConnectionPointControllerBase
14 | // {
15 | // private Dictionary _connectionPointDictionary = new Dictionary();
16 |
17 | // ///
18 | // /// Establishes a connection between a connection point object and the client's sink.
19 | // ///
20 | // /// Interface type of the outgoing interface whose connection point object is being requested.
21 | // /// An object that implements the IConnectionPointContainer inferface.
22 | // protected void AdviseSink(object container) where TInterface : class
23 | // {
24 | // bool lockTaken = false;
25 |
26 | // try
27 | // {
28 | // Monitor.Enter(this, ref lockTaken);
29 |
30 | // // Prevent multiple event Advise() calls on same sink.
31 | // if (IsSinkAdvised(container))
32 | // {
33 | // return;
34 | // }
35 |
36 | // IConnectionPointContainer cpc = null;
37 | // IConnectionPoint cp = null;
38 | // int cookie = 0;
39 |
40 | // cpc = (IConnectionPointContainer)container;
41 | // cpc.FindConnectionPoint(typeof(TInterface).GUID, out cp);
42 |
43 | // if (cp != null)
44 | // {
45 | // cp.Advise(this, out cookie);
46 | // _connectionPointDictionary.Add(cp, cookie);
47 | // }
48 | // }
49 | // finally
50 | // {
51 | // if (lockTaken)
52 | // {
53 | // Monitor.Exit(this);
54 | // }
55 | // }
56 | // }
57 |
58 | // ///
59 | // /// Determines if a connection between a connection point object and the client's sink is established.
60 | // ///
61 | // /// An object that implements the IConnectionPointContainer inferface.
62 | // protected bool IsSinkAdvised(object container) where TInterface : class
63 | // {
64 | // bool lockTaken = false;
65 |
66 | // try
67 | // {
68 | // Monitor.Enter(this, ref lockTaken);
69 |
70 | // IConnectionPointContainer cpc = null;
71 | // IConnectionPoint cp = null;
72 | // int cookie = 0;
73 |
74 | // cpc = (IConnectionPointContainer)container;
75 | // cpc.FindConnectionPoint(typeof(TInterface).GUID, out cp);
76 |
77 | // if (cp != null)
78 | // {
79 | // if (_connectionPointDictionary.ContainsKey(cp))
80 | // {
81 | // cookie = _connectionPointDictionary[cp];
82 | // return true;
83 | // }
84 | // }
85 | // }
86 | // finally
87 | // {
88 | // if (lockTaken)
89 | // {
90 | // Monitor.Exit(this);
91 | // }
92 | // }
93 |
94 | // return false;
95 | // }
96 |
97 | // ///
98 | // /// Terminates an advisory connection previously established between a connection point object and a client's sink.
99 | // ///
100 | // /// Interface type of the interface whose connection point object is being requested to be removed.
101 | // /// An object that implements the IConnectionPointContainer inferface.
102 | // protected void UnadviseSink(object container) where TInterface : class
103 | // {
104 | // bool lockTaken = false;
105 |
106 | // try
107 | // {
108 | // Monitor.Enter(this, ref lockTaken);
109 |
110 | // IConnectionPointContainer cpc = null;
111 | // IConnectionPoint cp = null;
112 | // int cookie = 0;
113 |
114 | // cpc = (IConnectionPointContainer)container;
115 | // cpc.FindConnectionPoint(typeof(TInterface).GUID, out cp);
116 |
117 | // if (cp != null)
118 | // {
119 | // if (_connectionPointDictionary.ContainsKey(cp))
120 | // {
121 | // cookie = _connectionPointDictionary[cp];
122 | // cp.Unadvise(cookie);
123 | // _connectionPointDictionary.Remove(cp);
124 | // }
125 | // }
126 | // }
127 | // finally
128 | // {
129 | // if (lockTaken)
130 | // {
131 | // Monitor.Exit(this);
132 | // }
133 | // }
134 | // }
135 |
136 | // ///
137 | // /// Terminates all advisory connections previously established.
138 | // ///
139 | // protected void UnadviseAllSinks()
140 | // {
141 | // bool lockTaken = false;
142 |
143 | // try
144 | // {
145 | // Monitor.Enter(this, ref lockTaken);
146 | // Dictionary.Enumerator enumerator = _connectionPointDictionary.GetEnumerator();
147 | // while (enumerator.MoveNext())
148 | // {
149 | // enumerator.Current.Key.Unadvise(enumerator.Current.Value);
150 | // }
151 | // }
152 | // finally
153 | // {
154 | // _connectionPointDictionary.Clear();
155 |
156 | // if (lockTaken)
157 | // {
158 | // Monitor.Exit(this);
159 | // }
160 | // }
161 | // }
162 |
163 | // ///
164 | // /// Establishes or terminates a connection between a connection point object and the client's sink.
165 | // ///
166 | // /// Interface type of the interface whose connection point object is being requested to be updated.
167 | // /// An object that implements the IConnectionPointContainer inferface.
168 | // /// Flag indicating whether to advise or unadvise.
169 | // //protected void UpdateSink(object container, bool advise) where TInterface : class
170 | // //{
171 | // // if (advise)
172 | // // {
173 | // // AdviseSink(container);
174 | // // }
175 | // // else
176 | // // {
177 | // // UnadviseSink(container);
178 | // // }
179 | // //}
180 | // }
181 | //}
182 |
--------------------------------------------------------------------------------
/src/SolidEdge.Community/EventSink.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Runtime.InteropServices;
5 | using System.Runtime.InteropServices.ComTypes;
6 | using System.Text;
7 | using System.Threading;
8 |
9 | namespace SolidEdgeCommunity
10 | {
11 | public abstract class EventSink : IDisposable where T : class
12 | {
13 | private IConnectionPoint _connectionPoint;
14 | private int _cookie;
15 |
16 | public EventSink()
17 | {
18 | }
19 |
20 | ///
21 | /// Establishes a connection between a connection point object and the client's sink.
22 | ///
23 | /// An event source that implements IConnectionPointContainer.
24 | public EventSink(object source)
25 | {
26 | // If event source is specified, automatically connect.
27 | Connect(source);
28 | }
29 |
30 | ///
31 | ///
32 | ///
33 | public void Dispose()
34 | {
35 | Dispose(true);
36 | GC.SuppressFinalize(this);
37 | }
38 |
39 | protected virtual void Dispose(bool disposing)
40 | {
41 | if (disposing)
42 | {
43 | // Clean up all managed resources
44 | }
45 |
46 | Disconnect();
47 | }
48 |
49 | ///
50 | /// Establishes a connection between a connection point object and the client's sink.
51 | ///
52 | /// An event source that implements IConnectionPointContainer.
53 | public void Connect(object source)
54 | {
55 | bool lockTaken = false;
56 | IConnectionPointContainer container = null;
57 |
58 | try
59 | {
60 | Monitor.Enter(this, ref lockTaken);
61 |
62 | // If previous call was made, disconnect existing connection.
63 | if (container != null)
64 | {
65 | Disconnect();
66 | }
67 |
68 | // QueryInterface for IConnectionPointContainer.
69 | container = (IConnectionPointContainer)source;
70 |
71 | // Find the connection point by the GUID of type T.
72 | container.FindConnectionPoint(typeof(T).GUID, out _connectionPoint);
73 |
74 | if (_connectionPoint != null)
75 | {
76 | // Establish the sink connection.
77 | _connectionPoint.Advise(this, out _cookie);
78 | }
79 | }
80 | finally
81 | {
82 | if (lockTaken)
83 | {
84 | Monitor.Exit(this);
85 | }
86 | }
87 | }
88 |
89 | ///
90 | /// Terminates the advisory connection between a connection point and a client's sink.
91 | ///
92 | public void Disconnect()
93 | {
94 | bool lockTaken = false;
95 |
96 | try
97 | {
98 | Monitor.Enter(this, ref lockTaken);
99 |
100 | if (_connectionPoint != null)
101 | {
102 | // Terminate the sink connection.
103 | _connectionPoint.Unadvise(_cookie);
104 | }
105 | }
106 | finally
107 | {
108 | if (_connectionPoint != null)
109 | {
110 | try
111 | {
112 | var count = Marshal.ReleaseComObject(_connectionPoint);
113 | }
114 | catch
115 | {
116 | }
117 |
118 | _connectionPoint = null;
119 | _cookie = 0;
120 | }
121 |
122 | if (lockTaken)
123 | {
124 | Monitor.Exit(this);
125 | }
126 | }
127 | }
128 | }
129 | }
130 |
--------------------------------------------------------------------------------
/src/SolidEdge.Community/Extensions/ApplicationExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Diagnostics;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Windows.Forms;
7 |
8 | namespace SolidEdgeCommunity.Extensions
9 | {
10 | ///
11 | /// SolidEdgeFramework.Application extension methods.
12 | ///
13 | public static class ApplicationExtensions
14 | {
15 | ///
16 | /// Creates a Solid Edge command control.
17 | ///
18 | ///
19 | ///
20 | public static SolidEdgeFramework.Command CreateCommand(this SolidEdgeFramework.Application application, SolidEdgeConstants.seCmdFlag CmdFlags)
21 | {
22 | return application.CreateCommand((int)CmdFlags);
23 | }
24 |
25 | ///
26 | /// Returns the currently active document.
27 | ///
28 | /// An exception will be thrown if there is no active document.
29 | public static SolidEdgeFramework.SolidEdgeDocument GetActiveDocument(this SolidEdgeFramework.Application application)
30 | {
31 | return application.GetActiveDocument(true);
32 | }
33 |
34 | ///
35 | /// Returns the currently active document.
36 | ///
37 | public static SolidEdgeFramework.SolidEdgeDocument GetActiveDocument(this SolidEdgeFramework.Application application, bool throwOnError)
38 | {
39 | try
40 | {
41 | // ActiveDocument will throw an exception if no document is open.
42 | return (SolidEdgeFramework.SolidEdgeDocument)application.ActiveDocument;
43 | }
44 | catch
45 | {
46 | if (throwOnError) throw;
47 | }
48 |
49 | return null;
50 | }
51 |
52 | ///
53 | /// Returns the currently active document.
54 | ///
55 | /// The type to return.
56 | /// /// An exception will be thrown if there is no active document or if the cast fails.
57 | public static T GetActiveDocument(this SolidEdgeFramework.Application application) where T : class
58 | {
59 | return application.GetActiveDocument(true);
60 | }
61 |
62 | ///
63 | /// Returns the currently active document.
64 | ///
65 | /// The type to return.
66 | public static T GetActiveDocument(this SolidEdgeFramework.Application application, bool throwOnError) where T : class
67 | {
68 | try
69 | {
70 | // ActiveDocument will throw an exception if no document is open.
71 | return (T)application.ActiveDocument;
72 | }
73 | catch
74 | {
75 | if (throwOnError) throw;
76 | }
77 |
78 | return null;
79 | }
80 |
81 | ///
82 | /// Returns the environment that belongs to the current active window of the document.
83 | ///
84 | public static SolidEdgeFramework.Environment GetActiveEnvironment(this SolidEdgeFramework.Application application)
85 | {
86 | SolidEdgeFramework.Environments environments = application.Environments;
87 | return environments.Item(application.ActiveEnvironment);
88 | }
89 |
90 | /////
91 | ///// Returns the application events.
92 | /////
93 | //public static SolidEdgeFramework.ISEApplicationEvents_Event GetApplicationEvents(this SolidEdgeFramework.Application application)
94 | //{
95 | // return (SolidEdgeFramework.ISEApplicationEvents_Event)application.ApplicationEvents;
96 | //}
97 |
98 | /////
99 | ///// Returns the application window events.
100 | /////
101 | //public static SolidEdgeFramework.ISEApplicationWindowEvents_Event GetApplicationWindowEvents(this SolidEdgeFramework.Application application)
102 | //{
103 | // return (SolidEdgeFramework.ISEApplicationWindowEvents_Event)application.ApplicationWindowEvents;
104 | //}
105 |
106 | ///
107 | /// Returns an environment specified by CATID.
108 | ///
109 | public static SolidEdgeFramework.Environment GetEnvironment(this SolidEdgeFramework.Application application, string CATID)
110 | {
111 | var guid1 = new Guid(CATID);
112 |
113 | foreach (var environment in application.Environments.OfType())
114 | {
115 | var guid2 = new Guid(environment.CATID);
116 | if (guid1.Equals(guid2))
117 | {
118 | return environment;
119 | }
120 | }
121 |
122 | return null;
123 | }
124 |
125 | /////
126 | ///// Returns the feature library events.
127 | /////
128 | //public static SolidEdgeFramework.ISEFeatureLibraryEvents_Event GetFeatureLibraryEvents(this SolidEdgeFramework.Application application)
129 | //{
130 | // return (SolidEdgeFramework.ISEFeatureLibraryEvents_Event)application.FeatureLibraryEvents;
131 | //}
132 |
133 | /////
134 | ///// Returns the file UI events.
135 | /////
136 | //public static SolidEdgeFramework.ISEFileUIEvents_Event GetFileUIEvents(this SolidEdgeFramework.Application application)
137 | //{
138 | // return (SolidEdgeFramework.ISEFileUIEvents_Event)application.FileUIEvents;
139 | //}
140 |
141 | ///
142 | /// Returns the value of a specified global constant.
143 | ///
144 | public static object GetGlobalParameter(this SolidEdgeFramework.Application application, SolidEdgeFramework.ApplicationGlobalConstants globalConstant)
145 | {
146 | object value = null;
147 | application.GetGlobalParameter(globalConstant, ref value);
148 | return value;
149 | }
150 |
151 | ///
152 | /// Returns the value of a specified global constant.
153 | ///
154 | /// The type to return.
155 | public static T GetGlobalParameter(this SolidEdgeFramework.Application application, SolidEdgeFramework.ApplicationGlobalConstants globalConstant)
156 | {
157 | object value = null;
158 | application.GetGlobalParameter(globalConstant, ref value);
159 | return (T)value;
160 | }
161 |
162 | ///
163 | /// Returns a NativeWindow object that represents the main application window.
164 | ///
165 | public static NativeWindow GetNativeWindow(this SolidEdgeFramework.Application application)
166 | {
167 | return NativeWindow.FromHandle(new IntPtr(application.hWnd));
168 | }
169 |
170 | /////
171 | ///// Returns the new file UI events.
172 | /////
173 | //public static SolidEdgeFramework.ISENewFileUIEvents_Event GetNewFileUIEvents(this SolidEdgeFramework.Application application)
174 | //{
175 | // return (SolidEdgeFramework.ISENewFileUIEvents_Event)application.NewFileUIEvents;
176 | //}
177 |
178 | /////
179 | ///// Returns the SEEC events.
180 | /////
181 | //public static SolidEdgeFramework.ISEECEvents_Event GetSEECEvents(this SolidEdgeFramework.Application application)
182 | //{
183 | // return (SolidEdgeFramework.ISEECEvents_Event)application.SEECEvents;
184 | //}
185 |
186 | ///
187 | /// Returns a Process object that represents the application prcoess.
188 | ///
189 | public static Process GetProcess(this SolidEdgeFramework.Application application)
190 | {
191 | return Process.GetProcessById(application.ProcessID);
192 | }
193 |
194 | /////
195 | ///// Returns the shortcut menu events.
196 | /////
197 | //public static SolidEdgeFramework.ISEShortCutMenuEvents_Event GetShortcutMenuEvents(this SolidEdgeFramework.Application application)
198 | //{
199 | // return (SolidEdgeFramework.ISEShortCutMenuEvents_Event)application.ShortcutMenuEvents;
200 | //}
201 |
202 | ///
203 | /// Returns a Version object that represents the application version.
204 | ///
205 | public static Version GetVersion(this SolidEdgeFramework.Application application)
206 | {
207 | return new Version(application.Version);
208 | }
209 |
210 | ///
211 | /// Returns a point object to the application main window.
212 | ///
213 | public static IntPtr GetWindowHandle(this SolidEdgeFramework.Application application)
214 | {
215 | return new IntPtr(application.hWnd);
216 | }
217 |
218 | ///
219 | /// Activates a specified Solid Edge command.
220 | ///
221 | public static void StartCommand(this SolidEdgeFramework.Application application, SolidEdgeConstants.AssemblyCommandConstants CommandID)
222 | {
223 | application.StartCommand((SolidEdgeFramework.SolidEdgeCommandConstants)CommandID);
224 | }
225 |
226 | ///
227 | /// Activates a specified Solid Edge command.
228 | ///
229 | public static void StartCommand(this SolidEdgeFramework.Application application, SolidEdgeConstants.CuttingPlaneLineCommandConstants CommandID)
230 | {
231 | application.StartCommand((SolidEdgeFramework.SolidEdgeCommandConstants)CommandID);
232 | }
233 |
234 | ///
235 | /// Activates a specified Solid Edge command.
236 | ///
237 | public static void StartCommand(this SolidEdgeFramework.Application application, SolidEdgeConstants.DetailCommandConstants CommandID)
238 | {
239 | application.StartCommand((SolidEdgeFramework.SolidEdgeCommandConstants)CommandID);
240 | }
241 |
242 | ///
243 | /// Activates a specified Solid Edge command.
244 | ///
245 | public static void StartCommand(this SolidEdgeFramework.Application application, SolidEdgeConstants.DrawingViewEditCommandConstants CommandID)
246 | {
247 | application.StartCommand((SolidEdgeFramework.SolidEdgeCommandConstants)CommandID);
248 | }
249 |
250 | ///
251 | /// Activates a specified Solid Edge command.
252 | ///
253 | public static void StartCommand(this SolidEdgeFramework.Application application, SolidEdgeConstants.ExplodeCommandConstants CommandID)
254 | {
255 | application.StartCommand((SolidEdgeFramework.SolidEdgeCommandConstants)CommandID);
256 | }
257 |
258 | ///
259 | /// Activates a specified Solid Edge command.
260 | ///
261 | public static void StartCommand(this SolidEdgeFramework.Application application, SolidEdgeConstants.LayoutCommandConstants CommandID)
262 | {
263 | application.StartCommand((SolidEdgeFramework.SolidEdgeCommandConstants)CommandID);
264 | }
265 |
266 | ///
267 | /// Activates a specified Solid Edge command.
268 | ///
269 | public static void StartCommand(this SolidEdgeFramework.Application application, SolidEdgeConstants.LayoutInPartCommandConstants CommandID)
270 | {
271 | application.StartCommand((SolidEdgeFramework.SolidEdgeCommandConstants)CommandID);
272 | }
273 |
274 | ///
275 | /// Activates a specified Solid Edge command.
276 | ///
277 | public static void StartCommand(this SolidEdgeFramework.Application application, SolidEdgeConstants.MotionCommandConstants CommandID)
278 | {
279 | application.StartCommand((SolidEdgeFramework.SolidEdgeCommandConstants)CommandID);
280 | }
281 |
282 | ///
283 | /// Activates a specified Solid Edge command.
284 | ///
285 | public static void StartCommand(this SolidEdgeFramework.Application application, SolidEdgeConstants.PartCommandConstants CommandID)
286 | {
287 | application.StartCommand((SolidEdgeFramework.SolidEdgeCommandConstants)CommandID);
288 | }
289 |
290 | ///
291 | /// Activates a specified Solid Edge command.
292 | ///
293 | public static void StartCommand(this SolidEdgeFramework.Application application, SolidEdgeConstants.ProfileCommandConstants CommandID)
294 | {
295 | application.StartCommand((SolidEdgeFramework.SolidEdgeCommandConstants)CommandID);
296 | }
297 |
298 | ///
299 | /// Activates a specified Solid Edge command.
300 | ///
301 | public static void StartCommand(this SolidEdgeFramework.Application application, SolidEdgeConstants.ProfileHoleCommandConstants CommandID)
302 | {
303 | application.StartCommand((SolidEdgeFramework.SolidEdgeCommandConstants)CommandID);
304 | }
305 |
306 | ///
307 | /// Activates a specified Solid Edge command.
308 | ///
309 | public static void StartCommand(this SolidEdgeFramework.Application application, SolidEdgeConstants.ProfilePatternCommandConstants CommandID)
310 | {
311 | application.StartCommand((SolidEdgeFramework.SolidEdgeCommandConstants)CommandID);
312 | }
313 |
314 | ///
315 | /// Activates a specified Solid Edge command.
316 | ///
317 | public static void StartCommand(this SolidEdgeFramework.Application application, SolidEdgeConstants.ProfileRevolvedCommandConstants CommandID)
318 | {
319 | application.StartCommand((SolidEdgeFramework.SolidEdgeCommandConstants)CommandID);
320 | }
321 |
322 | ///
323 | /// Activates a specified Solid Edge command.
324 | ///
325 | public static void StartCommand(this SolidEdgeFramework.Application application, SolidEdgeConstants.SheetMetalCommandConstants CommandID)
326 | {
327 | application.StartCommand((SolidEdgeFramework.SolidEdgeCommandConstants)CommandID);
328 | }
329 |
330 | ///
331 | /// Activates a specified Solid Edge command.
332 | ///
333 | public static void StartCommand(this SolidEdgeFramework.Application application, SolidEdgeConstants.SimplifyCommandConstants CommandID)
334 | {
335 | application.StartCommand((SolidEdgeFramework.SolidEdgeCommandConstants)CommandID);
336 | }
337 |
338 | ///
339 | /// Activates a specified Solid Edge command.
340 | ///
341 | public static void StartCommand(this SolidEdgeFramework.Application application, SolidEdgeConstants.SolidEdgeCommandConstants CommandID)
342 | {
343 | application.StartCommand((SolidEdgeFramework.SolidEdgeCommandConstants)CommandID);
344 | }
345 |
346 | ///
347 | /// Activates a specified Solid Edge command.
348 | ///
349 | public static void StartCommand(this SolidEdgeFramework.Application application, SolidEdgeConstants.StudioCommandConstants CommandID)
350 | {
351 | application.StartCommand((SolidEdgeFramework.SolidEdgeCommandConstants)CommandID);
352 | }
353 |
354 | ///
355 | /// Activates a specified Solid Edge command.
356 | ///
357 | public static void StartCommand(this SolidEdgeFramework.Application application, SolidEdgeConstants.TubingCommandConstants CommandID)
358 | {
359 | application.StartCommand((SolidEdgeFramework.SolidEdgeCommandConstants)CommandID);
360 | }
361 |
362 | ///
363 | /// Activates a specified Solid Edge command.
364 | ///
365 | public static void StartCommand(this SolidEdgeFramework.Application application, SolidEdgeConstants.WeldmentCommandConstants CommandID)
366 | {
367 | application.StartCommand((SolidEdgeFramework.SolidEdgeCommandConstants)CommandID);
368 | }
369 |
370 | ///
371 | /// Activates a specified Solid Edge command.
372 | ///
373 | public static void StartCommand(this SolidEdgeFramework.Application application, SolidEdgeFramework.SolidEdgeCommandConstants CommandID)
374 | {
375 | application.StartCommand((SolidEdgeFramework.SolidEdgeCommandConstants)CommandID);
376 | }
377 |
378 | ///
379 | /// Shows the form with the application main window as the owner.
380 | ///
381 | public static void Show(this SolidEdgeFramework.Application application, System.Windows.Forms.Form form)
382 | {
383 | if (form == null) throw new ArgumentNullException("form");
384 |
385 | form.Show(application.GetNativeWindow());
386 | }
387 |
388 | ///
389 | /// Shows the form as a modal dialog box with the application main window as the owner.
390 | ///
391 | public static DialogResult ShowDialog(this SolidEdgeFramework.Application application, System.Windows.Forms.Form form)
392 | {
393 | if (form == null) throw new ArgumentNullException("form");
394 |
395 | return form.ShowDialog(application.GetNativeWindow());
396 | }
397 |
398 | ///
399 | /// Shows the form as a modal dialog box with the application main window as the owner.
400 | ///
401 | public static DialogResult ShowDialog(this SolidEdgeFramework.Application application, CommonDialog dialog)
402 | {
403 | if (dialog == null) throw new ArgumentNullException("dialog");
404 | return dialog.ShowDialog(application.GetNativeWindow());
405 | }
406 | }
407 | }
408 |
--------------------------------------------------------------------------------
/src/SolidEdge.Community/Extensions/Arc3DExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SolidEdgeCommunity.Extensions
7 | {
8 | ///
9 | /// SolidEdgePart.Arc3D extension methods.
10 | ///
11 | public static class Arc3DExtensions
12 | {
13 | public static double[] SafeGetKeypointPosition(this SolidEdgePart.Arc3D arc3d, SolidEdgePart.Sketch3DKeypointType KeypointType, bool throwOnError = false)
14 | {
15 | var position = Array.CreateInstance(typeof(double), 0);
16 |
17 | try
18 | {
19 | // GetKeypointPosition may throw an exception so wrap in try\catch.
20 | arc3d.GetKeypointPosition(KeypointType, ref position);
21 | }
22 | catch
23 | {
24 | if (throwOnError) throw;
25 | }
26 |
27 | return position.OfType().ToArray();
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/src/SolidEdge.Community/Extensions/AssemblyDocumentExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SolidEdgeCommunity.Extensions
7 | {
8 | ///
9 | /// SolidEdgeAssembly.AssemblyDocument extension methods.
10 | ///
11 | public static class AssemblyDocumentExtensions
12 | {
13 | ///
14 | /// Returns the version of Solid Edge that was used to create the referenced document.
15 | ///
16 | ///
17 | ///
18 | public static Version GetCreatedVersion(this SolidEdgeAssembly.AssemblyDocument document)
19 | {
20 | return new Version(document.CreatedVersion);
21 | }
22 |
23 | ///
24 | /// Returns the version of Solid Edge that was used the last time the referenced document was saved.
25 | ///
26 | ///
27 | ///
28 | public static Version GetLastSavedVersion(this SolidEdgeAssembly.AssemblyDocument document)
29 | {
30 | return new Version(document.LastSavedVersion);
31 | }
32 |
33 | ///
34 | /// Returns the properties for the referenced document.
35 | ///
36 | ///
37 | ///
38 | public static SolidEdgeFramework.PropertySets GetProperties(this SolidEdgeAssembly.AssemblyDocument document)
39 | {
40 | return document.Properties as SolidEdgeFramework.PropertySets;
41 | }
42 |
43 | ///
44 | /// Returns the summary information property set for the referenced document.
45 | ///
46 | ///
47 | ///
48 | public static SolidEdgeFramework.SummaryInfo GetSummaryInfo(this SolidEdgeAssembly.AssemblyDocument document)
49 | {
50 | return document.SummaryInfo as SolidEdgeFramework.SummaryInfo;
51 | }
52 |
53 | ///
54 | /// Returns a collection of variables for the referenced document.
55 | ///
56 | ///
57 | ///
58 | public static SolidEdgeFramework.Variables GetVariables(this SolidEdgeAssembly.AssemblyDocument document)
59 | {
60 | return document.Variables as SolidEdgeFramework.Variables;
61 | }
62 | }
63 | }
64 |
--------------------------------------------------------------------------------
/src/SolidEdge.Community/Extensions/DocumentsExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Reflection;
5 | using System.Text;
6 |
7 | namespace SolidEdgeCommunity.Extensions
8 | {
9 | ///
10 | /// SolidEdgeFramework.Documents extension methods.
11 | ///
12 | public static class DocumentsExtensions
13 | {
14 | ///
15 | /// Creates a new document.
16 | ///
17 | internal static TDocumentType Add(this SolidEdgeFramework.Documents documents, string progId) where TDocumentType : class
18 | {
19 | return (TDocumentType)documents.Add(progId);
20 | }
21 |
22 | ///
23 | /// Creates a new document.
24 | ///
25 | internal static TDocumentType Add(this SolidEdgeFramework.Documents documents, string progId, object TemplateDoc) where TDocumentType : class
26 | {
27 | return (TDocumentType)documents.Add(progId, TemplateDoc);
28 | }
29 |
30 | ///
31 | /// Creates a new document.
32 | ///
33 | /// SolidEdgeAssembly.AssemblyDocument, SolidEdgeDraft.DraftDocument, SolidEdgePart.PartDocument or SolidEdgePart.SheetMetalDocument.
34 | ///
35 | ///
36 | public static TDocumentType Add(this SolidEdgeFramework.Documents documents) where TDocumentType : class
37 | {
38 | var t = typeof(TDocumentType);
39 |
40 | if (t.Equals(typeof(SolidEdgeAssembly.AssemblyDocument)))
41 | {
42 | return (TDocumentType)documents.AddAssemblyDocument();
43 | }
44 | else if (t.Equals(typeof(SolidEdgeDraft.DraftDocument)))
45 | {
46 | return (TDocumentType)documents.AddDraftDocument();
47 | }
48 | else if (t.Equals(typeof(SolidEdgePart.PartDocument)))
49 | {
50 | return (TDocumentType)documents.AddPartDocument();
51 | }
52 | else if (t.Equals(typeof(SolidEdgePart.SheetMetalDocument)))
53 | {
54 | return (TDocumentType)documents.AddSheetMetalDocument();
55 | }
56 | else
57 | {
58 | throw new NotSupportedException();
59 | }
60 | }
61 |
62 | ///
63 | /// Creates a new assembly document.
64 | ///
65 | public static SolidEdgeAssembly.AssemblyDocument AddAssemblyDocument(this SolidEdgeFramework.Documents documents)
66 | {
67 | return documents.Add(SolidEdgeSDK.PROGID.SolidEdge_AssemblyDocument);
68 | }
69 |
70 | ///
71 | /// Creates a new assembly document.
72 | ///
73 | public static SolidEdgeAssembly.AssemblyDocument AddAssemblyDocument(this SolidEdgeFramework.Documents documents, object TemplateDoc)
74 | {
75 | return documents.Add(SolidEdgeSDK.PROGID.SolidEdge_AssemblyDocument, TemplateDoc);
76 | }
77 |
78 | ///
79 | /// Creates a new draft document.
80 | ///
81 | public static SolidEdgeDraft.DraftDocument AddDraftDocument(this SolidEdgeFramework.Documents documents)
82 | {
83 | return documents.Add(SolidEdgeSDK.PROGID.SolidEdge_DraftDocument);
84 | }
85 |
86 | ///
87 | /// Creates a new draft document.
88 | ///
89 | public static SolidEdgeDraft.DraftDocument AddDraftDocument(this SolidEdgeFramework.Documents documents, object TemplateDoc)
90 | {
91 | return documents.Add(SolidEdgeSDK.PROGID.SolidEdge_DraftDocument, TemplateDoc);
92 | }
93 |
94 | ///
95 | /// Creates a new part document.
96 | ///
97 | public static SolidEdgePart.PartDocument AddPartDocument(this SolidEdgeFramework.Documents documents)
98 | {
99 | return documents.Add(SolidEdgeSDK.PROGID.SolidEdge_PartDocument);
100 | }
101 |
102 | ///
103 | /// Creates a new part document.
104 | ///
105 | public static SolidEdgePart.PartDocument AddPartDocument(this SolidEdgeFramework.Documents documents, object TemplateDoc)
106 | {
107 | return documents.Add(SolidEdgeSDK.PROGID.SolidEdge_PartDocument, TemplateDoc);
108 | }
109 |
110 | ///
111 | /// Creates a new sheetmetal document.
112 | ///
113 | public static SolidEdgePart.SheetMetalDocument AddSheetMetalDocument(this SolidEdgeFramework.Documents documents)
114 | {
115 | return documents.Add(SolidEdgeSDK.PROGID.SolidEdge_SheetMetalDocument);
116 | }
117 |
118 | ///
119 | /// Creates a new sheetmetal document.
120 | ///
121 | public static SolidEdgePart.SheetMetalDocument AddSheetMetalDocument(this SolidEdgeFramework.Documents documents, object TemplateDoc)
122 | {
123 | return documents.Add(SolidEdgeSDK.PROGID.SolidEdge_SheetMetalDocument, TemplateDoc);
124 | }
125 |
126 | ///
127 | /// Opens an existing Solid Edge document.
128 | ///
129 | public static TDocumentType Open(this SolidEdgeFramework.Documents documents, string Filename) where TDocumentType : class
130 | {
131 | return (TDocumentType)documents.Open(Filename);
132 | }
133 |
134 | ///
135 | /// Opens an existing Solid Edge document.
136 | ///
137 | public static TDocumentType Open(this SolidEdgeFramework.Documents documents, string Filename, object DocRelationAutoServer, object AltPath, object RecognizeFeaturesIfPartTemplate, object RevisionRuleOption, object StopFileOpenIfRevisionRuleNotApplicable)
138 | {
139 | return (TDocumentType)documents.Open(Filename, DocRelationAutoServer, AltPath, RecognizeFeaturesIfPartTemplate, RevisionRuleOption, StopFileOpenIfRevisionRuleNotApplicable);
140 | }
141 |
142 | ///
143 | /// Opens an existing Solid Edge document in the background with no window.
144 | ///
145 | public static TDocumentType OpenInBackground(this SolidEdgeFramework.Documents documents, string Filename)
146 | {
147 | ulong JDOCUMENTPROP_NOWINDOW = 0x00000008;
148 | return (TDocumentType)documents.Open(Filename, JDOCUMENTPROP_NOWINDOW);
149 | }
150 |
151 | ///
152 | /// Opens an existing Solid Edge document in the background with no window.
153 | ///
154 | public static TDocumentType OpenInBackground(this SolidEdgeFramework.Documents documents, string Filename, object AltPath, object RecognizeFeaturesIfPartTemplate, object RevisionRuleOption, object StopFileOpenIfRevisionRuleNotApplicable)
155 | {
156 | ulong JDOCUMENTPROP_NOWINDOW = 0x00000008;
157 | return (TDocumentType)documents.Open(Filename, JDOCUMENTPROP_NOWINDOW, AltPath, RecognizeFeaturesIfPartTemplate, RevisionRuleOption, StopFileOpenIfRevisionRuleNotApplicable);
158 | }
159 | }
160 | }
161 |
--------------------------------------------------------------------------------
/src/SolidEdge.Community/Extensions/DraftDocumentExtensions.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace SolidEdgeCommunity.Extensions
7 | {
8 | ///
9 | /// SolidEdgeDraft.DraftDocument extensions.
10 | ///
11 | public static class DraftDocumentExtensions
12 | {
13 | ///
14 | /// Returns an enumerable collection of drawing objects.
15 | ///
16 | ///
17 | ///
18 | public static IEnumerable