Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ All notable changes to the `IfcIO` library are documented in this file.
## [Unreleased]

### Fixed
- IFC export declares feet and inches as conversion-based length units and respects the selected plane angle unit.
Revolved-solid geometry converts between the file's angle unit and radians in memory. The CLI labels storey elevations in the model's units.
- Length quantities follow the model length unit after import, and metre-based cost quantities retain their explicit unit.
- Read options and `ifcio patch --legacy-ifcio-radian-sweeps` let callers repair older IfcIO files with mislabeled sweep angles.
- IFC import no longer treats type definitions, styles, or lining properties as building element occurrences.
- IFC2x3 and IFC4 exports write the profile attributes expected by each schema for I, L and U sections. IFC2x3
parameterized profiles also get the required local placement, including at the origin.
Expand Down
11 changes: 11 additions & 0 deletions docs/public-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@ This page summarizes the public types and entry points of the `IfcIO` package.
| `IfcBuildingStorey`, `IfcSpace` | Storeys hold elements and spaces and carry elevations. The model does not expose separate `IfcSite`, `IfcBuilding`, or `IfcProject` objects. |
| `IfcGuid` | buildingSMART 22-character compressed GlobalId encoder/decoder with bidirectional conversion to 128-bit .NET `Guid`. |

`IfcModel.LengthUnit` controls the declared unit of geometry and storey elevations. IFC import keeps recognised
millimetres, metres, feet and inches in the model; other supported length scales are converted to metres.
`IfcModel.AngleUnit` controls the IFC plane angle unit, but `IfcRevolvedAreaSolid.Angle` is always in radians in memory.
If the file has no usable plane angle unit, the reader assumes radians. Length quantities are read in the same
length unit as geometry; area and volume quantity handling is unchanged.

Older IfcIO exports declared degrees but stored revolved-solid angles in radians. Normal reads trust the IFC unit
declaration. For a file known to have this legacy error, use
`IfcModel.Open(path, new IfcReadOptions { LegacyIfcIoRevolvedAnglesInRadians = true })`, then save the model, or run
`ifcio patch old.ifc --legacy-ifcio-radian-sweeps -o repaired.ifc`.

## Geometry & Representation

| Type | Description |
Expand Down
4 changes: 2 additions & 2 deletions docs/scene-adapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ rebases them, for example on `ComputeBounds().Center`, before narrowing them to
`ifc:` keys and come after the occurrence sets in `PropertySetIds`, so a lookup by key finds the occurrence value
first.
- Property values are text even when the IFC value is a number or a boolean: IfcIO keeps only the text.
- Length, area, volume and weight quantities are text in file units. For a file whose length unit IfcIO converts to
metres while reading (for example centimetres), geometry is in metres but quantities stay in file units.
- Length quantities are text in the model's length unit, which may be metres for a file in a different length
unit (for example centimetres). Area, volume and weight quantities retain the file's values.
- An element without a GlobalId in the file gets a new random GlobalId from IfcIO each time it is read, so its
`SourceId` is not stable.
- Transparency is not read from files by IfcIO; materials built in memory keep their alpha.
Expand Down
17 changes: 15 additions & 2 deletions src/IfcIO.Cli/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,8 @@ private static void PrintUsage()
--purge Remove empty/duplicate property sets, quantity sets, and empty storeys
--reset-coords Shift large UTM coordinates to local origin (0,0,0) to prevent jitter
--offset <x,y,z> Translate model geometry by given coordinate offset
--legacy-ifcio-radian-sweeps
Repair old IfcIO files that stored sweep angles in radians despite declaring degrees
--extract <query> Extract matching elements into a separate IFC model
-o, --output <path> Output file path for patched IFC model

Expand Down Expand Up @@ -229,9 +231,17 @@ private static int ExecuteInfo(string[] args)
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine(" Spatial Hierarchy (Storeys):");
Console.ResetColor();
string elevationUnit = model.LengthUnit switch
{
IfcLengthUnit.Millimetre => "mm",
IfcLengthUnit.Metre => "m",
IfcLengthUnit.Foot => "ft",
IfcLengthUnit.Inch => "in",
_ => "?",
};
foreach (var storey in model.Storeys)
{
Console.WriteLine($" - {storey.Name,-24} Elevation: {storey.Elevation,8:F2} mm | Elements: {storey.Elements.Count} | Spaces: {storey.Spaces.Count}");
Console.WriteLine($" - {storey.Name,-24} Elevation: {storey.Elevation,8:F2} {elevationUnit} | Elements: {storey.Elements.Count} | Spaces: {storey.Spaces.Count}");
}
}

Expand Down Expand Up @@ -723,7 +733,10 @@ private static int ExecutePatch(string[] args)
}

var sw = Stopwatch.StartNew();
var model = IfcModel.Open(inputPath);
var model = IfcModel.Open(inputPath, new IfcReadOptions
{
LegacyIfcIoRevolvedAnglesInRadians = args.Contains("--legacy-ifcio-radian-sweeps", StringComparer.OrdinalIgnoreCase),
});

if (!string.IsNullOrEmpty(extractQuery))
{
Expand Down
2 changes: 1 addition & 1 deletion src/IfcIO.Scene/IfcSceneReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ private static bool IsNotProduct(string ifcType) =>
private static SceneDiagnostic Issue(SceneSeverity severity, string code, string reason, IfcElement element) =>
new(severity, code, $"{reason}; element #{element.Id} '{element.Name}' ({element.IfcType}) has no geometry in the scene.", element.GlobalId);

// Quantities are doubles in IfcIO, in the file's units (not always IfcModel.LengthUnit), which IfcIO does not report.
// Length quantities use the model's length unit; the other quantities retain their file values.
// A number with a null Unit means dimensionless, so only a count is a number; every other quantity is text.
private static SceneValue QuantityValue(IfcPhysicalQuantity quantity)
{
Expand Down
1 change: 1 addition & 0 deletions src/IfcIO/Geometry/SweptSolidTypes.cs
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,7 @@ public sealed class IfcRevolvedAreaSolid
public IfcProfileDef Profile { get; set; }
public IfcVector3 Position { get; set; } = IfcVector3.Zero;
public IfcAxis1Placement Axis { get; set; } = new();
/// <summary>Sweep angle in radians, regardless of the model's IFC plane angle unit.</summary>
public double Angle { get; set; } = 2.0 * Math.PI;

public IfcRevolvedAreaSolid(IfcProfileDef profile, double angle = 2.0 * Math.PI, IfcVector3? position = null, IfcAxis1Placement? axis = null)
Expand Down
Loading