diff --git a/src/DynamoRevit/DynamoRevit.csproj b/src/DynamoRevit/DynamoRevit.csproj index b6986831e..f1efa6f40 100644 --- a/src/DynamoRevit/DynamoRevit.csproj +++ b/src/DynamoRevit/DynamoRevit.csproj @@ -147,7 +147,6 @@ - diff --git a/src/DynamoRevit/Models/RevitDynamoModel.cs b/src/DynamoRevit/Models/RevitDynamoModel.cs index 5cc0f848f..b14edeaa2 100644 --- a/src/DynamoRevit/Models/RevitDynamoModel.cs +++ b/src/DynamoRevit/Models/RevitDynamoModel.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Collections.Specialized; using System.Diagnostics; +using System.IO; using System.Linq; using System.Windows.Forms; using Autodesk.Revit.DB; @@ -443,9 +444,16 @@ private void SetupPythonEngine(PythonEngine engine) { if (engine != null) { - (engine.OutputDataMarshaler as DataMarshaler).RegisterMarshaler((Element element) => element.ToDSType(true)); - engine.EvaluationStarted += OnPythonEvalStart; - engine.EvaluationFinished += OnPythonEvalFinished; + try + { + (engine.OutputDataMarshaler as DataMarshaler).RegisterMarshaler((Element element) => element.ToDSType(true)); + engine.EvaluationStarted += OnPythonEvalStart; + engine.EvaluationFinished += OnPythonEvalFinished; + } + catch(FileNotFoundException ex) + { + Logger.Log(ex); + } } } @@ -455,11 +463,18 @@ private void SetupPythonEngine(PythonEngine engine) /// private void CleanUpPythonEngine(PythonEngine engine) { - if (engine != null) + try + { + if (engine != null) + { + (engine.OutputDataMarshaler as DataMarshaler).UnregisterMarshalerOfType(); + engine.EvaluationStarted -= OnPythonEvalStart; + engine.EvaluationFinished -= OnPythonEvalFinished; + } + } + catch (FileNotFoundException ex) { - (engine.OutputDataMarshaler as DataMarshaler).UnregisterMarshalerOfType(); - engine.EvaluationStarted -= OnPythonEvalStart; - engine.EvaluationFinished -= OnPythonEvalFinished; + Logger.Log(ex); } }