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

fix(Navisworks): CNX-895 - Add ColorProxy Support for 2D Linework #492

Merged
merged 6 commits into from
Jan 14, 2025

Conversation

jsdbroughton
Copy link
Contributor

@jsdbroughton jsdbroughton commented Jan 13, 2025

Currently, all geometry in the Navisworks connector uses RenderMaterialProxies for colour representation. This causes 2D linework to appear uncoloured as it requires ColorProxies instead. This PR adds proper ColorProxy support for 2D elements while maintaining RenderMaterialProxy handling for 3D geometry.

Changes

  • Add new ColorProxy handling for 2D linework

  • New simplistic ComApI.InwSimplePrimitivesCB callback for primitive type detection

  • Implement proxy type detection based on geometry type

  • Update root object builder to support both proxy types

  • Additionally, refactors BuildAsync to reduce complexity and clear method steps

Source

image

Before

Screenshot 2025-01-13 233327

After

Screenshot 2025-01-13 233144

Copy link

linear bot commented Jan 13, 2025

Copy link

codecov bot commented Jan 13, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 9.16%. Comparing base (9d70579) to head (b54058f).
Report is 1 commits behind head on dev.

Additional details and impacted files
@@          Coverage Diff          @@
##             dev    #492   +/-   ##
=====================================
  Coverage   9.16%   9.16%           
=====================================
  Files        228     228           
  Lines       4299    4299           
  Branches     542     542           
=====================================
  Hits         394     394           
  Misses      3889    3889           
  Partials      16      16           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

This commit adds a new file, ColorConverter.cs, to the Helpers folder in the NavisworksShared project. The ColorConverter class provides methods for converting Navisworks colors to System.Drawing.Color, generating color hash strings, and getting human-readable color names.
The code changes in this commit refactor the NavisworksMaterialUnpacker.cs file to improve the color conversion process. Specifically, the ColorConverter class is now used to convert Navisworks colors to standard colors. This change enhances the accuracy and reliability of color conversions throughout the codebase.
The commit adds the `NavisworksColorUnpacker` class to improve the logic for unpacking colours from Navisworks objects. It introduces a new method `UnpackColor` that takes in a list of Navisworks objects and a dictionary of grouped nodes. The method iterates over the objects, skips non-2D elements, and extracts colour information based on the selected representation mode.

The commit also introduces a helper method `Is2DElement` that checks if a given model item is a 2D element by examining its geometry using the ComApi.

Additionally, a new class `PrimitiveChecker` is added to implement the callback interface for checking primitive types in Navisworks geometry.

These changes aim to enhance the accuracy and efficiency of color unpacking for Navisworks objects.
Add NavisworksColorUnpacker to service registration

This commit adds the NavisworksColorUnpacker class to the service registration in the NavisworksConnectorServiceRegistration.cs file. Additionally, it includes the necessary changes in the NavisworksRootObjectBuilder.cs file to inject the NavisworksColorUnpacker dependency.
- Validate input parameters before processing
- Initialize root collection with name and units
- Convert all model items and store results
- Validate conversion results to ensure successful conversion
- Build final elements by grouping sibling geometry nodes and adding remaining non-grouped nodes
- Add proxies (render materials and colors) to the root collection if applicable
@jsdbroughton jsdbroughton marked this pull request as ready for review January 13, 2025 23:38
@jsdbroughton jsdbroughton enabled auto-merge (squash) January 13, 2025 23:38
Copy link
Member

@oguzhankoral oguzhankoral left a comment

Choose a reason for hiding this comment

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

Lgtm ❤️

@jsdbroughton jsdbroughton merged commit 2a508e6 into dev Jan 14, 2025
5 checks passed
@jsdbroughton jsdbroughton deleted the jonathon/cnx-895-2d-linework-uncoloured branch January 14, 2025 06:54
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.

2 participants