It looks I need to clarify my intent for this posting. I am looking to display information when starting the interactive Revit Python Shell. I am not looking to run a script at Revit startup or any other time. I am not looking to create a script to run as a utility.
I have seen this statement in the RPS configuration dialog:
"The InitScript is a python script run everytime an interactive shell is opened. It is commonly used to performe initialization of helper functions and variables."
Ok...so I modify this file to do things like "import pyrevit". All of this I have working. However, I want to print a message to the interactive shell stating that pyrevit has been loaded into this RPS session.
For example, I have these lines in the init.py file:
MJM_Notes = "\n==== MJM Notes ====\n"
MJM_Notes = MJM_Notes + "Some Preloaded Varibles:\n"
MJM_Notes = MJM_Notes + " selection (user selected elements at startup\n"
MJM_Notes = MJM_Notes + " selection (user selected elements at startup\n"
MJM_Notes = MJM_Notes + " UIApplication\n"
MJM_Notes = MJM_Notes + " doc = __revit__.ActiveUIDocument.Document\n"
MJM_Notes = MJM_Notes + " lookup() - Database explorer tool\n"
MJM_Notes = MJM_Notes + "\nPreloaded Modules:\n"
MJM_Notes = MJM_Notes + " CLR loaded (It is part of .NET)\n"
import pyrevit
MJM_Notes = MJM_Notes + " PyRevit Loaded. Version: " + pyrevit.VERSION_STRING + "\n"
import rpw
MJM_Notes = MJM_Notes + " Revit Python Wrapper Loaded. Version: " + rpw.__version__ + "\n"
None of the above causes an error. But adding the print statement below causes the RPS to "hang"
print MJM_Notes
Here is a screen shot of RPS - note the missing ">>>":
At this point, I am not sure if RPS allows print statements in the init.py file, or if this is a bug in RPS, or if there is a different way to accomplish what I wish to do, or if I what I want is even possible.
I did not see anything on this webpage RPS Readme to address this issue.
Sincerely; Michelle
------ Original Post ---------- When I start Revit Python Shell it displays the message shown below before the command prompt.
IronPython 2.7.7 (2.7.7.0) on .NET 4.0.30319.42000 (64-bit)
Type "help", "copyright", "credits" or "license" for more information.
I would like to display additional info like this:
==== MJM Notes ====
Some Preloaded Varibles:
selection (user selected elements at startup
selection (user selected elements at startup
UIApplication
doc = __revit__.ActiveUIDocument.Document
lookup() - Database explorer tool
Preloaded Modules:
CLR loaded (It is part of .NET)
PyRevit Loaded. Version: 4.8.9.21361+0320
Revit Python Wrapper Loaded. Version: 1.7.4
==== MJM Notes ====
What would be the best way to do this? I have tried adding a print statement to init.py with less than perfect results. (Basically, it prints the message and then "hangs" - no command prompt.)
Sincerely; Michelle