mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-09-22 14:48:02 +00:00
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:
@@ -435,7 +435,7 @@ class SheetBuilder:
|
|||||||
data = reference.get_info()
|
data = reference.get_info()
|
||||||
data.update({"Sheet" + k: v for k, v in sheet.get_info().items()})
|
data.update({"Sheet" + k: v for k, v in sheet.get_info().items()})
|
||||||
if not data["Name"]:
|
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
|
# If a perspective drawing, don't add scale to view title
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -482,8 +482,10 @@ class Drawing(bonsai.core.tool.Drawing):
|
|||||||
for reference in cls.get_document_references(sheet):
|
for reference in cls.get_document_references(sheet):
|
||||||
reference_description = cls.get_reference_description(reference)
|
reference_description = cls.get_reference_description(reference)
|
||||||
if reference_description == "DRAWING":
|
if reference_description == "DRAWING":
|
||||||
drawing_references[Path(reference.Location).stem] = reference
|
info = cls.get_reference_document(reference)
|
||||||
drawing_names.append(Path(reference.Location).stem)
|
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"]:
|
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:
|
if drawing_annotation.Name in drawing_names:
|
||||||
sheet_builder.add_drawing(drawing_references[drawing_annotation.Name], drawing_annotation, sheet)
|
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:
|
if not new.is_expanded:
|
||||||
continue
|
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):
|
for reference in cls.get_document_references(sheet):
|
||||||
reference_description = cls.get_reference_description(reference)
|
reference_description = cls.get_reference_description(reference)
|
||||||
if reference_description in ("SHEET", "LAYOUT", "RASTER"):
|
if reference_description in ("SHEET", "LAYOUT", "RASTER"):
|
||||||
@@ -1145,7 +1153,8 @@ class Drawing(bonsai.core.tool.Drawing):
|
|||||||
else:
|
else:
|
||||||
new.identification = reference.Identification or ""
|
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
|
new.reference_type = reference_description
|
||||||
|
|
||||||
@classmethod
|
@classmethod
|
||||||
|
|||||||
Reference in New Issue
Block a user