pyrevit.output¶
Provide access to output window and its functionality.
This module provides access to the output window for the currently running
pyRevit command. The proper way to access this wrapper object is through
the get_output()
of pyrevit.script
module. This method, in return
uses the pyrevit.output module to get access to the output wrapper.
Example
>>> from pyrevit import script
>>> output = script.get_output()
Here is the source of pyrevit.script.get_output()
. As you can see this
functions calls the pyrevit.output.get_output()
to receive the
output wrapper.
def get_output():
"""Return object wrapping output window for current script.
Returns:
:obj:`pyrevit.output.PyRevitOutputWindow`: Output wrapper object
"""
return output.get_output()
-
class
pyrevit.output.
PyRevitOutputWindow
¶ Wrapper to interact with the output window.
-
add_style
(style_code, attribs=None)¶ Inject style tag into current html head of the output window.
Parameters: - style_code (str) – css styling code
- attribs (
dict
) – dictionary of attribute names and value
Example
>>> output = pyrevit.output.get_output() >>> output.add_style('body { color: blue; }')
-
center
()¶ Center the output window on the screen
-
close
()¶ Close the window.
-
close_others
(all_open_outputs=False)¶ Close all other windows that belong to the current command.
Parameters: all_open_outputs (bool) – Close all any other windows if True
-
debug_mode
¶ Set debug mode on output window and stream.
This will cause the output window to print information about the buffer stream and other aspects of the output window mechanism.
-
freeze
()¶ Freeze output content update.
-
get_head_html
()¶ str: Return inner code of html head element.
-
get_height
()¶ int: Return current window height.
-
get_title
()¶ str: Return current window title.
-
get_width
()¶ int: Return current window width.
-
hide
()¶ Hide the window.
-
hide_logpanel
()¶ Hide output window logging panel.
-
hide_progress
()¶ Hide output window progress bar.
-
indeterminate_progress
(state)¶ Show or hide indeterminate progress bar.
-
inject_script
(script_code, attribs=None, body=False)¶ Inject script tag into current head (or body) of the output window.
Parameters: - script_code (str) – javascript code
- attribs (
dict
) – dictionary of attribute names and value - body (bool, optional) – injects script into body instead of head
Example
>>> output = pyrevit.output.get_output() >>> output.inject_script('', # no script since it's a link {'src': js_script_file_path})
-
inject_to_body
(element_tag, element_contents, attribs=None)¶ Inject html element to current html body of the output window.
Parameters: - element_tag (str) – html tag of the element e.g. ‘div’
- element_contents (str) – html code of the element contents
- attribs (
dict
) – dictionary of attribute names and value
Example
>>> output = pyrevit.output.get_output() >>> output.inject_to_body('script', '', # no script since it's a link {'src': js_script_file_path})
-
inject_to_head
(element_tag, element_contents, attribs=None)¶ Inject html element to current html head of the output window.
Parameters: - element_tag (str) – html tag of the element e.g. ‘div’
- element_contents (str) – html code of the element contents
- attribs (
dict
) – dictionary of attribute names and value
Example
>>> output = pyrevit.output.get_output() >>> output.inject_to_head('script', '', # no script since it's a link {'src': js_script_file_path})
-
insert_divider
(level='')¶ Add horizontal rule to the output window.
-
static
linkify
(element_ids, title=None)¶ Create clickable link for the provided element ids.
This method, creates the link but does not print it directly.
Parameters: - element_ids (
list
of ElementId) – - element_ids – single or multiple ids
- title (str) – tile of the link. defaults to list of element ids
Example
>>> output = pyrevit.output.get_output() >>> for idx, elid in enumerate(element_ids): >>> print('{}: {}'.format(idx+1, output.linkify(elid)))
- element_ids (
-
lock_size
()¶ Lock window size.
-
log_debug
(message)¶ Report DEBUG message into output logging panel.
-
log_error
(message)¶ Report ERROR message into output logging panel.
-
log_info
(message)¶ Report INFO message into output logging panel.
-
log_success
(message)¶ Report SUCCESS message into output logging panel.
-
log_warning
(message)¶ Report WARNING message into output logging panel.
-
make_bar_chart
(version=None)¶ PyRevitOutputChart
: Return bar chart object.
-
make_bubble_chart
(version=None)¶ PyRevitOutputChart
: Return bubble chart object.
-
make_chart
(version=None)¶ PyRevitOutputChart
: Return chart object.
-
make_doughnut_chart
(version=None)¶ PyRevitOutputChart
: Return dougnut chart object.
-
make_line_chart
(version=None)¶ PyRevitOutputChart
: Return line chart object.
-
make_pie_chart
(version=None)¶ PyRevitOutputChart
: Return pie chart object.
-
make_polar_chart
(version=None)¶ PyRevitOutputChart
: Return polar chart object.
-
make_radar_chart
(version=None)¶ PyRevitOutputChart
: Return radar chart object.
-
make_stacked_chart
(version=None)¶ PyRevitOutputChart
: Return stacked chart object.
-
next_page
()¶ Add hidden next page tag to the output window.
This is helpful to silently separate the output to multiple pages for better printing.
-
open_page
(dest_file)¶ Open html page in output window.
Parameters: dest_file (str) – full path of the target html file
-
open_url
(dest_url)¶ Open url page in output window.
Parameters: dest_url (str) – web url of the target page
-
output_id
¶ Return id of the output window.
In current implementation, Id of output window is equal to the unique id of the pyRevit command it belongs to. This means that all output windows belonging to the same pyRevit command, will have identical output_id values.
Type: str
-
output_uniqueid
¶ Return unique id of the output window.
In current implementation, unique id of output window is a GUID string generated when the output window is opened. This id is unique to the instance of output window.
Type: str
-
static
print_code
(code_str)¶ Print code to the output window with special formatting.
Example
>>> output = pyrevit.output.get_output() >>> output.print_code('value = 12')
-
static
print_html
(html_str)¶ Add the html code to the output window.
Example
>>> output = pyrevit.output.get_output() >>> output.print_html('<strong>Title</strong>')
-
print_image
(image_path)¶ Prints given image to the output.
Example
>>> output = pyrevit.output.get_output() >>> output.print_image(r'C:\image.gif')
-
static
print_md
(md_str)¶ Process markdown code and print to output window.
Example
>>> output = pyrevit.output.get_output() >>> output.print_md('### Title')
-
print_table
(table_data, columns=None, formats=None, title='', last_line_style='')¶ Print provided data in a table in output window.
Parameters: - table_data (
list
of iterables) – 2D array of data - title (str) – table title
- columns (
list
str) – list of column names - formats (
list
str) – column data formats - last_line_style (str) – css style of last row
Example
>>> data = [ ... ['row1', 'data', 'data', 80 ], ... ['row2', 'data', 'data', 45 ], ... ] >>> output.print_table( ... table_data=data, ... title="Example Table", ... columns=["Row Name", "Column 1", "Column 2", "Percentage"], ... formats=['', '', '', '{}%'], ... last_line_style='color:red;' ... )
- table_data (
-
renderer
¶ Return html renderer inside output window.
Returns: System.Windows.Forms.WebBrowser
(In current implementation)
-
reset_icon
()¶ Sets icon on the output window.
-
reset_progress
()¶ Reset output window progress bar to zero.
-
resize
(width, height)¶ Resize window to the new width and height.
-
save_contents
(dest_file)¶ Save html code of the window.
Parameters: dest_file (str) – full path of the destination html file
-
self_destruct
(seconds)¶ Set self-destruct (close window) timer.
Parameters: seconds (int) – number of seconds after which window is closed.
-
set_font
(font_family, font_size)¶ Set window font family to the new font family and size.
Parameters: - font_family (str) – font family name e.g. ‘Courier New’
- font_size (int) – font size e.g. 16
-
set_height
(height)¶ Set window height to the new height.
-
set_icon
(iconpath)¶ Sets icon on the output window.
-
set_title
(new_title)¶ Set window title to the new title.
-
set_width
(width)¶ Set window width to the new width.
-
show
()¶ Show the window.
-
show_logpanel
()¶ Show output window logging panel.
-
unfreeze
()¶ Unfreeze output content update.
-
unhide_progress
()¶ Unhide output window progress bar.
-
unlock_size
()¶ Unock window size.
-
update_progress
(cur_value, max_value)¶ Activate and update the output window progress bar.
Parameters: - cur_value (float) – current progress value e.g. 50
- max_value (float) – total value e.g. 100
Example
>>> output = pyrevit.output.get_output() >>> for i in range(100): >>> output.update_progress(i, 100)
-
window
¶ Return output window object.
Type: PyRevitLabs.PyRevit.Runtime.ScriptConsole
-
-
pyrevit.output.
docclosing_eventhandler
(sender, args)¶ Close all output window on document closing.
-
pyrevit.output.
get_default_stylesheet
()¶ Return default css stylesheet used by output window.
-
pyrevit.output.
get_output
()¶ pyrevit.output.PyRevitOutputWindow
: Return output window.
-
pyrevit.output.
get_stylesheet
()¶ Return active css stylesheet used by output window.
-
pyrevit.output.
reset_stylesheet
()¶ Reset active stylesheet to default.
-
pyrevit.output.
set_stylesheet
(stylesheet)¶ Set active css stylesheet used by output window.
Parameters: stylesheet (str) – full path to stylesheet file
-
pyrevit.output.
setup_output_closer
()¶ Setup document closing event listener.