Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix net folder #2363

Merged
merged 13 commits into from
Aug 22, 2024
Merged

fix net folder #2363

merged 13 commits into from
Aug 22, 2024

Conversation

jmcouffin
Copy link
Contributor

@jmcouffin
Copy link
Contributor Author

jmcouffin commented Aug 19, 2024

needs to be addressed:

  • Same issue in pyRevit\runtime\__init__.py as well as in framework.py which feature the same __revit__.application code.
  • The version number is also being used in the 'Copy views' tool as well as the Assembly maker module ('asmmaker.py').

@jmcouffin jmcouffin added Runtime Issues related to loading pyRevit runtime [subsystem] pyRevit 5 pyRevit 5 coming release labels Aug 19, 2024
@sanzoghenzo
Copy link
Contributor

since there are many places in which the revit version is checked, we could move the version check to pyrevit.compat module, introducing a variable like

try:
    NETCORE = int(_get_revit_version()) >= 2025
except Exception:  # maybe we should change the exception thrown by the None check
    NETCORE = False # not sure about this, should we default to True? leave it None?

Or change the function to directly return True or False.

Then we can use

from pyrevit.compat import NETCORE

if NETCORE: # or if not NETCORE:
   # do the thing

whenewer there's a version check.

The next step would be to directly inject the revit version (or the current dotnet runtime) value via ironpython/pythonnet builtins, and point the NETCORE variable to that value (so we only need to change one place)

@sanzoghenzo
Copy link
Contributor

One note: since the "Copy views" is a pushbutton, it should always receive an UIApplication in the __revit__ builtin. The problem here is with hooks that pass another type as EventSender.
But using the solution mentioned in the previous post, we would solve potential future problems.

@sanzoghenzo
Copy link
Contributor

Given the other issues with hooks, it's better to solve this on the C# side and ensure that __revit__ is always a UIApplication

@jmcouffin
Copy link
Contributor Author

@sanzoghenzo you are on fire

@sanzoghenzo
Copy link
Contributor

I didn't test the modification at all 😅 I'll try them later to see if I broke something in netfx. If you have some time, please let me know if it works on revit 2025

@jmcouffin
Copy link
Contributor Author

@sanzoghenzo
Unless it needs to go through the CLI, which I doubt, You broke it 😄
This week it is your turn to break things! 🤣

in 2025,
image

' 0:< API_ERROR { : Assembly version conflict in some references in pyRevitLoader.dll assembly
'Addin's module RevitAPI of version 25.0.0.0 conflicts with same preloaded module of version 25.2.0.0
'Addin's module RevitAPIUI of version 25.0.0.0 conflicts with same preloaded module of version 25.2.0.0 } 
' 0:< ::58:: Delta VM: Avail -21 -> 133881693 MB, Used 313 MB, Peak +3 -> 318 MB; RAM: Avail +2 -> 45081 MB, Used +10 -> 699 MB, Peak +10 -> 699 MB 
' 0:< GUI Resource Usage GDI: Avail 9673, Used 327, User: Used 195 
' 0:< TaskDialog "System.InvalidOperationException: Sequence contains no elements
'   at System.Linq.ThrowHelper.ThrowNoElementsException()
'   at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source)
'   at PyRevitLoader.ScriptExecutor.AddEmbeddedLib(ScriptEngine engine)
'   at PyRevitLoader.ScriptExecutor.SetupEnvironment(ScriptEngine engine, ScriptScope scope)
'   at PyRevitLoader.ScriptExecutor.SetupEnvironment(ScriptEngine engine)
'   at PyRevitLoader.ScriptExecutor.ExecuteScript(String sourcePath, IEnumerable`1 sysPaths, String logFilePath, IDictionary`2 variables)"
'CommonButtons : Close
'DefaultButton : Close 
  ' 0:< ::58:: Delta VM: Avail -18 -> 133881675 MB, Used +2 -> 315 MB, Peak +9 -> 328 MB; RAM: Avail -146 -> 44936 MB, Used +3 -> 703 MB, Peak +16 -> 716 MB 
  ' 0:< GUI Resource Usage GDI: Avail 9657, Used 343, User: Used 214 
  'C 21-Aug-2024 10:43:58.679;   0:< Notify Active View. 
  'H 21-Aug-2024 10:43:58.691;   0:< 
  Jrn.Data  _
          "TaskDialogResult"  , "System.InvalidOperationException: Sequence contains no elements" & vbCrLf & "   at System.Linq.ThrowHelper.ThrowNoElementsException()" & vbCrLf & "   at System.Linq.Enumerable.Single[TSource](IEnumerable`1 source)" & vbCrLf & "   at PyRevitLoader.ScriptExecutor.AddEmbeddedLib(ScriptEngine engine)" & vbCrLf & "   at PyRevitLoader.ScriptExecutor.SetupEnvironment(ScriptEngine engine, ScriptScope scope)" & vbCrLf & "   at PyRevitLoader.ScriptExecutor.SetupEnvironment(ScriptEngine engine)" & vbCrLf & "   at PyRevitLoader.ScriptExecutor.ExecuteScript(String sourcePath, IEnumerable`1 sysPaths, String logFilePath, IDictionary`2 variables)" ,  _
           "Close"  _
          , "IDCLOSE" 
