Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
8f793f0
Improve Revit PDF parity across sheets and views
mahach666 Nov 23, 2026
55a08a9
Clip collected detail edges and handle optional print fixtures
mahach666 Nov 23, 2026
7154b54
Address PDF printing review findings
mahach666 Nov 23, 2026
4a34e71
Keep hidden openings in the wall and check viewport images
mahach666 Nov 23, 2026
761a351
Add tests for the print readers, PNG decoder and fill patterns
mahach666 Nov 23, 2026
b6b745a
Test rail and shaft placement and the plan symbol readers
mahach666 Nov 23, 2026
af839c1
Check the depth offset of a view-facing line pair
mahach666 Nov 23, 2026
860eaf4
Cover hidden-by-id opening tags and fix viewport image error notes
mahach666 Nov 23, 2026
c2d0607
Test the plan fixture readers of the GRep parser
mahach666 Nov 23, 2026
5b93093
Pin every term of the rail placement matrix in the tube test
mahach666 Nov 23, 2026
51155d6
Pin the Paeth tie order and two view-facing line boundaries
mahach666 Nov 23, 2026
5942f63
Fix nullable warnings in two print tests and a stray blank line
mahach666 Nov 23, 2026
0eb5fbc
Improve shading and visibility in Revit PDF sheets
mahach666 Nov 26, 2026
1ca4769
Print saved wall paint regions in elevations and sections
mahach666 Nov 26, 2026
f68cb9a
Align schedule rows and print terrain cut hatches
mahach666 Nov 26, 2026
432fa2e
Improve shaded solar-study printing
mahach666 Nov 26, 2026
5536460
print: shade slab sides through the section and skip group templates
mahach666 Nov 27, 2026
35eeb50
print: keep group template geometry in fine sections
mahach666 Nov 27, 2026
60d11e5
print: ink the inner loops of plan fitting faces
mahach666 Nov 27, 2026
b19c037
docs: record the raster score and where its residual comes from
mahach666 Nov 27, 2026
2ae5417
docs: attribute the A103 residual to the terrain cut cap and the rail…
mahach666 Nov 27, 2026
38f7f61
docs: name the occluders that drop the A103 guardrail bars
mahach666 Nov 27, 2026
8264088
docs: correct the A103 guardrail occluders to the railing assembly
mahach666 Nov 28, 2026
7cafd31
print: merge the echoed copies of a railing bar
mahach666 Nov 28, 2026
e2f3601
docs: contrast the A103 and A104 railing bars
mahach666 Nov 28, 2026
6dea02a
docs: record that the railing has no symbolic lines and the bars fall…
mahach666 Nov 28, 2026
bbb341d
docs: measure per-span railing clipping against every nearer face
mahach666 Nov 28, 2026
7df30c5
docs: point-in-B-rep test drops no railing spans
mahach666 Nov 28, 2026
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
275 changes: 274 additions & 1 deletion CHANGELOG.md

Large diffs are not rendered by default.

