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 :func:get_output
of :mod:pyrevit.script
module. This method, in return
uses the pyrevit.output
module to get access to the output wrapper.
Examples:
Here is the source of :func:pyrevit.script.get_output
. As you can see this
functions calls the :func:pyrevit.output.get_output
to receive the
output wrapper.
.. literalinclude:: ../../pyrevitlib/pyrevit/script.py :pyobject: get_output
Attributes
mlogger = logger.get_logger(__name__)
module-attribute
DEFAULT_STYLESHEET_NAME = 'outputstyles.css'
module-attribute
active_stylesheet = user_config.output_stylesheet or get_default_stylesheet()
module-attribute
Classes
PyRevitOutputWindow
Bases: object
Wrapper to interact with the output window.
Attributes
window
property
PyRevitLabs.PyRevit.Runtime.ScriptConsole
: Return output window object.
renderer
property
Return html renderer inside output window.
Returns:
Type | Description |
---|---|
WebBrowser
|
HTML renderer |
output_id
property
str: 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.
output_uniqueid
property
str: 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.
is_closed_by_user
property
Whether the window has been closed by the user.
last_line
property
Last line of the output window.
debug_mode
property
writable
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.
Functions
self_destruct(seconds)
Set self-destruct (close window) timer.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
seconds |
int
|
number of seconds after which window is closed. |
required |
inject_to_head(element_tag, element_contents, attribs=None)
Inject html element to current html head of the output window.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
element_tag |
str
|
html tag of the element e.g. 'div' |
required |
element_contents |
str
|
html code of the element contents |
required |
attribs |
obj: |
None
|
Examples:
output = pyrevit.output.get_output()
output.inject_to_head('script',
'', # no script since it's a link
{'src': js_script_file_path})
Source code in pyrevitlib/pyrevit/output/__init__.py
inject_to_body(element_tag, element_contents, attribs=None)
Inject html element to current html body of the output window.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
element_tag |
str
|
html tag of the element e.g. 'div' |
required |
element_contents |
str
|
html code of the element contents |
required |
attribs |
obj: |
None
|
Examples:
output = pyrevit.output.get_output()
output.inject_to_body('script',
'', # no script since it's a link
{'src': js_script_file_path})
Source code in pyrevitlib/pyrevit/output/__init__.py
inject_script(script_code, attribs=None, body=False)
Inject script tag into current head (or body) of the output window.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
script_code |
str
|
javascript code |
required |
attribs |
obj: |
None
|
|
body |
bool
|
injects script into body instead of head |
False
|
Examples:
output = pyrevit.output.get_output()
output.inject_script('', # no script since it's a link
{'src': js_script_file_path})
Source code in pyrevitlib/pyrevit/output/__init__.py
add_style(style_code, attribs=None)
Inject style tag into current html head of the output window.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
style_code |
str
|
css styling code |
required |
attribs |
obj: |
None
|
Examples:
Source code in pyrevitlib/pyrevit/output/__init__.py
get_head_html()
set_title(new_title)
set_width(width)
set_height(height)
set_font(font_family, font_size)
Set window font family to the new font family and size.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
font_family |
str
|
font family name e.g. 'Courier New' |
required |
font_size |
int
|
font size e.g. 16 |
required |
Source code in pyrevitlib/pyrevit/output/__init__.py
resize(width, height)
center()
Center the output window on the screen.
Source code in pyrevitlib/pyrevit/output/__init__.py
get_title()
get_width()
get_height()
close()
close_others(all_open_outputs=False)
Close all other windows that belong to the current command.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
all_open_outputs |
bool
|
Close all any other windows if True |
False
|
Source code in pyrevitlib/pyrevit/output/__init__.py
hide()
show()
lock_size()
unlock_size()
freeze()
unfreeze()
save_contents(dest_file)
Save html code of the window.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dest_file |
str
|
full path of the destination html file |
required |
Source code in pyrevitlib/pyrevit/output/__init__.py
open_url(dest_url)
Open url page in output window.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dest_url |
str
|
web url of the target page |
required |
open_page(dest_file)
Open html page in output window.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
dest_file |
str
|
full path of the target html file |
required |
update_progress(cur_value, max_value)
Activate and update the output window progress bar.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
cur_value |
float
|
current progress value e.g. 50 |
required |
max_value |
float
|
total value e.g. 100 |
required |
Examples:
Source code in pyrevitlib/pyrevit/output/__init__.py
reset_progress()
hide_progress()
unhide_progress()
indeterminate_progress(state)
show_logpanel()
hide_logpanel()
log_debug(message)
log_success(message)
log_info(message)
log_warning(message)
log_error(message)
set_icon(iconpath)
reset_icon()
print_html(html_str)
staticmethod
Add the html code to the output window.
Examples:
Source code in pyrevitlib/pyrevit/output/__init__.py
print_code(code_str)
staticmethod
Print code to the output window with special formatting.
Examples:
Source code in pyrevitlib/pyrevit/output/__init__.py
print_md(md_str)
staticmethod
Process markdown code and print to output window.
Examples:
Source code in pyrevitlib/pyrevit/output/__init__.py
print_table(table_data, columns=None, formats=None, title='', last_line_style='')
Print provided data in a table in output window.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
table_data |
list[iterable[Any]]
|
2D array of data |
required |
title |
str
|
table title |
''
|
columns |
list[str]
|
list of column names |
None
|
formats |
list[str]
|
column data formats |
None
|
last_line_style |
str
|
css style of last row |
''
|
Examples:
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;'
)
Source code in pyrevitlib/pyrevit/output/__init__.py
print_image(image_path)
Prints given image to the output.
Examples:
Source code in pyrevitlib/pyrevit/output/__init__.py
insert_divider(level='')
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.
Source code in pyrevitlib/pyrevit/output/__init__.py
linkify(element_ids, title=None)
staticmethod
Create clickable link for the provided element ids.
This method, creates the link but does not print it directly.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
element_ids |
ElementId | list[ElementId]
|
single or multiple ids |
required |
title |
str
|
tile of the link. defaults to list of element ids |
None
|
Returns:
Type | Description |
---|---|
str
|
clickable link |
Examples:
output = pyrevit.output.get_output()
for idx, elid in enumerate(element_ids):
print('{}: {}'.format(idx+1, output.linkify(elid)))
Source code in pyrevitlib/pyrevit/output/__init__.py
make_chart(version=None)
make_line_chart(version=None)
:obj:PyRevitOutputChart
: Return line chart object.
make_stacked_chart(version=None)
:obj:PyRevitOutputChart
: Return stacked chart object.
Source code in pyrevitlib/pyrevit/output/__init__.py
make_bar_chart(version=None)
:obj:PyRevitOutputChart
: Return bar chart object.
make_radar_chart(version=None)
:obj:PyRevitOutputChart
: Return radar chart object.
make_polar_chart(version=None)
:obj:PyRevitOutputChart
: Return polar chart object.
make_pie_chart(version=None)
:obj:PyRevitOutputChart
: Return pie chart object.
make_doughnut_chart(version=None)
:obj:PyRevitOutputChart
: Return dougnut chart object.
make_bubble_chart(version=None)
:obj:PyRevitOutputChart
: Return bubble chart object.
Functions
docclosing_eventhandler(sender, args)
setup_output_closer()
Setup document closing event listener.
set_stylesheet(stylesheet)
Set active css stylesheet used by output window.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
stylesheet |
str
|
full path to stylesheet file |
required |