Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix: ToSTEP call added #1059

19 changes: 13 additions & 6 deletions Elements.Serialization.IFC/src/IFCModelExtensions.cs
jamesbradleym marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -182,18 +182,25 @@ public static void ToIFC(this Model model,
/// </summary>
/// <param name="model">The model to convert to an IFC document.</param>
/// <param name="stream">The stream in which to write the IFC document.</param>
/// <param name="path">The path to the generated IFC STEP file.</param>
/// <param name="updateElementsRepresentation">Indicates whether UpdateRepresentation should be called for all elements.</param>

/// <param name="leaveOpen">Indicates whether the underlying stream should be left open.</param>
/// <remarks>
/// This method provides two options for stream handling:
/// 1. When the stream is left open for further access (using leaveOpen: true with StreamWriter).
/// Users must ensure proper resource management and close the StreamWriter when done.
/// 2. When the StreamWriter is closed (default - using leaveOpen: false with StreamWriter), ensuring proper resource cleanup.
/// Users can reopen the stream if further access is needed (use stream.Seek(0, SeekOrigin.Begin) to reset the position).
/// </remarks>
public static void ToIFC(this Model model,
MemoryStream stream,
bool updateElementsRepresentation = true)
bool updateElementsRepresentation = true,
bool leaveOpen = false)
{
var ifc = CreateIfcDocument(model, updateElementsRepresentation);
using (var writer = new StreamWriter(stream))
using (var writer = new StreamWriter(stream, leaveOpen: leaveOpen))
{
writer.Write(ifc);
writer.Write(ifc.ToSTEP());
}
}
}
}
}
Loading