715 changes: 649 additions & 66 deletions docs/printing.md

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion docs/public-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ See [sheets and viewports](sheets.md) for what is decoded, what the limits are a
| `ElevationPrinter` | `Views(document)` lists the elevations and the building sections (North, South, East, West, Section, Stair Section) with their scale; `Collect(document, direction, stairsOnly, planeView)` projects the model faces on the plane of the view when the reader decoded it (a section is cut at that plane: the geometry in front of it is removed and the crossing polygons are clipped) or on the plane of the direction taken from the name; a stair section projects the stairs alone. `DrawContent` writes them. |
| `ElevationView` | An elevation view: id, name, direction (north, south, east, west, section, iso) and scale. |
| `SheetComposer` | `Sheets(document)` lists the numbered sheets with the page their title block spans; `Render(document, sheetId, options)` and `RenderSheets` compose pages: each placed viewport draws its plan at the stored offset and view scale, labelled with the view name and scale, and the sheet's own text notes are written. |
| `SheetComposeOptions` | `PaperSize` (null takes the title block extent, snapped to A4-A0), `DrawViewLabels`, `ViewMarginMillimetres`. |
| `SheetComposeOptions` | `PaperSize` (null takes the title block extent, snapped to A4-A0), `DrawViewLabels`, `DrawRoomLegend` (the room legend under a plan), `ViewMarginMillimetres`, `DrawPageFrame` (the page border and the sheet number and name at its lower right), `ViewportImages` (optional rendered images keyed by viewport element id). |
| `SheetViewportImage` | An `IPdfImage` and its bounds in millimetres from the sheet's lower left. The viewport must belong to a selected sheet. Coordinates and dimensions must be finite, and both dimensions must be positive. `SheetComposer.RenderSheets` throws `ArgumentException` for an entry that is not a viewport of the selected sheets, has no image, or breaks the bounds rules. |
| `ComposedSheet` | A composed sheet: id, number, name, page, placed viewport count, text count. |
| `SheetPrinter` | `Sheets(document)` lists the sheets with page-sized decoded linework; `Render(document, sheetId, options)` and `RenderSheets` print one page per sheet from the lines the sheet owns, on the paper the linework spans. |
| `SheetPrintOptions` | `PaperSize` (null uses the linework extent, snapped to A4-A0), `MarginMillimetres`, `PaperToleranceMillimetres`, `DrawSheetFields`. |
Expand Down
61 changes: 57 additions & 4 deletions src/RvtIO.Cli/PrintCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ internal static int Run(string[] args, TextWriter output, TextWriter error)
var viewTexts = new List<string>();
var sheetTexts = new List<string>();
var whereTexts = new List<string>();
var imageFiles = new Dictionary<int, (double X, double Y, double Width, double Height, string Path)>();
int scale = 100;
PdfPageSize? paper = null;
bool listLevels = false, listViews = false, listSheets = false, allViews = false, allSheets = false;
Expand Down Expand Up @@ -64,6 +65,16 @@ internal static int Run(string[] args, TextWriter output, TextWriter error)
if (i + 1 >= args.Length) return Usage(error, "--where needs a filter: NAME=VALUE, NAME!=VALUE or NAME~TEXT.");
whereTexts.Add(args[++i]);
break;
case "--viewport-image":
if (i + 6 >= args.Length
|| !int.TryParse(args[i + 1], NumberStyles.None, CultureInfo.InvariantCulture, out int viewportId)
|| viewportId <= 0 || !Coordinate(i + 2, out double x) || !Coordinate(i + 3, out double y)
|| !Coordinate(i + 4, out double width) || width <= 0
|| !Coordinate(i + 5, out double height) || height <= 0 || string.IsNullOrWhiteSpace(args[i + 6])
|| !imageFiles.TryAdd(viewportId, (x, y, width, height, args[i + 6])))
return Usage(error, "--viewport-image requires a unique viewport ID, X Y WIDTH HEIGHT in mm, and a JPEG path.");
i += 6;
break;
default:
if (arg.StartsWith("--where=", StringComparison.Ordinal))
{
Expand All @@ -77,6 +88,8 @@ internal static int Run(string[] args, TextWriter output, TextWriter error)
break;
}
}
bool Coordinate(int index, out double value) =>
double.TryParse(args[index], NumberStyles.Float, CultureInfo.InvariantCulture, out value) && double.IsFinite(value);
if (file == null) return Usage(error, "print requires the file.");
var whereFilters = new List<SheetFilter>();
foreach (string text in whereTexts)
Expand All @@ -88,6 +101,8 @@ internal static int Run(string[] args, TextWriter output, TextWriter error)
if (whereFilters.Count > 0 && sheetTexts.Count == 0 && !allSheets && !listSheets)
return Usage(error, "--where selects sheets; it needs --sheet, --all-sheets or --list-sheets.");
bool listing = listLevels || listViews || listSheets;
if (imageFiles.Count > 0 && (listing || (!allSheets && sheetTexts.Count == 0) || allViews))
return Usage(error, "--viewport-image requires --sheet or --all-sheets.");
if (!listing && outputPath == null) return Usage(error, "print requires the output PDF path.");
// The comparison is the file's identity, not the spelling of the paths: an output path that is a hard link,
// symbolic link or junction to the input PDF would truncate the model. ExportReport.SameFile guards the other
Expand All @@ -98,6 +113,38 @@ internal static int Run(string[] args, TextWriter output, TextWriter error)
return RvtExitCodes.Usage;
}

