architecture-building-systems / revitpythonshell

An IronPython scripting environment for Autodesk Revit and Vasari
MIT License
515 stars 118 forks source link

RPS not loading in Revit 2025 #159

Open hisdirt opened 2 months ago

hisdirt commented 2 months ago

Describe the bug The upgrade process to newer Revit Versions doesnt work in Revit 2025. When addin manifest is copied into the Revit 2025 folder (and paths updated etc), an error is thrown on Revit startup

To Reproduce Steps to reproduce the behavior:

  1. Copy over addin files to Revit 2025 folders
  2. Run Revit 2025
  3. See error

Expected behavior Expected to see the RevitPythonShell addin on the Ribbon

Screenshots Screenshot 2024-09-17 091352

Desktop (please complete the following information):

Additional context It seems that pyRevit is having similar issues, seems to be related to Revit 2025 upgrading to .net CORE 8.0

Ianhuuuuang commented 2 months ago

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

daren-thomas commented 2 months ago

Ah. This is going to be a tricky one I think - Revit really jumped from .NET Framework 4.8 to .NET 8. That's... quite a leap.

This will probably also affect scripts a bit, so this blog post might help migrating those: https://thebuildingcoder.typepad.com/blog/2024/04/migrating-from-net-48-to-net-core-8.html

As for RPS itself, I'll need to come up with a new strategy of creating the assembly. This could take some time as I have to do this in my free time.

Any help is appreciated.

daren-thomas commented 2 months ago

This StackOverflow link looks promising: https://stackoverflow.com/questions/36937276/replacement-of-assemblybuilder-definedynamicassembly-in-net-core

daren-thomas commented 2 months ago

Reproduced the issue no problem (just copy contents of Roaming\Autodesk\Revit\Addins\2024 to Roaming\Autodesk\Revit\Addins\2025, specifically the RevitPythonShell.addin file and the RevitPythonShell folder).

Hit a snag: Is it just me or does JetBrains Rider have a hard time opening the solution? If I remember correctly, we might have done some funky things with the project configurations. I'll look into that next, else try with Visual Studio (Community Edition? Or what is that called?)

daren-thomas commented 2 months ago

Good news and bad news so far...

Good news: I've been able to rewrite the assembly generation logic using Roslyn (the StackOverflow question above didn't pan out sadly) and I actually like the new version much better.

Bad news: Now I'm having problems with the IronPythonConsole we use. This is code I was always hoping never to have to touch again. The current error goes a bit like this:

System.NotSupportedException
Specified method is not supported.

System.AggregateException
System.NotSupportedException: Built-in COM has been disabled via a feature switch. See https://aka.ms/dotnet-illink/com for more information.
   at System.StubHelpers.InterfaceMarshaler.ConvertToNative(Object objSrc, IntPtr itfMT, IntPtr classMT, Int32 flags)
   at MS.Win32.UnsafeNativeMethods.RegisterDragDrop(HandleRef hwnd, IOleDropTarget target)
   at System.Windows.DragDrop.RegisterDropTarget(IntPtr windowHandle)
   at System.Windows.Interop.HwndSource.Initialize(HwndSourceParameters parameters)
   at Microsoft.VisualStudio.XSurface.Wpf.DesignerSurface.CreateSource()
   at Microsoft.VisualStudio.XSurface.Wpf.DesignerSurface..ctor(IProtocolHandler protocolHandler, TapDocument document)
   at Microsoft.VisualStudio.XSurface.Wpf.Tap.SurfaceService.HandleCreateSurfaceInternal(CreateSurfaceRequestInfo requestInfo)
   at Microsoft.VisualStudio.DesignTools.RuntimeHost.TapOM.ResponseWithError.ThrowIfFailed()
   at Microsoft.VisualStudio.DesignTools.SurfaceDesigner.Documents.SurfaceIsolation.DesignerInstanceManager.<BuildDocumentAsync>d__57.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.VisualStudio.DesignTools.XamlSurfaceDesigner.Views.IsolatedSurfaceImageHost.<CreateSurfaceAsync>d__67.MoveNext()

System.AggregateException
One or more errors occurred.

I've tried enabling COM explicitly, but it's not working and I'm tired and it's Sunday so I'm just going to stop for today.

daren-thomas commented 1 month ago

OK. So. This branch shows how to fix the error mentioned in the issue, but it's not a replacement or upgrade of RPS to .NET 8. That seems to require a re-implementation of the console part. If anyone is interested in doing that, go ahead. I've decided I don't want to do this myself.