Skip to content

[Bug]: No data is available for encoding 0. #2729

@neilsonandrew

Description

@neilsonandrew

✈ Pre-Flight checks

  • I don't have SentinelOne antivirus installed (see above for the solution)
  • I have searched in the issues (open and closed) but couldn't find a similar issue
  • I have searched in the pyRevit Forum for similar issues
  • I already followed the installation troubleshooting guide thoroughly
  • I am using the latest pyRevit Version

🐞 Describe the bug

Error message appears after each sync in Revit 2026.
hooks.doc-synced "No data is available for encoding 0."
Error was not present in Revit 2024.

I do have SentinelOne installed but IT has provided the required exceptions.
The issue only presents in Revit 2026.
doc-synced is replicated below and attached as .ZIP file

⌨ Error/Debug Message

No data is available for encoding 0. For information on defining a custom encoding, see the documentation for the the encoding.RegisterProvider method.

♻️ To Reproduce

  1. Revit Sync document
  2. PyRevit Warning dialog display error after completing the sync.
  3. Error occurs in Revit 2026 but not Revit 2024

⏲️ Expected behavior

This is the code in the hooks/doc-synced.py

from pyrevit import EXEC_PARAMS, script
from Autodesk.Revit import DB
import CDA_UTILITY
import CDA_LOG

from pyrevit.coreutils import envvars
doc = EXEC_PARAMS.event_args.Document
import random
__title__   = "Synced"
def warn_non_enclosed_area():
    areas = DB.FilteredElementCollector(doc).OfCategory(DB.BuiltInCategory.OST_Areas).ToElements()
    bad_areas = filter(lambda x: x.Area == 0, areas)
    if len(bad_areas) > 0:
        CDA_UTILITY.show_toast(message = "They might have impact on the accuracy of your Area Schedule.", title = "There are {} non-placed/redundant/non-enclosed areas in the file.".format(len(bad_areas)))


def warn_non_enclosed_room():
    rooms = DB.FilteredElementCollector(doc).OfCategory(DB.BuiltInCategory.OST_Rooms).ToElements()
    bad_rooms = filter(lambda x: x.Area == 0, rooms)
    if len(bad_rooms) > 0:
        CDA_UTILITY.show_toast(message = "A bad room might be either non-placed/redudent/non-enclosed.", title = "There are {} bad rooms in need of attention.".format(len(bad_rooms)))



def is_level_grid_change_in_doc():
    # need to comfirm by user if after sync, the collection of grids or levels changed. Need to use long term ID, stable ID
    pass


def warn_bad_sized_meeting_rm():
    # only deal with N3 model

    if doc.Title != "2135_BiliBili SH HQ_N3":
        return

    if envvars.get_pyrevit_env_var("IS_SYNC_QUEUE_DISABLED"):
        # when  gloabl sync queue disabled, dont want to see dialogue
        return

    # get all rooms
    all_rms = DB.FilteredElementCollector(doc).OfCategory(DB.BuiltInCategory.OST_Rooms).ToElements()

    # filter room under department == visitor center
    visitor_rooms = filter(lambda x: x.LookupParameter("Department").AsString() == "VISITOR TRAINING", all_rms)

    # filter meeting rooms
    meeting_rms = filter(lambda x: "MEETING RM" in x.LookupParameter("Name").AsString(), visitor_rooms)

    # s, m ,l room group
    def is_room_area_ok(room):
        room_name = room.LookupParameter("Name").AsString()
        if "(S)" in room_name:
            low_bound, up_bound = 20, 28
        elif "(M)" in room_name:
            low_bound, up_bound = 28, 38
        elif "(L)" in room_name:
            low_bound, up_bound = 38, 9999
        else:
            low_bound, up_bound = 1, 0 # force bad display becasue up bound is smaller than low bound

        if CDA_UTILITY.sqm_to_internal(low_bound) <= room.Area <= CDA_UTILITY.sqm_to_internal(up_bound):
            return True
        return False

    bad_rooms = filter(lambda x: not(is_room_area_ok(x)), meeting_rms)

    if len(bad_rooms) == 0:
        return

    """
    t = DB.Transaction(doc, "mark bad room")
    t.Start()
    map()
    """
    bad_rooms.sort(key = lambda x: (x.Level.Name, x.LookupParameter("Name").AsString(), x.Area ))

    CDA_UTILITY.show_toast(message = "Go to '(6_Visitor Center) Meeting Room Schedule' for details", title = "There are {} meeting rooms not meeting area requirement".format(len(bad_rooms)))

    for room in bad_rooms:
        print "{}_{}: {} sqm --->{}".format(room.Level.Name, room.LookupParameter("Name").AsString(), CDA_UTILITY.sqft_to_sqm(room.Area), script.get_output().linkify(room.Id, title = "Go To Room"))
    print "\n\n"

    note = "N3 visitor center has {} meeting rooms not meeting desired area target for typical meeting room.\n\nYou can also go to '(6_Visitor Center) Meeting Room Schedule' for details".format(len(bad_rooms))
    print note

    print "\n"
    sub_note = "Rule:\nMeeting RM(S):20~28 sqm\nMeeting RM(M):28~38 sqm\nMeeting RM(L):38+ sqm"
    print sub_note
    user_name = CDA_UTILITY.get_application().Username
    if user_name in ["saurabh.j"] or CDA_UTILITY.is_SZ():
        try:
            if envvars.get_pyrevit_env_var("IS_AFTER_SYNC_WARNING_DISABLED"):
                return
        except Exception as e:
            CDA_UTILITY.print_note("error getting <IS_AFTER_SYNC_WARNING_DISABLED> varable: " + e)
        CDA_UTILITY.modeless_form_no_func(main_text = note, sub_text = sub_note, window_width = 500, window_height = 500, self_destruct = 10)
        #CDA_UTILITY.dialogue(main_text = note, sub_text = sub_note)


