Pyrevit run issue

I’m trying to move our DynamoAutomation based content updater to pyrevit, and execute it via a PowerShell script.

I’m having trouble using pyrevit run in the CLI. It seems to execute the different revit instances, but it won’t run the provided python script, instead it closes revit immediately after it is started.
The CLI output is the following:

==> Execution Environment
Execution Id: "b1bf4c67-3981-4bf5-b792-c7186d97fdec"
Product: 2020.2.2 (Full Install) | Version: 20.2.11.3 | Build: 20200206_0915(x64) | Language: 1033 | Path: "C:\Program Files\Autodesk\Revit 2020\"
Clone: main | Deploy: "base" | Branch: "master" | Version: "4.8.7" | Path: "C:\pyRevit\main"
Engine: DEFAULT | Kernel: IronPython | Version: 2711 | Runtime: True | Path: "C:\pyRevit\main\bin\engines\IPY2711PR\pyRevitLoader.dll" | Desc: "Custom pyRevit IronPython Engine"
Script: "G:\BIM\Development-Team\pyRevit\Scripts\Updater\ContentUpdater_script.py"
Working Directory: "C:\Users\TAMAS~2.DER\AppData\Local\Temp\b1bf4c67-3981-4bf5-b792-c7186d97fdec"
Journal File: "C:\Users\TAMAS~2.DER\AppData\Local\Temp\b1bf4c67-3981-4bf5-b792-c7186d97fdec\PyRevitRunner_b1bf4c67-3981-4bf5-b792-c7186d97fdec.txt"
Manifest File: "C:\Users\TAMAS~2.DER\AppData\Local\Temp\b1bf4c67-3981-4bf5-b792-c7186d97fdec\PyRevitRunner.addin"
Log File: "C:\Users\TAMAS~2.DER\AppData\Local\Temp\b1bf4c67-3981-4bf5-b792-c7186d97fdec\PyRevitRunner_b1bf4c67-3981-4bf5-b792-c7186d97fdec.log"
==> Target Models
g:\BIM\Development-Team\Dynamo\80_Actual\03_Sandbox\DynamoAutomation\Dummy.rvt
==> Execution Environment

The Log file that is provided by the CLI is not created so I cannot investigate any further. I did everything based on https://www.notion.so/Batch-Process-Revit-Models-d2c336a656684e2ebbc12371b70ac109

The Dummy file is only there because pyrevit run won’t execute without a valid Revit file, even it is not needed at all for the script.

Any ideas?

it seems similar to https://github.com/eirannejad/pyRevit/issues/661

@thumDer What is the actuall full command you are running?

@eirannejad the PS is:

$revitVersions = 2020, 2021, 2022

$dir = split-path -parent $MyInvocation.MyCommand.Definition
$scriptPath = Join-Path $dir "ContentUpdater_script.py"

foreach ($version in $revitVersions) {
    pyrevit run $scriptPath "g:\BIM\Development-Team\Dynamo\80_Actual\03_Sandbox\DynamoAutomation\Dummy.rvt" --revit=$version
}

The py script is actually a rather complex check-open-saveas-close thing, but I’ve also tried it with a simple Hello World!, with different outputs, but that didn’t run either.

I’ve tried to reuse the generated journal file without the following lines:

Jrn.Command "SystemMenu" , "Quit the application; prompts to save projects , ID_APP_EXIT"
Jrn.Data "TaskDialogResult" , "Do you want to save changes to Untitled?", "No", "IDNO"

So now it looks like the following:

' pyrevitrunner generated journal
' 0:< 'C 2021-04-15T15:28:13Z;
Dim Jrn
Set Jrn = CrsJournalScript
Jrn.Directive "DebugMode", "PerformAutomaticActionInErrorDialog", 1
Jrn.Directive "DebugMode", "PermissiveJournal", 1
Jrn.RibbonEvent "TabActivated:Add-Ins"
Jrn.RibbonEvent "Execute external command:CustomCtrl_%CustomCtrl_%Add-Ins%pyRevitRunner%PyRevitRunnerCommand:PyRevitRunner.PyRevitRunnerCommand"
Jrn.Data "APIStringStringMapJournalData"  _
    , 4 _
    , "ScriptSource" , "G:\BIM\Development-Team\pyRevit\Scripts\Updater\ContentUpdater_script.py" _
    , "SearchPaths" , "" _
    , "Models" , "g:\BIM\Development-Team\Dynamo\80_Actual\03_Sandbox\DynamoAutomation\Dummy.rvt" _
    , "LogFile" , "C:\Users\TAMAS~2.DER\AppData\Local\Temp\2b0925fe-e3fb-48fc-aae9-98abb50ce47b\PyRevitRunner_2b0925fe-e3fb-48fc-aae9-98abb50ce47b.log"

Revit loads successfully with the PyRevitRunnerCommand on the Add-Ins tab, but clicking it does nothing
I’m using the default engine, IPY2711PR

Here is the Journal result, the first Execution is from the playback, the second is the “manual click”

 'E 16-Apr-2021 10:35:38.721;   0:< 
 Jrn.RibbonEvent "TabActivated:Add-Ins"
 'E 16-Apr-2021 10:35:38.756;   0:< 
 Jrn.RibbonEvent "Execute external command:CustomCtrl_%CustomCtrl_%Add-Ins%pyRevitRunner%PyRevitRunnerCommand:PyRevitRunner.PyRevitRunnerCommand"
'  0.236648   1:<<<API External Command Time 
'  0.283624  0:<<Event timer 
'H 16-Apr-2021 10:35:39.004;   0:< 
Jrn.Data "APIStringStringMapJournalData"  _
        , 4, "LogFile", "C:\Users\TAMAS~2.DER\AppData\Local\Temp\2b0925fe-e3fb-48fc-aae9-98abb50ce47b\PyRevitRunner_2b0925fe-e3fb-48fc-aae9-98abb50ce47b.log" _
        , "Models", "g:\BIM\Development-Team\Dynamo\80_Actual\03_Sandbox\DynamoAutomation\Dummy.rvt", "ScriptSource" _
        , "G:\BIM\Development-Team\pyRevit\Scripts\Updater\ContentUpdater_script.py", "SearchPaths", ""
'C 16-Apr-2021 10:35:39.010;  finished journal file playback 
 ' 0:< ::42:: Delta VM: Avail -8 -> 134211162 MB, Used +8 -> 602 MB; RAM: Avail -40 -> 42968 MB, Used +14 -> 589 MB, Peak +7 -> 589 MB 
 ' 0:< GUI Resource Usage GDI: Avail 9855, Used 145, User: Used 171 
 'E 16-Apr-2021 10:35:43.326;   0:< 
 Jrn.RibbonEvent "Execute external command:CustomCtrl_%CustomCtrl_%Add-Ins%pyRevitRunner%PyRevitRunnerCommand:PyRevitRunner.PyRevitRunnerCommand"
'H 16-Apr-2021 10:35:43.364;   0:< 
Jrn.Data "APIStringStringMapJournalData"  _
        , 1, "pyRevitRunner Execution Failure", "The given key was not present in the dictionary."

Okay, so I’ve tested with a different engine (277) and it works, so it seems that the default engine has some issues.

Ok great find. I’ll test it with the default 2.7.11 engine. I tested with 277 today and it was working correctly

1 Like

Ok found and fixed the bug. It was isolated to the runner for default engine. Will be published with the next version.

1 Like