Skip to content

Commit 88a0e43

Browse files
committed
fix: VisualizationServerController start
1 parent 2ede5c7 commit 88a0e43

15 files changed

+916
-964
lines changed

source/RevitDevTool/Application.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@ public override void OnStartup()
1212
ExternalEventController.Register();
1313
AddButton(Application);
1414
AddDockable(Application);
15+
VisualizationServerController.Start();
16+
}
17+
18+
public override void OnShutdown()
19+
{
20+
VisualizationServerController.Stop();
1521
}
1622

1723
private static void AddDockable(UIControlledApplication application)

source/RevitDevTool/Geometry/TraceGeometry.cs

Lines changed: 0 additions & 75 deletions
This file was deleted.
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
using System.Diagnostics;
2+
3+
namespace RevitDevTool.Models;
4+
5+
public static class TraceGeometry
6+
{
7+
public static readonly TraceListener TraceListener = new TraceGeometryListener();
8+
9+
private static void Trace(object geometryObject)
10+
{
11+
VisualizationServerController.Add(geometryObject);
12+
}
13+
14+
private static void Trace(IEnumerable<object> geometries)
15+
{
16+
VisualizationServerController.Add(geometries);
17+
}
18+
19+
private class TraceGeometryListener : TraceListener
20+
{
21+
public override void Write(object? o)
22+
{
23+
switch (o)
24+
{
25+
case IEnumerable<GeometryObject> geometries:
26+
Trace(geometries);
27+
break;
28+
case GeometryObject geometryObject:
29+
Trace(geometryObject);
30+
break;
31+
case XYZ xyz:
32+
Trace(xyz);
33+
break;
34+
case BoundingBoxXYZ boundingBoxXyz:
35+
Trace(boundingBoxXyz);
36+
break;
37+
case IEnumerable<XYZ> xyzs:
38+
Trace(xyzs);
39+
break;
40+
case IEnumerable<BoundingBoxXYZ> boundingBoxXyzs:
41+
Trace(boundingBoxXyzs);
42+
break;
43+
default:
44+
base.Write(o);
45+
break;
46+
}
47+
}
48+
public override void Write(string? message)
49+
{
50+
}
51+
52+
public override void WriteLine(string? message)
53+
{
54+
}
55+
}
56+
}

source/RevitDevTool/ViewModel/TraceLogViewModel.cs

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
using System.Windows;
33
using System.Windows.Controls;
44
using System.Windows.Media;
5-
using RevitDevTool.Geometry;
65
using RevitDevTool.Models;
76
using Serilog;
87
using Serilog.Core;
@@ -75,37 +74,7 @@ [RelayCommand] private void Clear()
7574

7675
[RelayCommand] private static void ClearGeometry()
7776
{
78-
ExternalEventController.ActionEventHandler.Raise(app =>
79-
{
80-
var doc = app.ActiveUIDocument.Document;
81-
if (doc == null)
82-
{
83-
Trace.TraceWarning("No active document");
84-
return;
85-
}
86-
87-
var hashKey = doc.GetHashCode();
88-
89-
if (!TraceGeometry.DocGeometries.TryGetValue(hashKey, out var value))
90-
return;
91-
92-
var transaction = new Transaction(doc, "RemoveTransient");
93-
try
94-
{
95-
transaction.Start();
96-
doc.Delete(value);
97-
transaction.Commit();
98-
}
99-
catch (Exception e)
100-
{
101-
Trace.TraceWarning($"Remove Transient Geometry Failed : [{e.Message}]");
102-
transaction.RollBack();
103-
}
104-
finally
105-
{
106-
TraceGeometry.DocGeometries.Remove(hashKey);
107-
}
108-
});
77+
VisualizationServerController.Clear();
10978
}
11079

11180
public void Dispose()

0 commit comments

Comments
 (0)