var composeOptions = new SheetComposeOptions { PaperSize = paper };
if (imageFiles.Count > 0)
{
var images = new Dictionary<int, SheetViewportImage>();
foreach (var (id, input) in imageFiles)
{
if (ExportReport.SameFile(outputPath!, input.Path))
return Usage(error, "The PDF output path is a viewport image input.");
try
{
using var stream = File.OpenRead(input.Path);
if (stream.Length is < 4 or > 64 * 1024 * 1024)
return Usage(error, $"Viewport image {id} must be a JPEG no larger than 64 MiB.");
var bytes = new byte[(int)stream.Length];
stream.ReadExactly(bytes);
// The header is read here so that a file that is not a JPEG is reported by name, without the
// parameter name of the constructor.
var (jpegWidth, jpegHeight, _) = PdfJpegImage.ReadHeader(bytes);
if (jpegWidth <= 0 || jpegHeight <= 0)
return Usage(error, $"Viewport image {id} ({input.Path}) is not a JPEG.");
images.Add(id, new SheetViewportImage(new PdfJpegImage(bytes),
input.X, input.Y, input.Width, input.Height));
}
catch (Exception exception) when (exception is IOException or UnauthorizedAccessException)
{
error.WriteLine($"Cannot read viewport image {input.Path}: {exception.Message}");
return RvtExitCodes.InputError;
}
}
composeOptions.ViewportImages = images;
}

RvtDocument document;
try
{
Expand Down Expand Up @@ -204,8 +251,10 @@ IReadOnlyList<ComposedSheet> ListedComposed() =>
error.WriteLine("No numbered sheet was found; nothing to compose.");
return RvtExitCodes.DecodeError;
}
pdf = SheetComposer.RenderSheets(document, toCompose.Select(sheet => sheet.SheetId).ToList(),
new SheetComposeOptions { PaperSize = paper });
var composeIds = toCompose.Select(sheet => sheet.SheetId).ToList();
if (SheetComposer.ViewportImageProblem(document, composeIds, composeOptions.ViewportImages) is { } problem)
return Usage(error, problem);
pdf = SheetComposer.RenderSheets(document, composeIds, composeOptions);
}
else if (allViews)
{
Expand Down Expand Up @@ -239,8 +288,12 @@ IReadOnlyList<ComposedSheet> ListedComposed() =>
}
var sheetIds = selection.SheetIds;
var composedIds = selection.ComposedIds;
if (composeOptions.ViewportImages != null && sheetIds.Count > 0)
return Usage(error, "Viewport images require sheets with decoded viewports.");
if (SheetComposer.ViewportImageProblem(document, composedIds, composeOptions.ViewportImages) is { } imageProblem)
return Usage(error, imageProblem);
pdf = sheetIds.Count == 0
? SheetComposer.RenderSheets(document, composedIds, new SheetComposeOptions { PaperSize = paper })
? SheetComposer.RenderSheets(document, composedIds, composeOptions)
: SheetPrinter.RenderSheets(document, sheetIds, new SheetPrintOptions { PaperSize = paper });
}
else if (viewTexts.Count > 0)
Expand Down Expand Up @@ -412,7 +465,7 @@ private static int Usage(TextWriter error, string problem)
error.WriteLine(problem);
error.WriteLine("Usage: rvtio print <file.rvt> <out.pdf> [--level <id|name>] [--view <id|name>] [--sheet <id|number>] "
+ "[--where FILTER] [--all-views] [--all-sheets] [--scale <n>] [--paper A4|A3|A2|A1|A0] "
+ "[--list-levels] [--list-views] [--list-sheets]");
+ "[--viewport-image ID X Y WIDTH HEIGHT JPEG] [--list-levels] [--list-views] [--list-sheets]");
return RvtExitCodes.Usage;
}
}
1 change: 1 addition & 0 deletions src/RvtIO.Cli/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ Report options (read the file and print or write a report instead of exporting):
write the sheet catalog (sheets, viewports, parameters, limits not decoded) as JSON
print <file.rvt> <out.pdf> [--level <id|name>] [--view <id|name>] [--sheet <id|number>] [--where FILTER] [--scale <n>]
[--all-views] [--all-sheets] [--paper A4|A3|A2|A1|A0]
[--viewport-image ID X Y WIDTH HEIGHT JPEG]
[--list-levels] [--list-views] [--list-sheets]
render the plan of one level, one or more views (plans and elevations) or all of
them, or one or more sheets, to PDF
Expand Down
26 changes: 26 additions & 0 deletions src/RvtIO/Internal/GRepData.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
namespace RvtIO.Internal;

