linkmaker
Handle creation of output window helper links.
Attributes
mlogger = get_logger(__name__)
module-attribute
PROTOCOL_NAME = 'revit://outputhelpers?'
module-attribute
MAX_INLINE_QUERY_LENGTH = 2000
module-attribute
APPEND_SELECTION_ONCLICK = 'onclick="var appendEvt=window.event||event;var appendLnk=this;if(appendEvt.ctrlKey){location.href=this.href+\'&append=true\';setTimeout(function(){appendLnk.style.backgroundColor="#f39c12";},0);return false;}return true;"'
module-attribute
LINK_SHOW_ICON = 'M9.5,3A6.5,6.5 0 0,1 16,9.5C16,11.11 15.41,12.59 14.44,13.73L14.71,14H15.5L20.5,19L19,20.5L14,15.5V14.71L13.73,14.44C12.59,15.41 11.11,16 9.5,16A6.5,6.5 0 0,1 3,9.5A6.5,6.5 0 0,1 9.5,3M9.5,5C7,5 5,7 5,9.5C5,12 7,14 9.5,14C12,14 14,12 14,9.5C14,7 12,5 9.5,5Z'
module-attribute
DEFAULT_LINK = '<span><a class="elementlink" style="margin-right:0px;padding-right:3px" title="Click to select or show element" {attrs_select} >{ids}</a><a class="elementlink" style="margin-left:0px;padding-left:3px" {attrs_show}><svg width="14" height="14" viewBox="2 2 20 20" ><path fill="white" d="{show_icon}" /></svg></a></span>'
module-attribute
Functions:
make_link(element_ids, contents=None, register_ids=None)
Create link for given element ids.
This link is a special format link with revit:// scheme that is handled
by the output window to select the provided element ids in current project.
Scripts should not call this function directly. Creating clickable element
links is handled by the output wrapper object through the :func:linkify
method.
Ids that fit in a url (under :data:MAX_INLINE_QUERY_LENGTH characters) are
embedded in the link itself. Longer lists are handed to register_ids and
the link carries the token it returns, so any number of elements can be
selected with one link.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
element_ids
|
ElementId | list[ElementId]
|
single or multiple ids |
required |
contents
|
str
|
label of the link. defaults to the list of ids, or to the element count when the ids are registered |
None
|
register_ids
|
callable
|
receives the comma separated id values and returns the token the output window resolves back to them. Only called when the ids do not fit in the url |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
when an item is not an ElementId, or the ids do not fit in
the url and no |
Examples:
output = pyrevit.output.get_output()
for idx, elid in enumerate(element_ids):
print('{}: {}'.format(idx+1, output.linkify(elid)))