Fix #7784: Fix drawing names with special chars in sheets#7818
Open
theoryshaw wants to merge 1 commit intov0.8.0from
Open
Fix #7784: Fix drawing names with special chars in sheets#7818theoryshaw wants to merge 1 commit intov0.8.0from
theoryshaw wants to merge 1 commit intov0.8.0from
Conversation
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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 comparingPath(reference.Location).stem(the sanitised filename) againstIfcAnnotation.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 onIfcDocumentInformation.Nameviaget_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 tontpath.basename(foreground_path)[0:-4](the sanitised filename stem) whenIfcDocumentReference.Namewas empty — which it always is for sheet drawing references, since it is never explicitly set. TheIfcAnnotationentity is already in scope at this point and carries the full name, so the fallback now usesdrawing.Nameinstead.3.
Drawing.import_sheets(tool/drawing.py) The sheet list UI displayedos.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 toIfcAnnotation.Nameacross 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_filenamestrictly limited to constructing file paths.