-
Notifications
You must be signed in to change notification settings - Fork 7
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
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Codecov ReportAll modified and coverable lines are covered by tests ✅
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. |
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
oguzhankoral
approved these changes
Jan 14, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm ❤️
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 lineworkNew simplistic
ComApI.InwSimplePrimitivesCB
callback for primitive type detectionImplement 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 stepsSource
Before
After