Fix #7784: Fix drawing names with special chars in sheets

Drawing names containing characters like (, ), and & were
being stripped when displayed in the sheet list and SVG view
titles, because the sanitised filename stem was used instead
of the IFC annotation name.

Generated with the assistance of an AI coding tool.
This commit is contained in:
Ryan Schultz
2026-03-19 06:40:47 -05:00
parent ba36dc82ff
commit 45c64e1b4a
2 changed files with 13 additions and 4 deletions
@@ -435,7 +435,7 @@ class SheetBuilder:
data = reference.get_info()
data.update({"Sheet" + k: v for k, v in sheet.get_info().items()})
if not data["Name"]:
data["Name"] = ntpath.basename(foreground_path)[0:-4]
data["Name"] = drawing.Name or ntpath.basename(foreground_path)[0:-4]
# If a perspective drawing, don't add scale to view title
try:
+12 -3
View File
@@ -482,8 +482,10 @@ class Drawing(bonsai.core.tool.Drawing):
for reference in cls.get_document_references(sheet):
reference_description = cls.get_reference_description(reference)
if reference_description == "DRAWING":
drawing_references[Path(reference.Location).stem] = reference
drawing_names.append(Path(reference.Location).stem)
info = cls.get_reference_document(reference)
drawing_name = info.Name if info else Path(reference.Location).stem
drawing_references[drawing_name] = reference
drawing_names.append(drawing_name)
for drawing_annotation in [e for e in tool.Ifc.get().by_type("IfcAnnotation") if e.ObjectType == "DRAWING"]:
if drawing_annotation.Name in drawing_names:
sheet_builder.add_drawing(drawing_references[drawing_annotation.Name], drawing_annotation, sheet)
@@ -1131,6 +1133,12 @@ class Drawing(bonsai.core.tool.Drawing):
if not new.is_expanded:
continue
drawing_name_by_location = {
cls.get_document_uri(cls.get_drawing_document(d)): d.Name
for d in tool.Ifc.get().by_type("IfcAnnotation")
if d.ObjectType == "DRAWING" and cls.get_drawing_document(d)
}
for reference in cls.get_document_references(sheet):
reference_description = cls.get_reference_description(reference)
if reference_description in ("SHEET", "LAYOUT", "RASTER"):
@@ -1145,7 +1153,8 @@ class Drawing(bonsai.core.tool.Drawing):
else:
new.identification = reference.Identification or ""
new.name = os.path.basename(reference.Location)
resolved_location = cls.get_document_uri(reference)
new.name = drawing_name_by_location.get(resolved_location) or os.path.basename(reference.Location)
new.reference_type = reference_description
@classmethod