Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions pyrevitlib/pyrevit/output/linkmaker.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
"""Handle creation of output window helper links."""

from pyrevit.compat import safe_strtype, get_elementid_value_func
from pyrevit import DB
from pyrevit.coreutils.logger import get_logger


Expand Down Expand Up @@ -63,7 +62,21 @@ def make_link(element_ids, contents=None):
link_title = ', '.join(strids)

if len(reviturl) >= 2000:
alertjs = 'alert("Url was too long and discarded!");'
total_length = 0
max_elements = 0
elementquery_parts = ['element[]=' + strid for strid in strids]
for i, part in enumerate(elementquery_parts):
if i > 0:
total_length += 1 # for '&'
total_length += len(part)
if total_length >= 2000:
break
max_elements += 1

alertjs = \
'alert("URL was too long ({} characters). Maximum allowed is 2000. '\
'Only {} out of {} elements could fit.");'\
.format(len(reviturl), max_elements, len(strids))
linkattrs_select = 'href="#" onClick="{}"'.format(alertjs)
linkattrs_show = linkattrs_select
else:
Expand Down