Skip to content

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

Open
theoryshaw wants to merge 1 commit intov0.8.0from
dont_sanitize_drawing_name
Open

Fix #7784: Fix drawing names with special chars in sheets#7818
theoryshaw wants to merge 1 commit intov0.8.0from
dont_sanitize_drawing_name

Conversation

@theoryshaw
Copy link
Copy Markdown
Member

Drawing names containing special characters such as (, ), and & were being unintentionally stripped in several places in the sheet and drawing workflow.

The root cause is Drawing.sanitise_filename, which intentionally restricts filenames to alphanumeric characters and ._- for filesystem safety. This is correct behaviour for file paths. However, the sanitised filename stem was leaking back into three places where the full human-readable IFC name should be used instead:

1. Drawing.add_drawings (tool/drawing.py) When building a sheet layout, drawings were matched to their sheet references by comparing Path(reference.Location).stem (the sanitised filename) against IfcAnnotation.Name. If the drawing name contained special characters, these two values would differ and the drawing would silently not be added to the sheet. Fixed by keying on IfcDocumentInformation.Name via get_reference_document() instead of the file stem.

2. SheetBuilder.build_drawings (sheeter.py) When building the final sheet SVG, the view title data fell back to ntpath.basename(foreground_path)[0:-4] (the sanitised filename stem) when IfcDocumentReference.Name was empty — which it always is for sheet drawing references, since it is never explicitly set. The IfcAnnotation entity is already in scope at this point and carries the full name, so the fallback now uses drawing.Name instead.

3. Drawing.import_sheets (tool/drawing.py) The sheet list UI displayed os.path.basename(reference.Location) as the drawing name under each sheet, again using the sanitised filename. Fixed by building a reverse lookup from resolved file location to IfcAnnotation.Name across all drawing annotations, so the full name is shown in the UI.

In all three cases the fix is to use the IFC name as the authoritative source, keeping sanitise_filename strictly limited to constructing file paths.

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant