├── .gitattributes
├── .gitignore
├── App.config
├── CADSnoop.csproj
├── Documents
├── SnoopCad.gif
└── _Image_bfad9808-fa10-4857-8d77-f1f0b161433f.png
├── LICENSE
├── Model
├── ObjectDetails.cs
├── RelayCommand.cs
├── ViewModelBase.cs
└── WindowHandle.cs
├── PackageContents.xml
├── Properties
├── AssemblyInfo.cs
├── Resources.Designer.cs
├── Resources.resx
├── Settings.Designer.cs
└── Settings.settings
├── README.md
├── SnoopAutoCADCSharp.bundle
├── PackageContents.xml
└── SnoopAutoCADCSharp.dll
├── SnoopAutoCADCSharp.sln
├── SnoopCommand.cs
├── View
├── MainWindow.xaml
└── MainWindow.xaml.cs
├── ViewModel
├── SnoopViewModel.cs
└── TreeViewCustom.cs
└── inno_setup
├── Installer.iss
└── Output
└── SnoopAutoCADCSharp setup.exe
/.gitattributes:
--------------------------------------------------------------------------------
1 | ###############################################################################
2 | # Set default behavior to automatically normalize line endings.
3 | ###############################################################################
4 | * text=auto
5 |
6 | ###############################################################################
7 | # Set default behavior for command prompt diff.
8 | #
9 | # This is need for earlier builds of msysgit that does not have it on by
10 | # default for csharp files.
11 | # Note: This is only used by command line
12 | ###############################################################################
13 | #*.cs diff=csharp
14 |
15 | ###############################################################################
16 | # Set the merge driver for project and solution files
17 | #
18 | # Merging from the command prompt will add diff markers to the files if there
19 | # are conflicts (Merging from VS is not affected by the settings below, in VS
20 | # the diff markers are never inserted). Diff markers may cause the following
21 | # file extensions to fail to load in VS. An alternative would be to treat
22 | # these files as binary and thus will always conflict and require user
23 | # intervention with every merge. To do so, just uncomment the entries below
24 | ###############################################################################
25 | #*.sln merge=binary
26 | #*.csproj merge=binary
27 | #*.vbproj merge=binary
28 | #*.vcxproj merge=binary
29 | #*.vcproj merge=binary
30 | #*.dbproj merge=binary
31 | #*.fsproj merge=binary
32 | #*.lsproj merge=binary
33 | #*.wixproj merge=binary
34 | #*.modelproj merge=binary
35 | #*.sqlproj merge=binary
36 | #*.wwaproj merge=binary
37 |
38 | ###############################################################################
39 | # behavior for image files
40 | #
41 | # image files are treated as binary by default.
42 | ###############################################################################
43 | #*.jpg binary
44 | #*.png binary
45 | #*.gif binary
46 |
47 | ###############################################################################
48 | # diff behavior for common document formats
49 | #
50 | # Convert binary document formats to text before diffing them. This feature
51 | # is only available from the command line. Turn it on by uncommenting the
52 | # entries below.
53 | ###############################################################################
54 | #*.doc diff=astextplain
55 | #*.DOC diff=astextplain
56 | #*.docx diff=astextplain
57 | #*.DOCX diff=astextplain
58 | #*.dot diff=astextplain
59 | #*.DOT diff=astextplain
60 | #*.pdf diff=astextplain
61 | #*.PDF diff=astextplain
62 | #*.rtf diff=astextplain
63 | #*.RTF diff=astextplain
64 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | #Ignore thumbnails created by Windows
2 | Thumbs.db
3 |
4 | #Ignore files built by Visual Studio
5 | *.obj
6 | *.exe
7 | *.pdb
8 | *.user
9 | *.aps
10 | *.pch
11 | *.vspscc
12 | *_i.c
13 | *_p.c
14 | *.ncb
15 | *.suo
16 | *.tlb
17 | *.tlh
18 | *.bak
19 | *.cache
20 | *.ilk
21 | *.log
22 | *.iref
23 | *.db
24 | *.ide
25 | *.opendb
26 | *.lock
27 | *.ide-shm
28 | *.ide-wal
29 | [Bb]in
30 | [Dd]ebug*/
31 | *.lib
32 | *.sbr
33 | obj/
34 | [Rr]elease*/
35 | _ReSharper*/
36 | [Tt]est[Rr]esult*
37 | .vs/
38 |
39 | #Nuget packages folder
40 | packages/
41 |
42 |
43 |
--------------------------------------------------------------------------------
/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/CADSnoop.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 | net48
4 | Library
5 | false
6 | true
7 | true
8 | true
9 |
10 |
11 |
12 |
13 |
14 |
15 | None
16 |
17 |
18 |
19 |
20 | ..\RefrencedAssemblies\accoremgd.dll
21 |
22 |
23 | ..\RefrencedAssemblies\acdbmgd.dll
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
--------------------------------------------------------------------------------
/Documents/SnoopCad.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/htlcnn/AutoCADLookup/32944bd352e13d5276d8ed5039967e7472f77c59/Documents/SnoopCad.gif
--------------------------------------------------------------------------------
/Documents/_Image_bfad9808-fa10-4857-8d77-f1f0b161433f.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/htlcnn/AutoCADLookup/32944bd352e13d5276d8ed5039967e7472f77c59/Documents/_Image_bfad9808-fa10-4857-8d77-f1f0b161433f.png
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2020 Long
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 |
--------------------------------------------------------------------------------
/Model/ObjectDetails.cs:
--------------------------------------------------------------------------------
1 | using System;
2 |
3 | namespace CADSnoop.Model
4 | {
5 | ///
6 | /// Information Of Object
7 | ///
8 | public class ObjectDetails
9 | {
10 | public string GroupName { get; set; }
11 | public string PropName { get; set; }
12 | public string Type { get; set; }
13 | public string Value { get; set; }
14 | public Object LinkObject { get; set; }
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/Model/RelayCommand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Windows.Input;
3 |
4 | namespace CADSnoop.Model
5 | {
6 | public class RelayCommand : ICommand
7 | {
8 | readonly Action _execute;
9 | readonly Func _canExecute;
10 |
11 | public RelayCommand(Action execute, Func canExecute)
12 | {
13 | if (execute == null)
14 | throw new NullReferenceException("execute");
15 |
16 | _execute = execute;
17 | _canExecute = canExecute;
18 | }
19 |
20 | public RelayCommand(Action execute) : this(execute, null)
21 | {
22 |
23 | }
24 |
25 | public event EventHandler CanExecuteChanged
26 | {
27 | add => CommandManager.RequerySuggested += value;
28 | remove => CommandManager.RequerySuggested -= value;
29 | }
30 |
31 | public bool CanExecute(object parameter)
32 | {
33 | return _canExecute == null ? true : _canExecute();
34 | }
35 |
36 | public void Execute(object parameter)
37 | {
38 | _execute.Invoke();
39 | }
40 | }
41 | }
42 |
--------------------------------------------------------------------------------
/Model/ViewModelBase.cs:
--------------------------------------------------------------------------------
1 | using System.ComponentModel;
2 | using System.Diagnostics;
3 | using System.Globalization;
4 | using System.Reflection;
5 | using System.Runtime.CompilerServices;
6 |
7 | namespace CADSnoop.Model
8 | {
9 | public class ViewModelBase : INotifyPropertyChanged
10 | {
11 | public event PropertyChangedEventHandler PropertyChanged;
12 |
13 | public virtual void OnPropertyChanged([CallerMemberName] string propertyName = null)
14 | {
15 | PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
16 | }
17 |
18 | //
19 | /// Called when the specified property has been changed.
20 | ///
21 | /// Name of the property.
22 | /// The old value.
23 | /// The new value.
24 | protected virtual void OnPropertyChanged(string propertyName, object oldValue, object newValue)
25 | {
26 | this.OnPropertyChanged(propertyName);
27 | }
28 |
29 | #region Can Optimize
30 | ///
31 | ///
32 | ///
33 | ///
34 | ///
35 | ///
36 | ///
37 | public void OnPropertyChanged(ref T property, T value, [CallerMemberName] string propertyName = "")
38 | {
39 | property = value;
40 | var handler = PropertyChanged;
41 | if (handler != null)
42 | {
43 | PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
44 | }
45 | }
46 |
47 | #endregion
48 |
49 | ///
50 | /// Sets the property value.
51 | ///
52 | /// The type of the property.
53 | /// The field.
54 | /// The value.
55 | /// Name of the property.
56 | ///
57 | /// True if the property was set.
58 | ///
59 | /// This method uses the CallerMemberNameAttribute to determine the property name.
60 | protected bool SetValue(ref T field, T value, [System.Runtime.CompilerServices.CallerMemberName] string propertyName = "")
61 | {
62 | // ReSharper disable once RedundantNameQualifier
63 | if (object.Equals(field, value))
64 | {
65 | return false;
66 | }
67 | this.VerifyProperty(propertyName);
68 | //// this.OnPropertyChanging(propertyName, field, value);
69 | T oldValue = field;
70 | field = value;
71 | this.OnPropertyChanged(propertyName, oldValue, value);
72 | return true;
73 | }
74 |
75 | ///
76 | /// Verifies the property name.
77 | ///
78 | /// Name of the property.
79 | [Conditional("DEBUG")]
80 | private void VerifyProperty(string propertyName)
81 | {
82 | var type = this.GetType();
83 |
84 | // Look for a public property with the specified name.
85 | var propertyInfo = type.GetTypeInfo().GetDeclaredProperty(propertyName);
86 |
87 | Debug.Assert(propertyInfo != null, string.Format(CultureInfo.InvariantCulture, "{0} is not a property of {1}", propertyName, type.FullName));
88 | }
89 | }
90 | }
--------------------------------------------------------------------------------
/Model/WindowHandle.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Diagnostics;
3 | using System.Runtime.InteropServices;
4 | using System.Windows;
5 | using System.Windows.Interop;
6 |
7 | namespace CADSnoop.Model
8 | {
9 | public static class WindowHandle
10 | {
11 | [DllImport("kernel32.dll")]
12 | public static extern uint GetCurrentThreadId();
13 |
14 | ///
15 | /// Sets the given window's owner to Cad window.
16 | ///
17 | /// Target window.
18 | public static void SetCadAsWindowOwner(this Window dialog)
19 | {
20 | if (null == dialog) { return; }
21 |
22 | WindowInteropHelper helper = new WindowInteropHelper(dialog);
23 | helper.Owner = FindCadWindowHandle();
24 | }
25 |
26 | ///
27 | /// Finds the Cad window handle.
28 | ///
29 | /// Revit window handle.
30 | public static IntPtr FindCadWindowHandle()
31 | {
32 | try
33 | {
34 | IntPtr foundRevitHandle = IntPtr.Zero;
35 | uint currentThreadID = GetCurrentThreadId();
36 |
37 | // Search for the Revit process with current thread ID.
38 | Process[] revitProcesses = Process.GetProcessesByName("acad");
39 | Process foundRevitProcess = null;
40 | foreach (Process aRevitProcess in revitProcesses)
41 | {
42 | foreach (ProcessThread aThread in aRevitProcess.Threads)
43 | {
44 | if (aThread.Id == currentThreadID)
45 | {
46 | foundRevitProcess = aRevitProcess;
47 | break;
48 | }
49 | } // For each thread in the process.
50 |
51 | // When we have found our Revit process, then stop searching.
52 | if (null != foundRevitProcess) { break; }
53 | } // For each revit process found
54 |
55 | if (null != foundRevitProcess)
56 | {
57 | foundRevitHandle = foundRevitProcess.MainWindowHandle;
58 | }
59 |
60 | return foundRevitHandle;
61 | }
62 | catch (Exception)
63 | {
64 | return IntPtr.Zero;
65 | }
66 | }
67 | }
68 | }
69 |
--------------------------------------------------------------------------------
/PackageContents.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
10 |
11 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Resources;
3 | using System.Runtime.CompilerServices;
4 | using System.Runtime.InteropServices;
5 | using System.Windows;
6 |
7 | // General Information about an assembly is controlled through the following
8 | // set of attributes. Change these attribute values to modify the information
9 | // associated with an assembly.
10 | [assembly: AssemblyTitle("SnooAutoCADCSharp")]
11 | [assembly: AssemblyDescription("")]
12 | [assembly: AssemblyConfiguration("")]
13 | [assembly: AssemblyCompany("HTL")]
14 | [assembly: AssemblyProduct("SnooAutoCADCSharp")]
15 | [assembly: AssemblyCopyright("Copyright © HTL 2020")]
16 | [assembly: AssemblyTrademark("")]
17 | [assembly: AssemblyCulture("")]
18 |
19 | // Setting ComVisible to false makes the types in this assembly not visible
20 | // to COM components. If you need to access a type in this assembly from
21 | // COM, set the ComVisible attribute to true on that type.
22 | [assembly: ComVisible(false)]
23 |
24 | //In order to begin building localizable applications, set
25 | //CultureYouAreCodingWith in your .csproj file
26 | //inside a . For example, if you are using US english
27 | //in your source files, set the to en-US. Then uncomment
28 | //the NeutralResourceLanguage attribute below. Update the "en-US" in
29 | //the line below to match the UICulture setting in the project file.
30 |
31 | //[assembly: NeutralResourcesLanguage("en-US", UltimateResourceFallbackLocation.Satellite)]
32 |
33 |
34 | [assembly: ThemeInfo(
35 | ResourceDictionaryLocation.None, //where theme specific resource dictionaries are located
36 | //(used if a resource is not found in the page,
37 | // or application resource dictionaries)
38 | ResourceDictionaryLocation.SourceAssembly //where the generic resource dictionary is located
39 | //(used if a resource is not found in the page,
40 | // app, or any theme specific resource dictionaries)
41 | )]
42 |
43 |
44 | // Version information for an assembly consists of the following four values:
45 | //
46 | // Major Version
47 | // Minor Version
48 | // Build Number
49 | // Revision
50 | //
51 | // You can specify all the values or you can default the Build and Revision Numbers
52 | // by using the '*' as shown below:
53 | // [assembly: AssemblyVersion("1.0.*")]
54 | [assembly: AssemblyVersion("1.0.0.0")]
55 | [assembly: AssemblyFileVersion("1.0.0.0")]
56 |
--------------------------------------------------------------------------------
/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 SnoopAutoCADCSharp.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", "15.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("SnoopAutoCADCSharp.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 |
--------------------------------------------------------------------------------
/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 | text/microsoft-resx
107 |
108 |
109 | 2.0
110 |
111 |
112 | System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
113 |
114 |
115 | System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
116 |
117 |
--------------------------------------------------------------------------------
/Properties/Settings.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 SnoopAutoCADCSharp.Properties {
12 |
13 |
14 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
15 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "15.9.0.0")]
16 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase {
17 |
18 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
19 |
20 | public static Settings Default {
21 | get {
22 | return defaultInstance;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 | # AutoCADLookup
3 |
4 | 
5 | 
6 | 
7 | [](http://opensource.org/licenses/MIT)
8 |
9 | Interactive Autocad BIM database exploration tool to view and navigate element properties and relationships.
10 |
11 | ### Setup
12 |
13 | Open the SnoopAutoCADCSharp.sln on Visual Studio 2022. All references should be ready for AutoCAD 2022 default install path, otherwise go to project properties >> References, then click on Reference Paths and adjust. Build the project in Release, the DLL should be placed at same folder. Copy the entire .bundle folder to C:\Program Files\Autodesk\Autodesk\ApplicationPlugins folder and launch Autocad.
14 |
15 | ## Installation
16 |
17 | - Download last install stable(msi) from CadPythonShell [Release](https://github.com/chuongmep/CADPythonShell/releases/latest)
18 | - Use command `Snoop` to open Window or use button Snoop from Ribbon
19 | - See guide install detail at [How-to-Install-CadPythonShell](https://github.com/chuongmep/CadPythonShell/wiki/How-to-Install-CadPythonShell)
20 |
21 | Note : Support for 4 last version(2019-2022) Autocad or Civil 3D. Older versions can be used but will not guarantee the expected performance.
22 |
23 | # Usage
24 |
25 | - On AutoCAD , command the "Snoop" option, the main form should appear. At the left side is a list of the main collections on the active document. On the right side, the properties of the item selected on the left.
26 |
27 | - Can continue Snoop Database to check.
28 |
29 | 
30 |
31 | ### Author
32 |
33 | First Project write sypport Autocad and Civi3D with language VB.NET by Augusto Goncalves @augustomaia , member of the Autodesk Developer Technical Services team.
34 |
35 | Now project update in .NET C# by htlcnn and Hồ Văn Chương
36 |
37 | ### Known Issues
38 |
39 | The tool may stop working on some properties that cannot be reflected (using .NET).
40 |
41 | ### Demo
42 |
43 | 
44 |
45 | ### Release History
46 |
47 | 1.0.0 : First Release
48 |
49 |
50 |
--------------------------------------------------------------------------------
/SnoopAutoCADCSharp.bundle/PackageContents.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 |
10 |
11 |
16 |
17 |
18 |
19 |
20 |
21 |
--------------------------------------------------------------------------------
/SnoopAutoCADCSharp.bundle/SnoopAutoCADCSharp.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/htlcnn/AutoCADLookup/32944bd352e13d5276d8ed5039967e7472f77c59/SnoopAutoCADCSharp.bundle/SnoopAutoCADCSharp.dll
--------------------------------------------------------------------------------
/SnoopAutoCADCSharp.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio Version 17
4 | VisualStudioVersion = 17.2.32317.152
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "CADSnoop", "CADSnoop.csproj", "{4AB3C6E6-D513-461D-BA9A-6F081E50323A}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {4AB3C6E6-D513-461D-BA9A-6F081E50323A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {4AB3C6E6-D513-461D-BA9A-6F081E50323A}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {4AB3C6E6-D513-461D-BA9A-6F081E50323A}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {4AB3C6E6-D513-461D-BA9A-6F081E50323A}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | GlobalSection(ExtensibilityGlobals) = postSolution
23 | SolutionGuid = {7C89A58D-A042-49B9-8849-1DEF4397E06F}
24 | EndGlobalSection
25 | EndGlobal
26 |
--------------------------------------------------------------------------------
/SnoopCommand.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Windows;
5 | using Autodesk.AutoCAD.ApplicationServices;
6 | using Autodesk.AutoCAD.DatabaseServices;
7 | using Autodesk.AutoCAD.EditorInput;
8 | using Autodesk.AutoCAD.Runtime;
9 | using CADSnoop.Model;
10 | using CADSnoop.View;
11 | using CADSnoop.ViewModel;
12 | using Application = Autodesk.AutoCAD.ApplicationServices.Core.Application;
13 | using Exception = System.Exception;
14 |
15 | namespace CADSnoop
16 | {
17 | public class SnoopCommand
18 | {
19 | [CommandMethod("Snoop")]
20 | public void Snoop()
21 | {
22 | Snoop(new List());
23 | }
24 | ///
25 | /// Snoop Snoop a object by id
26 | ///
27 | ///
28 | public void Snoop(ObjectId objectId)
29 | {
30 | Snoop(new List(){objectId});
31 | }
32 | ///
33 | /// snoop by dbobject
34 | ///
35 | ///
36 | ///
37 | public void Snoop(DBObject dbObject)
38 | {
39 | if (dbObject == null) throw new ArgumentException(nameof(dbObject));
40 | Document doc = Application.DocumentManager.MdiActiveDocument;
41 | Editor ed = doc.Editor;
42 | Database db = doc.Database;
43 | using (DocumentLock lockDoc = doc.LockDocument())
44 | {
45 | using (Transaction tran = db.TransactionManager.StartTransaction())
46 | {
47 | {
48 | SnoopViewModel vm = new SnoopViewModel(doc, db, dbObject);
49 | MainWindow form = new MainWindow(vm);
50 | form.SetCadAsWindowOwner();
51 | form.Show();
52 | }
53 | tran.Commit();
54 | }
55 | }
56 | }
57 | ///
58 | /// Snoop snoop object by list object id
59 | ///
60 | ///
61 | public void Snoop(List objectIds)
62 | {
63 | try
64 | {
65 | Document doc = Application.DocumentManager.MdiActiveDocument;
66 | Editor ed = doc.Editor;
67 | Database db = doc.Database;
68 | using (DocumentLock lockDoc = doc.LockDocument())
69 | {
70 | using (Transaction tran = db.TransactionManager.StartTransaction())
71 | {
72 | if (objectIds == null || objectIds.Count==0) objectIds = PickObjectBySelect(doc);
73 | if (objectIds != null)
74 | {
75 | SnoopViewModel vm = new SnoopViewModel(doc, db, objectIds);
76 | MainWindow form = new MainWindow(vm);
77 | form.SetCadAsWindowOwner();
78 | form.Show();
79 | }
80 | tran.Commit();
81 | }
82 | }
83 | }
84 | catch (Exception ex)
85 | {
86 | MessageBox.Show(ex.ToString());
87 | }
88 | }
89 | List PickObjectBySelect(Document doc)
90 | {
91 | try
92 | {
93 | //PromptSelectionOptions poOptions = new PromptSelectionOptions();
94 | //poOptions.SingleOnly = true;
95 | PromptSelectionResult promptSelectionResult = doc.Editor.GetSelection();
96 | if (promptSelectionResult.Status != PromptStatus.OK) return null;
97 | SelectionSet selectionSet = promptSelectionResult.Value;
98 | return selectionSet.GetObjectIds().ToList();
99 | }
100 | catch (ArgumentNullException) { }
101 | catch (NullReferenceException) { }
102 | catch (Exception e)
103 | {
104 | MessageBox.Show(e.ToString());
105 | }
106 |
107 | return null;
108 | }
109 |
110 | }
111 | }
112 |
--------------------------------------------------------------------------------
/View/MainWindow.xaml:
--------------------------------------------------------------------------------
1 |
19 |
20 |
23 |
27 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
60 |
61 |
62 |
66 |
67 |
68 |
69 |
73 |
74 |
75 |
76 |
80 |
84 |
88 |
89 |
90 |
91 |
92 |
93 |
118 |
119 |
120 |
121 |
122 |
123 |
124 |
125 |
--------------------------------------------------------------------------------
/View/MainWindow.xaml.cs:
--------------------------------------------------------------------------------
1 | using System.Collections.Generic;
2 | using System.Windows;
3 | using System.Windows.Controls;
4 | using System.Windows.Input;
5 | using Autodesk.AutoCAD.DatabaseServices;
6 | using CADSnoop.Model;
7 | using CADSnoop.ViewModel;
8 | using Exception = System.Exception;
9 |
10 | namespace CADSnoop.View
11 | {
12 |
13 | ///
14 | /// Interaction logic for MainWindow.xaml
15 | ///
16 | public partial class MainWindow : Window
17 | {
18 | private SnoopViewModel _viewModel;
19 |
20 | public MainWindow()
21 | {
22 | InitializeComponent();
23 | }
24 | public MainWindow(SnoopViewModel vm) :this()
25 | {
26 | this._viewModel = vm;
27 | this.DataContext = vm;
28 | SnoopViewModel.FrmMain = this;
29 | }
30 |
31 | private void Treeview_SelectedItemChanged(object sender, RoutedPropertyChangedEventArgs