When to use doc.regenerate?

When to use doc.regenerate?

Anonymous
Not applicable
3,977 Views
2 Replies
Message 1 of 3

When to use doc.regenerate?

Anonymous
Not applicable

Hi,

 

I am starting to write an add-in in Revit that will deal with the creation of thousands of family instances, addition of parameters and its values on the fly. I have most of the bits of code required for the task, but I really  I have no clue on when to use doc.regenerate or not (the lesser the better for best performance and I understand that I may have to organize my add-in in order to minimize the number of calls). 

 

I have browsed through the Intenret, including Jeremy's blog notes on the topic, but it still seems to me that it is some kind of trial and error operation.

 

Are there any guidelines/recommendations/documentation on the type of Revit database update operations that require the use of doc.regenerate inside a transaction?

 

Regards,

 

Juan

0 Likes
Accepted solutions (1)
3,978 Views
2 Replies
Replies (2)
Message 2 of 3

jeremytammik
Autodesk
Autodesk
Accepted solution

Thank you for a very pertinent and interesting question.

 

Indeed, it may seem a bit like trial and error.

 

In general, however, it should probably be pretty clear.

 

Whenever a transaction is committed, Revit regenerates the document for you anyway, so you do not have to call it.

 

That will take care of many cases.

 

The only cases that require explicit regen are when you make several different modifications within one single transaction, and/or query the model after some of them have been make.

 

In that case, you may be retrieving stale data, outdated information that requires a regen to take the most recent modifications into account.

 

In general, I would probably not make any calls to Regenerate until I notice that something is going wrong.

 

Just keep in mind what can go wrong when stale data is accessed and used, always check your results, and be ready to add a regen call in case of need.

 

If you have read and understood all the examples listed in the topic group on the need to regenerate, it should be pretty clear and you should be well prepared to address your programming task, at least as far as this aspect is concerned:

 

https://thebuildingcoder.typepad.com/blog/about-the-author.html#5.33

 

Good luck!

 

Cheers,

 

Jeremy

 



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

Message 3 of 3

Anonymous
Not applicable

Thanks for the confirmation, Jeremy, It is more or less what expected. I have some experience on Autocad programming, where there was also a need to regenerate from time to time (but I was more or less aware about the rules of the game).

 

I will re-read your blog inputs on the topic before getting deeply on the add-in and I will test sequences of operations to check whether they require a Regenerate operation or not.

 

Regards,

 

Juan

0 Likes