internal sealed record DoorPlanSymbol((double Lo, double Hi)? CutRange,
IReadOnlyList<RvtIO.Parsing.GRepParserV2.ArcRec> Curves);

internal sealed record StyledModelLine(double[] Start, double[] End, int StyleId);
internal sealed record PlanFixtureGraphics(List<StyledModelLine> Lines, List<List<double[]>> Masks,
PlanFixtureProjection? MediumProjection = null, PlanFixtureProjection? CoarseProjection = null);

internal sealed record PlanFixtureProjection(List<StyledModelLine> Lines, List<List<double[]>> Masks);

internal record GRepData
{
public int GStyleElemId { get; set; }
Expand Down Expand Up @@ -65,6 +74,10 @@ internal record GRepData
/// symbols contain many independent mapped children; retaining only one loses solids.</summary>
public List<GRepInstance> Instances { get; set; } = new();

/// <summary>Authored projection strokes with view filters, in the representation's own frame.</summary>
public List<ViewFacingLine>? ViewFacingLines { get; set; }
public IReadOnlyList<DoorPlanSymbol>? DoorPlanSymbols { get; set; }

/// <summary>For a FamilySymbol complex cutter, the authored dummy-host closure plane
/// in family-local coordinates. Replacing the symmetric dummy-host slab delimited by
/// this plane with the real host slab preserves every authored reveal/protrusion.</summary>
Expand Down Expand Up @@ -108,10 +121,22 @@ internal record GRepInstance
public long NodeOrder { get; set; }
}

internal sealed record ModelFacePattern(int PatternId, double[] Origin, double[] U, double[] V);

internal sealed record ViewFacingLine(double[] Start, double[] End, double[] Axis, int StyleId,
(int Comparison, int Level)? DetailCondition = null);

internal sealed record SurfaceMaterialRegion(int MaterialId, List<double[]> Outer, List<List<double[]>> Holes);

