Skip to content

Commit

Permalink
fixes #56 (NullReferenceException on loading)
Browse files Browse the repository at this point in the history
  • Loading branch information
daren-thomas committed Jul 24, 2017
1 parent a76eea4 commit acec4e5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
Binary file not shown.
7 changes: 5 additions & 2 deletions RevitPythonShell/RevitPythonShellApplication.cs
Expand Up @@ -52,7 +52,10 @@ Result IExternalApplication.OnStartup(UIControlledApplication application)
}
catch (Exception ex)
{
TaskDialog.Show("Error setting up RevitPythonShell", ex.ToString());
var td = new TaskDialog("Error setting up RevitPythonShell");
td.MainInstruction = ex.Message;
td.ExpandedContent = ex.ToString();
td.Show();
return Result.Failed;
}
}
Expand All @@ -61,7 +64,7 @@ private static void ExecuteStartupScript(UIControlledApplication uiControlledApp
{
// we need a UIApplication object to assign as `__revit__` in python...
var versionNumber = uiControlledApplication.ControlledApplication.VersionNumber;
var fieldName = versionNumber == "2017" ? "m_uiapplication": "m_application";
var fieldName = int.Parse(versionNumber) >= 2017 ? "m_uiapplication": "m_application";
var fi = uiControlledApplication.GetType().GetField(fieldName, BindingFlags.NonPublic | BindingFlags.Instance);
var uiApplication = (UIApplication)fi.GetValue(uiControlledApplication);
// execute StartupScript
Expand Down
2 changes: 1 addition & 1 deletion RpsRuntime/RpsExternalApplicationBase.cs
Expand Up @@ -173,7 +173,7 @@ private void ExecuteStartupScript(UIControlledApplication uiControlledApplicatio
{
// we need a UIApplication object to assign as `__revit__` in python...
var versionNumber = uiControlledApplication.ControlledApplication.VersionNumber;
var fieldName = versionNumber == "2017" ? "m_uiapplication" : "m_application";
var fieldName = int.Parse(versionNumber) >= 2017 ? "m_uiapplication" : "m_application";
var fi = uiControlledApplication.GetType().GetField(fieldName, BindingFlags.NonPublic | BindingFlags.Instance);
var uiApplication = (UIApplication)fi.GetValue(uiControlledApplication);
// execute StartupScript
Expand Down

0 comments on commit acec4e5

Please sign in to comment.