Skip to content

Adjusted Materials Logic#136

Merged
vnoves merged 1 commit intodevelopfrom
86b7dpjrc/SpecifiedItemCouldNotBeFound
Nov 11, 2025
Merged

Adjusted Materials Logic#136
vnoves merged 1 commit intodevelopfrom
86b7dpjrc/SpecifiedItemCouldNotBeFound

Conversation

@vnoves
Copy link
Member

@vnoves vnoves commented Nov 11, 2025

Summary by CodeRabbit

  • Refactoring
    • Material processing workflow refactored for improved reliability and efficiency
    • Added fallback mechanism to gracefully handle scenarios where materials cannot be retrieved
    • Enhanced material dictionary management to better reuse existing definitions and reduce redundant processing
    • Streamlined material export logic for improved performance

@coderabbitai
Copy link

coderabbitai bot commented Nov 11, 2025

Walkthrough

The material handling workflow in the glTF exporter is refactored. GlTFExportContext.OnMaterial now delegates material processing to RevitMaterials.ProcessMaterial(), replacing prior manual material search and creation logic. A new processing method is introduced that reuses or creates materials from a dictionary, with fallback handling for missing materials. A new Export() method overload is added to encapsulate material population logic for a given Revit Material.

Changes

Cohort / File(s) Summary
Material delegation refactoring
Common_glTF_Exporter/Core/GlTFExportContext.cs
Simplified OnMaterial to delegate material handling to RevitMaterials.ProcessMaterial(), removing prior manual search/create/upgrade logic.
Material processing workflow
Common_glTF_Exporter/Materials/RevitMaterials.cs
Added new ProcessMaterial() method that reuses/creates materials in a dictionary with fallback handling. Introduced new Export() overload encapsulating material population logic for a specific Material. Removed prior direct Export method signature.

Sequence Diagram

sequenceDiagram
    participant GlTFExportContext
    participant RevitMaterials
    participant MaterialsDict as Materials<br/>Dictionary

    GlTFExportContext->>RevitMaterials: ProcessMaterial(...)
    alt Material exists in Dictionary
        RevitMaterials->>MaterialsDict: Retrieve existing GLTFMaterial
        RevitMaterials->>RevitMaterials: Export(Material overload)
    else Material missing from Dictionary
        RevitMaterials->>RevitMaterials: Create default GLTFMaterial
        RevitMaterials->>MaterialsDict: Add new GLTFMaterial
    end
    Note over RevitMaterials: Fallback: if Revit Material<br/>cannot be retrieved,<br/>use default GLTFMaterial
    RevitMaterials-->>GlTFExportContext: Return GLTFMaterial
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Areas requiring attention:
    • Verify that the delegation from OnMaterial to ProcessMaterial() preserves all prior material filtering and export logic.
    • Confirm the new Export() overload correctly encapsulates the original material population workflow.
    • Test fallback handling when Revit Material retrieval fails to ensure UniqueId assignment works as expected.
    • Ensure the IndexedDictionary<GLTFMaterial> reuse pattern functions correctly across material processing cycles.

Possibly related PRs

  • Fix textures #102 — Directly modifies the same material-handling flow in both GlTFExportContext.OnMaterial and RevitMaterials export methods.
  • Fix missing textures #113 — Refactors material export paths, adding new processing/export methods and changing material resolution logic in the same context.
  • Added Log and Fix None Materials #118 — Updates material-handling code in GlTFExportContext.OnMaterial and RevitMaterials, affecting material reuse and null-material fallback patterns.

Poem

🐰 Materials now flow through channels neat,
Where ProcessMaterial makes the workflow sweet,
Reusing what exists, creating anew,
The rabbit approves—delegation's the crew! 🌿

Pre-merge checks and finishing touches

❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
Title check ❓ Inconclusive The title 'Adjusted Materials Logic' is vague and generic, using non-descriptive terms that don't clearly convey the specific nature of the refactoring or the main technical change. Consider using a more specific title that captures the key change, such as 'Refactor material handling to delegate to ProcessMaterial' or 'Extract material processing workflow into dedicated method'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch 86b7dpjrc/SpecifiedItemCouldNotBeFound

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🧹 Nitpick comments (1)
Common_glTF_Exporter/Materials/RevitMaterials.cs (1)

23-50: Good centralization of material processing logic.

The ProcessMaterial method successfully consolidates material lookup, creation, and dictionary management. The fallback handling for missing materials (lines 37-41) is a solid improvement that reuses a shared default material.

One suggestion: Consider adding a brief comment at line 40 explaining the materialId reassignment:

// Use default material's ID so all missing materials reference the same default
materialId = gl_mat.UniqueId;

This would clarify that the reassignment is intentional behavior for consolidating missing materials to a single default entry.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ebe4d19 and eb5fa24.

📒 Files selected for processing (2)
  • Common_glTF_Exporter/Core/GlTFExportContext.cs (1 hunks)
  • Common_glTF_Exporter/Materials/RevitMaterials.cs (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
Common_glTF_Exporter/Materials/RevitMaterials.cs (4)
Common_glTF_Exporter/Materials/MaterialTextures.cs (1)
  • GLTFMaterial (23-58)
Common_glTF_Exporter/Core/GLTFMaterial.cs (1)
  • GLTFMaterial (14-44)
Common_glTF_Exporter/Core/IndexedDictionary.cs (3)
  • IndexedDictionary (12-162)
  • Contains (118-121)
  • AddOrUpdateCurrentMaterial (92-111)
Common_glTF_Exporter/Utils/glTFExportUtils.cs (1)
  • GLTFExportUtils (12-220)
Common_glTF_Exporter/Core/GlTFExportContext.cs (2)
Common_glTF_Exporter/Utils/glTFExportUtils.cs (1)
  • GLTFExportUtils (12-220)
Common_glTF_Exporter/Materials/RevitMaterials.cs (1)
  • RevitMaterials (19-79)
🔇 Additional comments (3)
Common_glTF_Exporter/Core/GlTFExportContext.cs (1)

283-291: LGTM! Clean refactoring with improved error handling.

The delegation to RevitMaterials.ProcessMaterial() successfully centralizes material handling logic while preserving the existing filter guards. The new implementation adds better fallback handling for materials that have a valid MaterialId but cannot be retrieved from the document.

Common_glTF_Exporter/Materials/RevitMaterials.cs (2)

14-14: LGTM!

The addition of the Common_glTF_Exporter.Utils using directive is necessary for accessing GLTFExportUtils.GetGLTFMaterial() on line 39.


56-78: The review comment's premise about a breaking API change is incorrect.

There is no evidence of an old 3-parameter Export method. The codebase contains only a single Export method definition with 4 parameters (MaterialNode, Preferences, Document, Material), and the only caller already uses this signature correctly at line 44.

The null check observation is valid: at line 70, the material != null check is indeed redundant since the material parameter is guaranteed non-null (the call at line 44 occurs in the else branch of a null check guard). However, this is unrelated to any signature change.

The verification request to find dangling callers of an old signature is unnecessary—no old signature exists to find callers for.

Likely an incorrect or invalid review comment.

@vnoves vnoves merged commit 444ef9f into develop Nov 11, 2025
2 checks passed
@vnoves vnoves deleted the 86b7dpjrc/SpecifiedItemCouldNotBeFound branch November 26, 2025 14:20
@coderabbitai coderabbitai bot mentioned this pull request Nov 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant