architecture-building-systems / revitpythonshell

An IronPython scripting environment for Autodesk Revit and Vasari
MIT License
501 stars 115 forks source link

System.NullReferenceException in PythonTextEditor.Write causing Revit to crash #158

Open alexworkorb opened 1 month ago

alexworkorb commented 1 month ago

Describe the bug Sometimes Revit crashes due to a Null pointer exception traced to PythonTextEditor.Write

To Reproduce Steps to reproduce the behavior:

Expected behavior

Screenshots image

Windows event log:

Faulting application name: Revit.exe, version: 24.1.11.26, time stamp: 0x64ff47ef
Faulting module name: ntdll.dll, version: 10.0.22621.3733, time stamp: 0x67ca8829
Exception code: 0xc0000374
Fault offset: 0x000000000010c8f9
Faulting process id: 0x0x45E4
Faulting application start time: 0x0x1DAE118D918C487
Faulting application path: C:\Program Files\Autodesk\Revit 2024\Revit.exe
Faulting module path: C:\Windows\SYSTEM32\ntdll.dll
Report Id: 79327c40-7a4a-4c0b-bdcb-5102af93c7fa
Faulting package full name: 
Faulting package-relative application ID: 

-----------------------------------
Application: Revit.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.NullReferenceException
   at System.Text.StringBuilder.Append(System.String)
   at PythonConsoleControl.PythonTextEditor.Write(System.String, Boolean, Boolean)
   at PythonConsoleControl.PythonConsole.ExecuteStatements()
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at MS.Internal.CulturePreservingExecutionContext.Run(MS.Internal.CulturePreservingExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
   at MS.Win32.HwndWrapper.WndProc(IntPtr, Int32, IntPtr, IntPtr, Boolean ByRef)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(System.Object)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(System.Delegate, System.Object, Int32)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(System.Object, System.Delegate, System.Object, Int32, System.Delegate)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(System.Windows.Threading.DispatcherPriority, System.TimeSpan, System.Delegate, System.Object, Int32)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr, Int32, IntPtr, IntPtr)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(System.Windows.Interop.MSG ByRef)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(System.Windows.Threading.DispatcherFrame)
   at PythonConsoleControl.PythonConsole.DispatcherThreadStartingPoint()
   at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
   at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
   at System.Threading.ThreadHelper.ThreadStart()

Desktop (please complete the following information):

Additional context We keep encountering this issue when exporting ViewSections into DWG's (using doc.Export)

Ianhuuuuang commented 1 month ago

您好,邮件已收到,尽快给您回复。