Revit API Forum
Welcome to Autodesk’s Revit API Forums. Share your knowledge, ask questions, and explore popular Revit API topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

When managed wrapper can be existing while its native object already is destroye

1 REPLY 1
SOLVED
Reply
Message 1 of 2
Anonymous
272 Views, 1 Reply

When managed wrapper can be existing while its native object already is destroye

Revit 2017.1 SDK, RevitAPI.chm file:

 

> FilteredElementCollector.IsValidObject Property

>

> If the corresponding Revit native object is destroyed, or creation of the corresponding object is undone, a managed API object containing it is no longer valid. API methods cannot be called on invalidated wrapper objects.

 

When the managed wrapper can be existing while its native object already is destroyed or creation of the corresponding native object is undone?

Tags (1)
1 REPLY 1
Message 2 of 2
jeremytammik
in reply to: Anonymous

Dear Andrey,

 

In the real world, this method is never used, as far as I know.

 

I think you can safely ignore it.

 

Just follow the best practices.

 

In this case, that means: 

 

  • Instantiate the filtered element collector.
  • Add the required filters to it, as many and specific as possible, and as many quick filters as possible.
  • Collect and potentially process the results.

 

If the processing is complex, I would store the results first and discard the filtered element collector before proceeding any further.

 

Always discard all objects as quickly as possible, to isolate individual steps from each other as much as possible:

 

http://thebuildingcoder.typepad.com/blog/2017/01/distances-switches-kiss-ing-and-a-dino.html#4

 

Cheers,

 

Jeremy

 

 



Jeremy Tammik
Developer Technical Services
Autodesk Developer Network, ADN Open
The Building Coder

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Rail Community