def update_sync_queue():
    if envvars.get_pyrevit_env_var("IS_SYNC_CANCELLED"):
        return

    log_file = r"F:\\04_BIM\\10_DB\\CDA_tools Logs\\Sync_Queue\\Sync Queue_{}.queue".format(doc.Title)
    try:
        with open(log_file, "r"):
            pass
    except:
        with open(log_file, "w+"):
            pass

    queue = CDA_UTILITY.read_txt_as_list(log_file)
    user_name = CDA_UTILITY.get_application().Username
    OUT = [item for item in queue if user_name not in item]
    CDA_UTILITY.save_list_to_txt(OUT, log_file)

    if envvars.get_pyrevit_env_var("IS_SYNC_QUEUE_DISABLED"):
        return

    if not OUT:
        #CDA_UTILITY.print_note("Cannot find next user.")
        return

    try:
        next_user = OUT[0].split("]")[-1]
    except Exception as e:
        CDA_UTILITY.print_note("Error finding next user.")
        CDA_UTILITY.print_traceback()
        return

    try:
        # Show a modeless form with next user details
        #CDA_UTILITY.modeless_form_no_func(main_text = "[{}]\nshould sync next.\nPlease go ahead and msg him/her now.".format(next_user), sub_text = "Expect slight network lag between server to transfer waitlist file.", window_width = 500, window_height = 400, self_destruct = 15)
        """
        #CDA_UTILITY.dialogue(main_text = "[{}] should sync next.\nPlease go ahead and msg him/her now.".format(next_user),
                            sub_text = "Expect slight network lag between SH/NY server to transfer waitlist file.\n")
        """
        pass
    except Exception as e:
        print(e)
    

def OLD_warn_revit_session_too_long(non_interuptive = True):

    try:

        if CDA_UTILITY.time_has_passed_too_long(envvars.get_pyrevit_env_var("APP_UPTIME"), tolerence = 60 * 60 * 24):
            #CDA_UTILITY.dialogue(main_text = "This Revit session has been running for more than 24Hours.\n\nPlease consider restarting Revit to release memory and improve performance.")
            CDA_LOG.session_too_long()
            if non_interuptive:
                CDA_UTILITY.show_toast(message = "That is just bad..", title = "Your Revit seesion has been running for more than 24Hours.")
            else:
                CDA_UTILITY.show_toast(message = "That is just bad..", title = "Your Revit seesion has been running for more than 24Hours.")
                #CDA_UTILITY.modeless_form_no_func(main_text = "This Revit session has been running for more than 24Hours.\nPaying $300 Shark Tokens.", sub_text = "Please consider restarting Revit to release memory and improve performance.", window_width = 500, window_height = 300, self_destruct = 3)
    except Exception as e:
        #CDA_UTILITY.print_note("cannot warn too long session")
        #CDA_UTILITY.print_traceback()
        pass

def play_success_sound():
    """
    if not CDA_UTILITY.is_SZ():
        return
    """

    file = 'sound effect_mario join.wav'
    file = 'sound effect_mario 1up.wav'
    CDA_UTILITY.play_sound(file)
    pass

def play_text_to_speech_audio():
    return

    import traceback
    try:
        CDA_UTILITY.speak("Document {} has finished syncing.".format(doc.Title))
    except Exception as e:
        CDA_UTILITY.print_note(e)
        CDA_UTILITY.print_note(traceback.format_exc())

def update_sync_time_record():
    import imp

#################################################################



CDA_LOG.use_cdatab(coin_change = 1, tool_used = __title__.replace("\n", " "), show_toast = False)

