Extend ifc.py — extended IFC export helper#3147
Extend ifc.py — extended IFC export helper#3147jmcouffin merged 4 commits intopyrevitlabs:developfrom
ifc.py — extended IFC export helper#3147Conversation
|
Unable to trigger custom agent "Code Reviewer". You have run out of credits 😔 |
There was a problem hiding this comment.
Pull request overview
Extends pyrevitlib/pyrevit/interop/ifc.py from a simple Ifc.Net bootstrapper into a helper library that can parse Revit-exported IFC JSON configs, build Autodesk.Revit.DB.IFCExportOptions, and drive Revit’s IFC export via a small IFCExporter wrapper.
Changes:
- Added
load_config()to parse Revit IFC export configuration JSON. - Added
build_export_options()to map config/overrides intoIFCExportOptions(including tessellation decimal-separator workaround) and optional view filtering. - Added
IFCExporter(doc).export(...)to perform a one-call IFC export with optional config/overrides.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|
📦 New work-in-progress (wip) builds are available for 6.1.0.26061+1027-wip |
|
📦 New work-in-progress (wip) builds are available for 6.1.0.26061+1126-wip |
|
📦 New work-in-progress (wip) builds are available for 6.1.0.26061+1139-wip |
|
📦 New work-in-progress (wip) builds are available for 6.1.0.26061+1233-wip |
|
📦 New work-in-progress (wip) builds are available for 6.1.0.26061+1244-wip |
|
📦 New work-in-progress (wip) builds are available for 6.1.0.26061+1357-wip |
|
📦 New work-in-progress (wip) builds are available for 6.1.0.26061+1403-wip |
Description
The existing
ifc.pylib only bootstraps theIfc.NetCLR assembly (schema/geometry types). It provides no support for driving Revit's own IFC export pipeline. This PR extendsifc.py, with a thin wrapper aroundAutodesk.Revit.DB.IFCExportOptionsthat fills that gap.What's new
load_config(path)— parses a Revit-exported IFC configuration JSON filebuild_export_options(config, overrides)— maps JSON keys ontoIFCExportOptionsproperties andAddOptioncalls, handles nested keys (ProjectAddress,ClassificationSettings), and includes a workaround for the Revit tessellation decimal-separator bug (.→,)IFCExporter(doc).export(...)— one-call export with optional config file, runtime overrides, view filter, and console loggingscript.py— developer-tab test script with folder/config picker and output panel loggingWhy the tessellation workaround is in the lib
Revit's IFC exporter plugin reads
TessellationLevelOfDetailfromAddOptionand parses it with the system locale, which expects a comma as the decimal separator on non-English Windows installs (and inconsistently on EN installs too). Normalising it here keeps every call site clean.Testing
Tested against Revit 2024, IronPython 2.7, with the attached
IFC_config_sample.json. RunExportIFCfrom the Developer tab against any open document to verify.Checklist
Before submitting your pull request, ensure the following requirements are met:
pipenv run black {source_file_or_directory}