internal record GRepFace
{
public List<SurfaceMaterialRegion>? SurfaceRegions { get; set; }

public bool ExcludedFromTopPlan { get; init; }

/// <summary>GFace.m_renderStyleId: the material element of the face; absent when not read.</summary>
public int? RenderStyleId { get; init; }
public ModelFacePattern? ModelPattern { get; init; }

public double[] Envelope { get; set; } = Array.Empty<double>();
public bool Orient { get; set; }
Expand Down Expand Up @@ -160,6 +185,7 @@ internal record GRepFace

/// <summary>True for a tessellated patch of a non-planar surface (cylinder, cone, revolution, ruled, Hermite).</summary>
public bool CurvedSurface { get; init; }
public bool PolygonMesh { get; init; }

/// <summary>The face lies on a plane surface of the file (GSurface class Plane). When every face of a closed shell lies
/// on a plane, all its edges are straight lines and the shell is a polyhedron whose volume is exact.
Expand Down
16 changes: 13 additions & 3 deletions src/RvtIO/Internal/ParsingState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ public Ifc.IfcNumericUnitPlan? OwnDocumentIfcNumericUnitPlan
public Dictionary<uint, Dictionary<int, int>> ElemBipInts { get; set; } = new();
public Dictionary<uint, BaseElementFields> ElemBaseFields { get; set; } = new();
public Dictionary<uint, GRepData> GrepBlocks { get; set; } = new();
public Dictionary<uint, PlanFixtureGraphics> PlanFixtureGraphicsBySymbol { get; } = new();
internal Dictionary<uint, (int BlockCount, TfBlockDeserializer.OwnRailingQuantityInput? Input)> RailingQuantityInputs { get; } = new();

/// <summary>While set, the symbols placed from <see cref="GrepBlocks"/> are taken at the Coarse detail level.</summary>
Expand Down Expand Up @@ -281,7 +282,12 @@ public Ifc.IfcNumericUnitPlan? OwnDocumentIfcNumericUnitPlan

/// <summary>Material element id -> the cut and surface fill pattern ids of its Material record (-1 when the
/// material has no pattern of that kind), for the blocks that decoded exactly once.</summary>
public Dictionary<uint, (int BlockCount, int CutPatternId, int SurfacePatternId)> MaterialPatterns { get; } = new();
public Dictionary<uint, (int BlockCount, int CutPatternId, int SurfacePatternId, int? SurfacePatternColor, int? CutPatternColor)> MaterialPatterns { get; } = new();

public (double BaseFeet, int MaterialId)? SiteCutGraphics { get; set; }
public int SiteCutGraphicsCount { get; set; }
public (int Method, int Units)? PropertyBearingFormat { get; set; }
public int PropertyBearingFormatCount { get; set; }

/// <summary>GStyleElem (class 2050) -> GStyle.m_materialElemId and the style's category; MaterialId is null when the
/// block did not decode. A repeated block clears it.</summary>
Expand Down Expand Up @@ -342,7 +348,7 @@ public Ifc.IfcNumericUnitPlan? OwnDocumentIfcNumericUnitPlan

/// <summary>Own wall-root (SWall/ArcWall) top-attachment source: every root counts;
/// an unreadable root records null. Duplicates clear the value.</summary>
public Dictionary<uint, (int BlockCount, bool? JoinedToTop)> WallJoinedToTop { get; } = new();
public Dictionary<uint, (int BlockCount, bool? JoinedToTop, int[]? Targets)> WallJoinedToTop { get; } = new();

/// <summary>Control joins of each wall's own driver
/// (<see cref="Parsing.TfBlockDeserializer.ExtractWallEndJoins"/>); null when the block is
Expand Down Expand Up @@ -428,6 +434,7 @@ public Ifc.IfcNumericUnitPlan? OwnDocumentIfcNumericUnitPlan

/// <summary>GeoSite (class 2071) latitude and longitude in radians by element id; the last block wins.</summary>
internal Dictionary<uint, (double Latitude, double Longitude)> GeoSites { get; } = new();
internal Dictionary<uint, double> GeoSiteTimeZones { get; } = new();

/// <summary>GeoSite (class 2071) m_placeName by element id; the last block wins.</summary>
internal Dictionary<uint, string> GeoSitePlaceNames { get; } = new();
Expand All @@ -452,6 +459,9 @@ public Ifc.IfcNumericUnitPlan? OwnDocumentIfcNumericUnitPlan
/// Null when the block did not decode; a repeated block clears it.</summary>
public Dictionary<uint, (int BlockCount, Parsing.TfBlockDeserializer.LevelDatum? Datum)> LevelDatums { get; } = new();

public Dictionary<int, (int BlockCount, Parsing.TfBlockDeserializer.ViewDatumExtents Extents)> DatumExtents { get; } = new();
public Dictionary<int, Parsing.TfBlockDeserializer.DatumHead?> DatumHeads { get; } = new();

/// <summary>GridAttributes block (class 2109) -> the center-segment category id whose projection
/// graphics style inks the grid's center line. Null when the block did not decode; a repeated
/// block clears it.</summary>
Expand All @@ -470,7 +480,7 @@ public Ifc.IfcNumericUnitPlan? OwnDocumentIfcNumericUnitPlan

/// <summary>Curve line style + length from the full CurveElem schema walk (handles
/// detail arcs the GInfoBlob pattern scan can't reach).</summary>
public Dictionary<uint, (int GStyle, double Length)> CurveGeometry { get; set; } = new();
public Dictionary<uint, (int GStyle, double Length, (double X, double Y, double Radius)? Circle)> CurveGeometry { get; set; } = new();

/// <summary>Native parameter stores per element, deserialized from the Element base
/// class m_pParamValueSet* containers (schema-driven).</summary>
Expand Down
Loading
Loading