🖥️ Hardware and Software Setup (please complete the following information)

Microsoft Windows [Version 10.0.26100.4652]
(c) Microsoft Corporation. All rights reserved.

C:\Windows\System32>pyrevit env
==> Registered Clones (full git repos)
==> Registered Clones (deployed from archive/image)
master | Branch: "master" | Version: "5.2.0.25181+1332" | Path: "C:\Program Files\pyRevit-Master"
==> Attachments
master | Product: "2026 First Customer Ship" | Engine: DEFAULT (2712) | Path: "C:\Program Files\pyRevit-Master" | AllUsers
master | Product: "2025 First Customer Ship" | Engine: DEFAULT (2712) | Path: "C:\Program Files\pyRevit-Master" | AllUsers
master | Product: "2024.3.3" | Engine: DEFAULT (2712) | Path: "C:\Program Files\pyRevit-Master" | AllUsers
master | Product: "2022.1.8" | Engine: DEFAULT (2712) | Path: "C:\Program Files\pyRevit-Master" | AllUsers
master | Product: "2021.1.10" | Engine: DEFAULT (2712) | Path: "C:\Program Files\pyRevit-Master" | AllUsers
master | Product: "2020.2.1 (New Install)" | Engine: DEFAULT (2712) | Path: "C:\Program Files\pyRevit-Master" | AllUsers
master | Product: "2018.3.3 Security Fix" | Engine: DEFAULT (2712) | Path: "C:\Program Files\pyRevit-Master" | AllUsers
master | Product: "2017.2.5 Security Fix" | Engine: DEFAULT (2712) | Path: "C:\Program Files\pyRevit-Master" | AllUsers
master | Product: "2016.1.9 Security Fix" | Engine: DEFAULT (2712) | Path: "C:\Program Files\pyRevit-Master" | AllUsers
==> Installed Extensions
==> Default Extension Search Path
C:\Users\andrew.n\AppData\Roaming\pyRevit\Extensions
==> Extension Search Paths
==> Extension Sources - Default
https://github.com/pyrevitlabs/pyRevit/raw/master/extensions/extensions.json
==> Extension Sources - Additional
==> Installed Revits
2026 First Customer Ship | Version: 26.0.4.409 | Build: 20250227_1515(x64) | Language: 1033 | Path: "C:\Program Files\Autodesk\Revit 2026\"
2025 First Customer Ship | Version: 25.0.2.419 | Build: 20240307_1300(x64) | Language: 1033 | Path: "C:\Program Files\Autodesk\Revit 2025\"
2024.3.3 | Version: 24.3.30.11 | Build: 20250516_1515(x64) | Language: 1033 | Path: "C:\Program Files\Autodesk\Revit 2024\"
2022.1.8 | Version: 22.1.80.32 | Build: 20241107_1515(x64) | Language: 1033 | Path: "C:\Program Files\Autodesk\Revit 2022\"
2021.1.10 | Version: 21.1.100.12 | Build: 20240319_1700(x64) | Language: 1033 | Path: "C:\Program Files\Autodesk\Revit 2021\"
2020.2.1 (New Install) | Version: 20.2.12.1 | Build: 20200210_1400(x64) | Language: 1033 | Path: "C:\Program Files\Autodesk\Revit 2020\"
2018.3.3 Security Fix | Version: 18.3.3.18 | Build: 20190510_1515(x64) | Language: 1033 | Path: "C:\Program Files\Autodesk\Revit 2018\"
2017.2.5 Security Fix | Version: 17.0.1169.0 | Build: 20190508_0315(x64) | Language: 1033 | Path: "C:\Program Files\Autodesk\Revit 2017\"
2016.1.9 Security Fix | Version: 16.0.1218.0 | Build: 20190508_0715(x64) | Language: 1033 | Path: "C:\Program Files\Autodesk\Revit 2016\"
==> Running Revit Instances
==> User Environment
Microsoft Windows 10 [Version 10.0.26100]
Executing User: CDA\andrew.n
Active User: CDA\andrew.n
Admin Access: Yes
%APPDATA%: "C:\Users\andrew.n\AppData\Roaming"
Latest Installed .Net Framework: 8.0.18
No .Net Target Packs are installed.
No .Net-Core Target Packs are installed.
pyRevit CLI v5.2.0.25181+1332.ad837f1fc6ac89979e64710991eb6d846b63c109

Additional context

Everything is operating well in Revit 2024. Issue only occurs in Revit 2026.

doc-synced.zip

Image

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugBug that stops user from using the tool or a major portion of pyRevit functionality [class]needs-more-infoIssue required to follow the bug report template. Triggered by the stale issue workflow

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions