Skip to content

Commit 31ef701

Browse files
IsakNaslundBhFraser Greenroyd
authored andcommitted
Wrap getting active doc in try-catch
1 parent 7bdf111 commit 31ef701

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

Rhinoceros_Engine/Compute/CaptureNamedViews.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,17 @@ public static partial class Compute
5050
[Output("success", "Returns true if the view capture was successful.")]
5151
public static bool CaptureNamedViews(bool active = false, string folderPath = "", string imageName = "", List<string> namedViewFilter = null, IViewCaptureSettings settings = null)
5252
{
53-
RhinoDoc doc = RhinoDoc.ActiveDoc;
53+
RhinoDoc doc;
54+
try
55+
{
56+
doc = RhinoDoc.ActiveDoc;
57+
}
58+
catch (Exception e)
59+
{
60+
string msg = "Failed to get the active rhino document. Exception thrown: " + e.Message;
61+
Base.Compute.RecordError(msg);
62+
return false;
63+
}
5464

5565
if (doc == null)
5666
return false;

Rhinoceros_Engine/Compute/CaptureView.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,17 @@ public static partial class Compute
4949
[Output("success", "Returns true if the view capture was successful.")]
5050
public static bool CaptureView(bool active = false, string folderPath = "", string imageName = "", IViewCaptureSettings settings = null)
5151
{
52-
RhinoDoc doc = Rhino.RhinoDoc.ActiveDoc;
52+
RhinoDoc doc;
53+
try
54+
{
55+
doc = RhinoDoc.ActiveDoc;
56+
}
57+
catch (Exception e)
58+
{
59+
string msg = "Failed to get the active rhino document. Exception thrown: " + e.Message;
60+
Base.Compute.RecordError(msg);
61+
return false;
62+
}
5363

5464
if (doc == null)
5565
return false;

0 commit comments

Comments
 (0)