ModelItem IsDisposed, how to avoid?

ModelItem IsDisposed, how to avoid?

alexisDVJML
Collaborator Collaborator
411 Views
2 Replies
Message 1 of 3

ModelItem IsDisposed, how to avoid?

alexisDVJML
Collaborator
Collaborator

In our plugin, we keep a list of specific ModelItems of interest (let's say up to a few thousands).
Once in a while, typically when memory is under stress, some of these objects end up being disposed by Navisworks even if we have references.

For now, for each of these items, we internally keep its ModelItem "path" into the document, then before using it, we check item.IsDisposed and if true, we use the path we saved to restore the item.

 

It works, but looks far from optimal:
- we keep a string for each item
- we have to check before using this item

Any suggestion/better option?
For example a way to force these items to NOT be disposed?

Thanks.

Main Scientist, Full Stack Developer & When Time Permits Director of IDIGO ► On your marks, Set, Go
0 Likes
412 Views
2 Replies
Replies (2)
Message 2 of 3

naveen.kumar.t
Autodesk Support
Autodesk Support

Hi @alexisDVJML ,

 

I had some discussions with senior Navisworks API Experts.

 

Could you elaborate with a demo code on what you are doing and what you expected? Regarding the general practice with preventing dispose, I think you would call copyTo / copyFrom, instead of using Reference as the reference would also be useless once native one is disposed.

 

Anyway, better add a demo code about the question.


Naveen Kumar T
Developer Technical Services
Autodesk Developer Network

Message 3 of 3

alexisDVJML
Collaborator
Collaborator

Hi Naveen,

 

Thanks for following up on this topic.
I will try to replicate this behaviour in a dedicated simplified test code.

In parallele, can you elaborate on the CopyTo/CopyFrom idea?
I can't find these methods inModelItem class or its NativeHandle base class.

Main Scientist, Full Stack Developer & When Time Permits Director of IDIGO ► On your marks, Set, Go
0 Likes