Skip to content

Commit 5aa0c98

Browse files
committed
Update SnoopCommand.cs
1 parent 7c7fd49 commit 5aa0c98

File tree

1 file changed

+2
-55
lines changed

1 file changed

+2
-55
lines changed

CADPythonShell/SnoopCommand.cs

Lines changed: 2 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,4 @@
1-
using Autodesk.AutoCAD.ApplicationServices;
2-
using Autodesk.AutoCAD.DatabaseServices;
3-
using Autodesk.AutoCAD.EditorInput;
4-
using Autodesk.AutoCAD.Runtime;
5-
using CADSnoop.Model;
6-
using CADSnoop.View;
7-
using CADSnoop.ViewModel;
8-
using Exception = System.Exception;
9-
using Application = Autodesk.AutoCAD.ApplicationServices.Core.Application;
10-
using MessageBox = System.Windows.MessageBox;
1+
using Autodesk.AutoCAD.Runtime;
112

123
namespace CADPythonShell
134
{
@@ -16,51 +7,7 @@ public class SnoopCommand
167
[CommandMethod("Snoop")]
178
public void Execute()
189
{
19-
try
20-
{
21-
Document doc = Application.DocumentManager.MdiActiveDocument;
22-
Editor ed = doc.Editor;
23-
Database db = doc.Database;
24-
using (Transaction tran = db.TransactionManager.StartTransaction())
25-
{
26-
List<ObjectId> objectIds = PickObjectBySelect(doc);
27-
if (objectIds!=null)
28-
{
29-
SnoopViewModel vm = new SnoopViewModel(doc, db, objectIds);
30-
MainWindow form = new MainWindow(vm);
31-
form.SetCadAsWindowOwner();
32-
form.Show();
33-
}
34-
tran.Commit();
35-
36-
}
37-
}
38-
catch (Exception ex)
39-
{
40-
MessageBox.Show(ex.ToString());
41-
}
42-
}
43-
44-
List<ObjectId> PickObjectBySelect(Document doc)
45-
{
46-
try
47-
{
48-
//PromptSelectionOptions poOptions = new PromptSelectionOptions();
49-
//poOptions.SingleOnly = true;
50-
PromptSelectionResult promptSelectionResult = doc.Editor.GetSelection();
51-
if (promptSelectionResult.Status != PromptStatus.OK) return null;
52-
SelectionSet selectionSet = promptSelectionResult.Value;
53-
return selectionSet.GetObjectIds().ToList();
54-
}
55-
catch(ArgumentNullException){}
56-
catch(NullReferenceException){}
57-
catch (Exception e)
58-
{
59-
MessageBox.Show(e.ToString());
60-
}
61-
62-
return null;
10+
new CADSnoop.SnoopCommand().Execute();
6311
}
64-
6512
}
6613
}

0 commit comments

Comments
 (0)