ChrisClems / EdgeSharp

A library of helpers and extensions for the Solid Edge API. A spiritual successor to SolidEdge.Community build on modern .NET to make Solid Edge interop less frustrating.
MIT License
1 stars 0 forks source link

Create methods to delegate iteration of parts in assembly, optionally recursive #1

Closed ChrisClems closed 3 weeks ago

ChrisClems commented 3 months ago

https://github.com/ironfede/openmcdf/blob/a61b6b9a836865781c2588b9b6bf711f30137e17/sources/OpenMcdf/CFStorage.cs#L493

Add as Assembly extension method?

ChrisClems commented 1 month ago

Re-opening to assess need for TraverseAssemblyWithAction and TraverseOccurrencesWithAction. I suspect both are functionally identical with the former being more expensive. The former traverses the assembly by casting an Occurrence to a SolidEdgeDocument then to an AssemblyDocument when found. The latter walks the SubOccurrences of the Occurrences and SubOccurrences when they are SubAssemblies, getting Occurrences from SucOccurrences using SubOccurrences.ThisAsOccurrence to perform actions on.

When using SubOccurrence.ThisAsOccurrence you change the top-level assembly context in the same way that casting the SubAssembly Occurrence to an AssemblyDocument does. Performing the Action on the SolidEdgeDocument instead of the Occurrence is limiting as we can get the SolidEdgeDocument from the Occurrence but not the other way around. Is there any value in maintaining the (likely) more expensive original version when we can just traverse the SubOccurrences much faster?

ChrisClems commented 3 weeks ago

Replaced original method with a full occurrence tree walk from the top level without casting subassemblies to assemblies. Can revisit if edge case comes up where that works better.