Sorry for late reply, busy past days on other topics.
Yes, would be great to know which plugin is doing this fast, maybe can give clues, you can email me at alexis@idigo.com.sg.
Re: caching, my code is not clean/independent enough to be shared, but the concept is simple:
- I have 2 levels of primitives cache: memory and file
- I have a class (named Tesselation for historical reasons) that store the equivalent as native C# types, aka list of fragments with points, snap-points (and should also contains lines and points to be a full equivalent but I do not need these for now) and able to be saved/load from a file
- I have 1 method that build a file path from a model item (document folder / model file path '.peekee / item path '.prm'
When I need an object primitive I look in my in-memory cache (a dictionary) for a Tesselation for this object. If I have I use it. If not I look for a saved Tesselation file, load it and add it to my in-memory cache. If not, I extract the primitives using the standard method you use, store them in my Tesselation object, save this Tesselation data to file and add it to the dictionary, then I use it 😉
I'm planning to replace individual files in the future by some kind of simple hard coded database to avoid multiple file access and bloating the hard disk.
Saving to disk in the same folder as the original Navisworks document allows this cached info to be persistent, which make a big difference in user experience in my plugin due to the specific use case where user add items for later processing.
Of course, all this complexity and disk access would probably be useless if we can extract the primitives efficiently.