' 0:< API_ERROR { Starting External Application: PyRevitLoader, Class: PyRevitLoader.PyRevitLoaderApplication, Vendor : eirannejad(), Assembly: C:\pyRevit\netcore\bin\netcore\engines\IPY2712PR\pyRevitLoader.dll,  Assembly Version: 2.7.11.0 } 

in 2024
image

'C 21-Aug-2024 10:45:21.113;   0:< start up warnings for AddIns 
' 0:< TaskDialog "Impossible d'initialiser le compl魥nt �PyRevitLoader�, car l'assemblage �C:\pyRevit\netcore\bin\netfx\engines\IPY2712PR\pyRevitLoader.dll � n'existe pas. "
'Id : TaskDialog_External_Tools_Add_In_Assembly_Not_Found
'CommonButtons : Close
'DefaultButton : Close 

@sanzoghenzo
Copy link
Contributor

That's strange, I didn't touch any .cs/.dll files, those errors comes before the python scripts I edited gets loaded (but I may be wrong). I'll check this later

@jmcouffin
Copy link
Contributor Author

jmcouffin commented Aug 21, 2024

That's strange, I didn't touch any .cs/.dll files, those errors comes before the python scripts I edited gets loaded (but I may be wrong). I'll check this later

Just checked the latest installer pre-commit of this draft PR and all good (except a typo in the de_de translation of the reload button, but nothing important)

Copy link
Contributor

@sanzoghenzo sanzoghenzo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Waiting for @eirannejad to shed some light about the __revit__ builtin polymorphism, I think this should cover most of the cases.

It may be a good time to remove all references of __revit__ in the notion site and use HOST_APP.uiapp (or the other properties) instead

@jmcouffin
Copy link
Contributor Author

jmcouffin commented Aug 21, 2024

Waiting for @eirannejad to shed some light about the __revit__ builtin polymorphism, I think this should cover most of the cases.

~~Latest WIP does not isntall CLI properly 😸 ~~
Heisenbug, my cmd line was not reloading properly, running in admin mode did the trick

@sanzoghenzo
Copy link
Contributor

Wait, I'm not sure I follow you, this branch doesn't have an associated CI job with installers to try... what are you testing? 🤣

@jmcouffin
Copy link
Contributor Author

I was testing the latest wip to see if the bug was introduced by your changes (attaching this PR to Revit) or by previous changes (installing latest wip)
it seems the current draft PR #2363 introduces the bug (or require some sort of compiling or changes in submodules?)

@sanzoghenzo
Copy link
Contributor

I was testing the latest wip to see if the bug was introduced by your changes (attaching this PR to Revit) or by previous changes (installing latest wip) it seems the current draft PR #2363 introduces the bug (or require some sort of compiling or changes in submodules?)

I've merged the current develop branch to this PR, so you can use the latest WIP installer for this.

As you can see from the "files changed" section here, I only touched .py files, so the pyrevitloader.dll is not affected at all.

The first message is thrown because it cannot find the python_{EngineVersion}pr_lib.zip (I assume EngineVersion is 2712 if it properly attached) in the PyRevitLoader Assembly resouces manifest.

