Files
IfcOpenShell/src/ifcpatch
Dion Moult 19a1d88970 Fix all ty diagnostics on ifcviewer-wgpu (ci-lint ty-ios + ty-bonsai)
This branch carried v0.8.0's strict `[tool.ty.rules] all = "error"` config but
not the source fixes that were made upstream to satisfy it, so both ci-lint ty
gates were failing: `poe ty-ios` reported 256 diagnostics and `poe ty-bonsai`
258. Both are now clean.

Most fixes are ported from v0.8.0 and follow two idioms: initialise a name
before a conditional that may not bind it (plus an `assert` where the invariant
is real but not provable), and close an exhaustive `if`/`elif` chain with
`else: assert False, <discriminant>`.

The branch's own newer accessors are preserved throughout - `.file`,
`.declaration`, `file.types()`, `get_max_id()` are kept rather than reverted to
`wrapped_data.*`, and non-ty upstream changes (notably the in-progress geometry
cache removal) are deliberately not pulled in.

Notable fixes that are not straight ports:

* ifcopenshell_wrapper.pyi: `entity_instance.file` was declared as
  `def file(self) -> file`, where the property name shadows the `class file`
  below it, so the annotation resolved to `Unknown`. Every `element.file` in
  the codebase was therefore unchecked. Qualifying it to `ifcopenshell.file`
  restores `.schema` to its Literal union and surfaces no new diagnostics.

* model/wall.py: a duplicated merge fragment in the void-straddle path ran an
  always-true `if void_straddles:` that read `new_opening` from the mutually
  exclusive branch (stale value, or NameError on the first iteration), followed
  by an unreachable duplicate `elif`. Removing it makes the file match v0.8.0.

* light/operator.py: upstream's own fix unpacks three targets from two values
  and raises ValueError unconditionally; corrected to `None, None, None`.

* assign_system.py, validate.py, geom/main.py: walrus-in-genexp is valid at
  runtime (PEP 572 binds in the containing scope) but ty does not model it;
  rewritten as explicit loops, matching upstream.

Verified: poe ty-ios, poe ty-bonsai, ruff check src/ nix/, black --check .,
and compileall -W error at py3.10 (ifcopenshell-python) and py3.11 (bonsai).

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-07-27 19:14:39 +10:00
..
2026-07-26 18:03:09 +10:00
2026-01-26 17:10:03 +05:00
2024-06-27 11:49:12 +10:00

IfcPatch

Utility for applying modification recipes to IFC files. IfcPatch enables programmatic editing and correction of IFC models through a collection of patches that can fix common issues, migrate data, or transform models.

Available Recipes

Alignment and Linear Placement

  • AddGeometricRepresentationToAlignment - Add geometric representations to alignment elements
  • AddLinearPlacementFallbackPosition - Add fallback positions for linear placements
  • AddZeroLengthSegmentToAlignment - Add zero-length segments to alignments
  • PatchStationReferentPosition - Patch station referent positions

Data Conversion and Migration

  • AGS2IFC - Convert AGS (geotechnical) data to IFC
  • ConvertLengthUnit - Convert between length units
  • ConvertNestToAggregate - Convert nesting relationships to aggregations
  • ConvertPropertiesToQuantities - Convert properties to quantities
  • Migrate - Migrate between IFC schema versions

Element Extraction and Manipulation

  • ExtractElements - Extract specific elements into a new model
  • ExtractPropertiesToSQLite - Export properties to SQLite database
  • Ifc2Sql - Convert IFC to SQL database
  • TessellateElements - Tessellate elements into triangulated geometry

Fixing Software-Specific Issues

  • FixArchiCADToRevitDoorSwings - Fix door swing orientation from ArchiCAD for Revit
  • FixArchiCADToRevitSpaces - Fix space data from ArchiCAD for Revit
  • FixRevit2025TINs - Fix TIN (Triangulated Irregular Network) issues from Revit 2025
  • FixRevitClassificationCodeTypes - Fix classification code data types from Revit
  • FixRevitTINs - Fix TIN issues from Revit

Geometry and Representation

  • AssignConstituentFractions - Assign fractions to material constituents
  • DowngradeIndexedPolyCurve - Convert indexed poly curves to simpler representations
  • RemoveSiteRepresentation - Remove geometric representation from site elements

Merging and Optimization

  • MergeDuplicateTypes - Merge duplicate element types
  • MergeProjects - Merge multiple IFC projects
  • MergeStyles - Merge duplicate styles
  • Optimise - Optimize file size and structure
  • PurgeData - Remove unused data from model

Spatial and Coordinate Systems

  • OffsetObjectPlacements - Offset object placement coordinates
  • OffsetStoreyElevations - Offset storey elevations
  • ResetAbsoluteCoordinates - Reset absolute coordinates to origin
  • ResetSpatialElementLocations - Reset spatial element locations
  • SetFalseOrigin - Set a false origin for coordinates
  • SetRefElevation - Set reference elevation
  • SetWorldCoordinateSystem - Set world coordinate system
  • SplitByBuildingStorey - Split model by building storeys

Utilities

  • RecycleNonRootedElements - Remove or recycle non-rooted elements
  • RegenerateGlobalIds - Regenerate GlobalId values for elements
  • RemoveRevitUniformatClassification - Remove Revit Uniformat classification
  • UnsharePsets - Unshare property sets between elements