pyrevitlabs / pyRevit

Rapid Application Development (RAD) Environment for Autodesk Revit®
http://wiki.pyrevitlabs.io
GNU General Public License v3.0
1.33k stars 338 forks source link

CLI run doesn't run a script #661

Closed melnikovalex closed 5 years ago

melnikovalex commented 5 years ago

Describe the bug Hi Ehsan! I am trying pyrevit run command and for me something goes wrong here (maybe I don't know how to do it properly). Please correct me if so.

Thank you in advance!

To Reproduce

If I run pyrevit run "make3dview" "D:\test.rvt" --revit=2018 Revit is being opened, loaded and closed. But in the end no files were opened or changed.

If I check journal file generated by Revit, right after running a command it closes revit.

Jrn.RibbonEvent "Execute external command:CustomCtrl_%CustomCtrl_%Add-Ins%pyRevitRunner%PyRevitRunnerCommand:PyRevitRunner.PyRevitRunnerCommand"
'  0.621163   1:<<<API External Command Time 
'  0.725203  0:<<Event timer 
'H 03-Aug-2019 13:06:22.725;   0:< 
Jrn.Data "APIStringStringMapJournalData"  _
        , 4, "LogFile", "C:\Users\Alex\AppData\Local\Temp\a4c2a673-c62b-4895-abf7-73fd4a000312\PyRevitRunner_a4c2a673-c62b-4895-abf7-73fd4a000312.log" _
        , "Models", "D:\test.rvt", "ScriptSource" _
        , "C:\Users\Alex\AppData\Roaming\pyRevit\pyRevit46-24\main46-24\extensions\pyRevitRun.run\make3dview_command.py", "SearchPaths", ""
 'E 03-Aug-2019 13:06:22.731;   0:< 
 Jrn.Command "SystemMenu" , "Quit the application; prompts to save projects , ID_APP_EXIT"

Here CLI log:

C:\Users\Alex>pyrevit run "make3dview" "D:\test.rvt" --revit=2018
==> Execution Environment
Execution Id: "a4c2a673-c62b-4895-abf7-73fd4a000312"
Product: Autodesk Revit 2018.2 | Version: 18.2.0.51 | Build: 20170927_1515(x64) | Language: 1033 | Path: "C:\Program Files\Autodesk\Revit 2018"
Clone: main46-24 | Branch: "master" | Version: "4.6.24:76d18d6" | Path: "C:\Users\Alex\AppData\Roaming\pyRevit\pyRevit46-24\main46-24"
Engine: Kernel: IronPython | Version: 279 | Runtime: True | Path: "C:\Users\Alex\AppData\Roaming\pyRevit\pyRevit46-24\main46-24\bin\engines\279\pyRevitLoader.dll" | Desc: "Latest Stable IronPython Engine" | Compatible: ""
Script: "C:\Users\Alex\AppData\Roaming\pyRevit\pyRevit46-24\main46-24\extensions\pyRevitRun.run\make3dview_command.py"
Working Directory: "C:\Users\Alex\AppData\Local\Temp\a4c2a673-c62b-4895-abf7-73fd4a000312"
Journal File: "C:\Users\Alex\AppData\Local\Temp\a4c2a673-c62b-4895-abf7-73fd4a000312\PyRevitRunner_a4c2a673-c62b-4895-abf7-73fd4a000312.txt"
Manifest File: "C:\Users\Alex\AppData\Local\Temp\a4c2a673-c62b-4895-abf7-73fd4a000312\PyRevitRunner.addin"
Log File: "C:\Users\Alex\AppData\Local\Temp\a4c2a673-c62b-4895-abf7-73fd4a000312\PyRevitRunner_a4c2a673-c62b-4895-abf7-73fd4a000312.log"
==> Target Models
D:\test.rvt

Desktop (please complete the following information):

eirannejad commented 5 years ago

@melnikovalex Hey bud. I just tested the runner with make3dview command with CLI v0.13 on both 2019 and 2018 and it works fine. Would you mind upgrading your CLI to the latest and test again?

Thanks a lot for sharing all the results. On the surface everything looks OK. It'd be also great if you can check to see if there is anything logged in the log file listed at Log File: in the ==> Execution Environment report. If the log file doesn't exist it means that the command script generated no output or exceptions and nothing was logged. That means the script ran OK.

melnikovalex commented 5 years ago

Thank you for your recommendation and sorry for the late answer. I've tested it with CLI 0.13 in two different environments with 2018 and 2019, ENU and DEU. I couldn't see any difference, revit file is still not being updated by the script. In the log there Jrn.Command "SystemMenu" , "Quit the application; right after Jrn.Data "APIStringStringMapJournalData" _

In both cases there were no .log file, only .txts

Is it working for you with the same command and empty file pyrevit run "make3dview" "D:\test.rvt" ?

Here is the second env where I was testing it

==> Registered Clones (full git repos)
main46-24 | Branch: "master" | Version: "4.6.24:76d18d6" | Path: "D:\Sicherung\pyRevit\main46-24"
==> Registered Clones (deployed from archive/image)
==> Attachments
main46-24 | Product: "Autodesk Revit 2019.2.1" | Engine: 279 | Path: "D:\Sicherung\pyRevit\main46-24" | Manifest: "D:\Users\aleksei.melnikov\AppData\Roaming\Autodesk\Revit\Addins\2019\pyRevit.addin"
==> Installed Extensions
==> Default Extension Search Path
D:\Users\aleksei.melnikov\AppData\Roaming\pyRevit\Extensions
==> Extension Search Paths
==> Extension Sources - Default
https://github.com/eirannejad/pyRevit/raw/master/extensions/extensions.json
==> Extension Sources - Additional
P:\CAD\Settings\_storage\pyRevit_extensions.json
==> Installed Revits
Autodesk Revit 2019.2.1 | Version: 19.2.10.7 | Build: 20190225_1515(x64) | Language: 1033 | Path: "C:\Program Files\Autodesk\Revit 2019"
==> Running Revit Instances
==> User Environment
Microsoft Windows 10 [Version 10.0.18362]
Executing User: HWPNET\aleksei.melnikov
Active User: HWPNET\aleksei.melnikov
Adming Access: No
%APPDATA%: "D:\Users\aleksei.melnikov\AppData\Roaming"
Latest Installed .Net Framework: 4.8
No .Net Target Packs are installed.
No .Ne-Core Target Packs are installed.
pyRevit CLI 0.13.0.0
melnikovalex commented 5 years ago

I was also testing code like:

with open("D:\results.txt", "a") as f:
    f.write("x")

both with Revit file and without usint run. No data is being written in results.txt in both cases.

eirannejad commented 5 years ago

@melnikovalex I tested the attached test script and model and it works on all Revit versions. Using CLI v0.17

Issue 661.zip

In the script above you need to change "D:\results.txt" to r"D:\results.txt" as \r is a special escape character

thumDer commented 3 years ago

However this is an old, closed issue, I seem to have the same problem. https://discourse.pyrevitlabs.io/t/pyrevit-run-issue/373