The python lib are there, and listed as embedded resources in both loader and runner (which I believe is a waste of space, but I still didn't learn much about those projects).

image

@sanzoghenzo
Copy link
Contributor

I realize now that attaching engines/loaders from a clone means using all of its dlls, so it may be that some binaries are missing - but then again - i didn't touch them, so it should be happening regardless of this PR!

Try to run a pipenv run pyrevit build products in the root folder to force the compilation of the dlls, maybe something got messed up.

Meanwhile, I enabled the PyrevitDevHooks extension (I previously tell you the wrong one), and a plethora of errors welcomed me.

I solve what I could, but I also got this from the VB.NET and C# hooks for the activation of a view :

image

This could be an old bug, who knows...

@jmcouffin
Copy link
Contributor Author

pipenv run pyrevit build products

my dev environment is not properly setup to run this.
Maybe we could just merge this PR and see how it goes / it may be faster?

@jmcouffin
Copy link
Contributor Author

@sanzoghenzo I just launched the CI on this PR branch to be able to test it properly
I don't have all the git pro reflexes yet, but I am getting there 😄

@sanzoghenzo
Copy link
Contributor

pipenv run pyrevit build products

my dev environment is not properly setup to run this. Maybe we could just merge this PR and see how it goes / it may be faster?

You remind me that I still need to create the documentation on how to setup the dev environment 😉

I see that you find the way to run the CI manually on this branch, so I don't have to tell you how to do it 😅

@jmcouffin
Copy link
Contributor Author

jmcouffin commented Aug 22, 2024

for the sake of the argument and documenation
image

@jmcouffin
Copy link
Contributor Author

Tried to install the wip from this PR and it works fine for the main tools extension

Tried also the dev hooks extension:

startup.cs in 2025 returns if only devhooks are enabled (and not devtools extension)

C# Traceback:
Define: REVIT2025;REVIT2025_2 
Reference: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.3\System.Private.CoreLib.dll 
Reference: C:\Users\Jean-Marc\AppData\Roaming\pyRevit-Master\bin\netcore\pyRevitLabs.PyRevit.Runtime.Shared.dll 
Reference: C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\8.0.3\System.Windows.Forms.dll 
Reference: C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\8.0.3\System.Drawing.dll 
Reference: C:\Users\Jean-Marc\AppData\Roaming\pyRevit-Master\bin\netcore\engines\IPY2712PR\pyRevitLabs.IronPython.Modules.dll 
Reference: C:\Users\Jean-Marc\AppData\Roaming\pyRevit-Master\bin\netcore\engines\IPY2712PR\pyRevitLabs.Microsoft.Dynamic.dll 
Reference: C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319\System.Numerics.dll 
Reference: C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\8.0.3\WindowsFormsIntegration.dll 
Reference: C:\Program Files\Autodesk\Revit 2025\RevitAPIUI.dll 
Reference: C:\Program Files\Autodesk\Revit 2025\RevitAPI.dll 
Reference: C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\8.0.3\System.Xaml.dll 
Reference: C:\Users\Jean-Marc\AppData\Roaming\pyRevit-Master\bin\netcore\pyRevitLabs.Common.dll 
Reference: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.3\System.dll 
Reference: C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\8.0.3\WindowsBase.dll 
Reference: C:\Users\Jean-Marc\AppData\Roaming\pyRevit-Master\bin\netcore\pyRevitLabs.Emojis.dll 
Reference: C:\Users\Jean-Marc\AppData\Roaming\pyRevit-Master\bin\netcore\pyRevitLabs.NLog.dll 
Reference: C:\Users\Jean-Marc\AppData\Roaming\pyRevit-Master\bin\netcore\pyRevitLabs.TargetApps.Revit.dll 
Reference: C:\Users\Jean-Marc\AppData\Roaming\pyRevit-Master\bin\netcore\pyRevitLabs.PyRevit.dll 
Reference: C:\WINDOWS\Microsoft.NET\Framework64\v4.0.30319\System.Web.dll 
Reference: C:\Program Files\Autodesk\Revit 2025\UIFramework.dll 
Reference: C:\Users\Jean-Marc\AppData\Roaming\pyRevit-Master\bin\netcore\pyRevitLabs.MahAppsMetro.dll 
Reference: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.3\System.Xml.dll 
Reference: C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\8.0.3\PresentationCore.dll 
Reference: C:\Users\Jean-Marc\AppData\Roaming\pyRevit-Master\bin\netcore\engines\IPY2712PR\pyRevitLoader.dll 
Reference: C:\Program Files\dotnet\shared\Microsoft.NETCore.App\8.0.3\System.Core.dll 
Reference: C:\Users\Jean-Marc\AppData\Roaming\pyRevit-Master\bin\netcore\pyRevitLabs.CommonWPF.dll 
Reference: C:\Users\Jean-Marc\AppData\Roaming\pyRevit-Master\bin\netcore\pyRevitLabs.Json.dll 
Reference: C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App\8.0.3\PresentationFramework.dll 
Reference: C:\Program Files\Autodesk\Revit 2025\AdWindows.dll 
Reference: C:\Users\Jean-Marc\AppData\Roaming\pyRevit-Master\bin\netcore\Microsoft.CSharp.dll 
Reference: C:\Users\Jean-Marc\AppData\Roaming\pyRevit-Master\bin\netcore\engines\IPY2712PR\pyRevitLabs.Microsoft.Scripting.dll 
Reference: C:\Program Files\Autodesk\Revit 2025\Xceed.Wpf.AvalonDock.dll 
Reference: C:\Users\Jean-Marc\AppData\Roaming\pyRevit-Master\bin\netcore\engines\IPY2712PR\pyRevitLabs.IronPython.dll 
Reference: C:\Users\Jean-Marc\AppData\Roaming\pyRevit-Master\bin\netcore\engines\IPY2712PR\pyRevitLabs.PyRevit.Runtime.2025.dll 
C:\Users\Jean-Marc\AppData\Roaming\pyRevit-Master\extensions\pyRevitDevHooks.extension\startup.cs(16,14): error CS0012: The type 'Enum' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. 
C:\Users\Jean-Marc\AppData\Roaming\pyRevit-Master\extensions\pyRevitDevHooks.extension\startup.cs(16,21): error CS0012: The type 'Enum' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. 
C:\Users\Jean-Marc\AppData\Roaming\pyRevit-Master\extensions\pyRevitDevHooks.extension\startup.cs(14,42): error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. 
C:\Users\Jean-Marc\AppData\Roaming\pyRevit-Master\extensions\pyRevitDevHooks.extension\startup.cs(18,17): error CS0012: The type 'Object' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. 
C:\Users\Jean-Marc\AppData\Roaming\pyRevit-Master\extensions\pyRevitDevHooks.extension\startup.cs(18,10): error CS0012: The type 'MulticastDelegate' is defined in an assembly that is not referenced. You must add a reference to assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. 
C:\Users\Jean-Marc\AppData\Roaming\pyRevit-Master\extensions\pyRevitDevHooks.extension\startup.cs(19,10): error CS0103: The name 'Console' does not exist in the current context 
C:\Users\Jean-Marc\AppData\Roaming\pyRevit-Master\extensions\pyRevitDevHooks.extension\startup.cs(20,10): error CS0103: The name 'Console' does not exist in the current context 
C:\Users\Jean-Marc\AppData\Roaming\pyRevit-Master\extensions\pyRevitDevHooks.extension\startup.cs(21,17): error CS0012: The type 'Enum' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. 
C:\Users\Jean-Marc\AppData\Roaming\pyRevit-Master\extensions\pyRevitDevHooks.extension\startup.cs(21,24): error CS0012: The type 'Enum' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=8.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

starting 2021 with or without devtools extension activated and dev hooks activated
image

app-init works as expected.

@jmcouffin jmcouffin marked this pull request as ready for review August 22, 2024 11:09
@jmcouffin
Copy link
Contributor Author

I think we could merge this one and get going from there.

@jmcouffin
Copy link
Contributor Author

what do you think @sanzoghenzo @dosymep

@sanzoghenzo
Copy link
Contributor

You have my blessing! 😉

@jmcouffin jmcouffin merged commit d6c355f into develop Aug 22, 2024
@jmcouffin jmcouffin deleted the fix-2351-net-folder branch August 22, 2024 11:55
Copy link
Contributor

📦 New work-in-progress (wip) builds are available for 5.0.0.24235+1159-wip

Copy link
Contributor

📦 New work-in-progress (wip) builds are available for 5.0.0.24236+2228-wip

Copy link
Contributor

📦 New work-in-progress (wip) builds are available for 5.0.0.24240+2307-wip

Copy link
Contributor

📦 New work-in-progress (wip) builds are available for 5.0.0.24242+0910-wip

Copy link
Contributor

github-actions bot commented Sep 2, 2024

📦 New work-in-progress (wip) builds are available for 5.0.0.24246+1410-wip

Copy link
Contributor

github-actions bot commented Sep 9, 2024

📦 New work-in-progress (wip) builds are available for 5.0.0.24253+1920-wip

Copy link
Contributor

📦 New work-in-progress (wip) builds are available for 5.0.0.24254+1158-wip

Copy link
Contributor

📦 New work-in-progress (wip) builds are available for 5.0.0.24254+1351-wip

Copy link
Contributor

📦 New work-in-progress (wip) builds are available for 5.0.0.24261+0647-wip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pyRevit 5 pyRevit 5 coming release Runtime Issues related to loading pyRevit runtime [subsystem]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants