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

feat(Navisworks): CNX-1064 - Add hierarchy path property to converted Navisworks objects #500

Open
wants to merge 6 commits into
base: dev
Choose a base branch
from

Conversation

jsdbroughton
Copy link
Contributor

@jsdbroughton jsdbroughton commented Jan 16, 2025

This adds path information to converted Navisworks objects to provide better context about their location in the model hierarchy. Instead of returning a hierarchical data structure, each object in the list is flat but has hierarchical information in the path.

Closes CNX-1064 & CNX-1067

Key changes:

  • Added a path property to all converted objects, showing their hierarchical location in the model
  • Created DisplayPathHelper to generate standardized paths by traversing meaningful ancestors
  • Modified NavisworksRootObjectBuilder to handle path generation for both individual and grouped geometry objects
  • Added logic to find meaningful ancestor names for grouped geometry nodes
  • Ensured paths don't duplicate the object's name, which is already shown in the name property
  • Paths follow the format: "file.nwd > Assembly > Subassembly"

Example:

name: "Hood1A-1"
path: "snowmobile.nwd > Hood-2" 

This change improves object identification and filtering capabilities by providing a clear hierarchical context for each object in the converted model.

Manual Tests:

  • Source object in the selection tree
    image

  • As name and path as published
    image

This commit adds a new file, `DisplayPathHelper.cs`, which contains a helper class for generating display paths by traversing Navisworks model item ancestors. The `GenerateDisplayPath` method takes a `ModelItem` as input and returns a string representing the full path of display names from ancestors, stopping at the first object ancestor. If no first object ancestor is found, it returns just the model item's display name.

The helper class uses a constant `PATH_DELIMITER` to separate the display names in the generated path. It throws an exception if the input `modelItem` is null.

The algorithm works by starting from the first object ancestor and traversing backwards to the root, collecting non-empty display names along the way. Finally, it reverses the collected names and joins them with the delimiter to form the final display path string.

These changes improve code reusability and readability by encapsulating logic related to generating display paths in Navisworks models.
- Modified the CreateNavisworksObject method to handle cases where the convertedBase or groupKey is null and return null in those cases
- Added a new private method GetDisplayPath to retrieve the modelItem and displayPath based on the applicationId
- Updated the CreateNavisworksObject methods to include the displayNamePath property in the returned NavisworksObject
Copy link

linear bot commented Jan 16, 2025

…me method

This commit adds a new private method, FindMeaningfulAncestorName, to the NavisworksRootObjectBuilder class. This method is used to find the name of the most meaningful ancestor of a given NAV.ModelItem object. It iterates through the ancestors until it finds an ancestor with a non-empty DisplayName and no geometry. The found name is then used as the "name" property in the created NavisworksObject instances. Additionally, the "displayNamePath" property has been renamed to "path" for consistency.
- Update the helper class to generate display paths by traversing meaningful Navisworks model item ancestors.
- Skip nodes without meaningful names or geometry nodes when generating the display path.
- Reverse the collected names to build the path from root to leaf.
Copy link

codecov bot commented Jan 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 9.15%. Comparing base (db4d2f7) to head (8bc681e).

Additional details and impacted files
@@          Coverage Diff          @@
##             dev    #500   +/-   ##
=====================================
  Coverage   9.15%   9.15%           
=====================================
  Files        228     228           
  Lines       4306    4306           
  Branches     542     542           
=====================================
  Hits         394     394           
  Misses      3896    3896           
  Partials      16      16           

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

- Renamed the file from "DisplayPathHelper.cs" to "HierarchyHelper.cs"
- Updated all references to the renamed file

Refactor helper class for generating display paths
- Refactored the helper class to extract hierarchical context from Navisworks model items in a single traversal
- Changed the method name from "GenerateDisplayPath" to "ExtractContext"
- Modified the method signature to return a tuple of strings (Name, Path)
- Updated the implementation logic accordingly

Improve traversal and extraction logic
- Improved the traversal logic by collecting both name and path information while traversing up the tree once
- Extracted meaningful name and path information from model items in a more efficient way
- Handled cases where model item has no meaningful name or is a geometry node
- Extracted the GetContext method to retrieve the name and path of a model item
- Replaced calls to GetDisplayPath with calls to GetContext for consistency
- Updated CreateNavisworksObject and ConvertBase methods to use the extracted context information instead of finding meaningful ancestor names
- Updated the "path" property in the returned NavisworksObject instances with the extracted path
Copy link

linear bot commented Jan 16, 2025

@jsdbroughton jsdbroughton marked this pull request as ready for review January 16, 2025 01:22
@jsdbroughton jsdbroughton enabled auto-merge (squash) January 16, 2025 01:23
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