Emojis breaking output.print_table

Im not sure if i am just doing something wrong or if this might be a bug, so i wanted to check here before i open a github issue.

When outputting a table using emojis in a “column” it seems to break the formatting, im not sure what is going on exactly, so ill just post some screenshots below.

When using Emojis:

When using normal string:
image

Hi @THEfonz
Could you please post the code you’re using? This might help better understand the error and provide a solution for you.

Sure things. I probably should have done that initially.

# -*- coding: utf-8 -*-

import clr
clr.AddReference('RevitAPI')
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.UI import *
from pyrevit import script

# Get the active document
doc = __revit__.ActiveUIDocument.Document

output = script.get_output()

# Define the tests to check. Allows sending list to output even if the list is empty
tests = ["Test 1",  "Test 2"]

def check_element(element, output):
    data = []

    try:
        if """Test Something""":
            title = "Test 1"
            datarow = [ ":emoji-shorthand:",output.linkify(element.Id), element.Name]
            data.append((title, datarow))
    except AttributeError:
        pass

    try:
        if """Test Something""":
            title = "Test 2"
                datarow = [":emoji-shorthand:",output.linkify(element.Id), element.Name]
                data.append((title, datarow))
    except AttributeError:
        pass

    return data

# Initialize results with all tests
results = {test: [] for test in tests}

# Collect all elements once
all_elements = FilteredElementCollector(doc).WhereElementIsNotElementType().ToElements()

warningTable = []

# Perform all checks
for element in all_elements:
    element_data = check_element(element, output)
    for title, datarow in element_data:
        results[title].append(datarow)

# Print results for each test
for test in tests:
    datarows = results[test]
    if not datarows:  # If there are no failing elements for this test
        datarows = [[":emoji-shorthand:","N/A", "No failing elements"]]
    output.print_table(table_data=datarows,
                       title=test,
                       columns=["Check","ID", "Description"])

I’m not able to reproduce the error with the code you posted; but let’s start small: what is your output if you run the following code?

# -*- coding: utf-8 -*-
from pyrevit import script
output = script.get_output()
datarows = [[":cross_mark:", "N/A", "No failing elements"]]
output.print_table(
    table_data=datarows,
    title="test",
    columns=["Check","ID", "Description"]
)

I assume you used :cross_mark: where you stated emoji-shorthand; if not, please provide the exact emoji and check if anything changes with other emojis.

If you still encounter the error, try to add a space after the shorthand: ":cross_mark: "

using your example, it exports as expected:

I did some additional testing:
It seems to be happening for each addtional item in the list.

One item in list:
image

Two items in list:
image

Three items in list:
image

I also tried adding a space before the shorthand, after the shorthand and both before and after the shorthand. doing that did not solve the error.

1 Like

Thanks for taking the time to investigate this issue!

I didn’t test it on my setup yet, but to me it seems a bug worth opening an issue on github.

Cc @Jean-Marc to keep him posted: looking through the code I didn’t find anything obvious about this issue, but I discovered that emojis are png images in a zip file;
Since the output window is just a web browser control, we could set the css to use a monospaced font that supports emoji characters and drop the png embedding altogether. What do you think?

Another useful thing could be generate the tables directly in html as I proposet in another thread to minimise the conversion steps and related bugs

1 Like

This is definitely a bug!

I opened a new issue on github explaining it.

1 Like

Thanks for looking into this.
Now that there is a GitHub issue. ill mark this thread as solved and keep an eye on GitHub for a new release.

I merged @sanzoghenzo PR.
Please @THEfonz try these installers with the fix

And report

1 Like

image

That looks like it solved the issue.
Thanks @Jean-Marc

You should thank @sanzoghenzo
He did the digging and fixing!

Thanks @sanzoghenzo. :heart:

2 Likes