Document.Regenerate
Method
Description:
Updates the elements in the Revit document to reflect all changes.
Updates the elements in the Revit document to reflect all changes.
Remarks:
Use this method to force update to the document after a group of changes. Note that when a transaction is committed there is an automatic call to regenerate the document.
Use this method to force update to the document after a group of changes. Note that when a transaction is committed there is an automatic call to regenerate the document.
Examples
FamilyInstance instance = doc.Create.NewFamilyInstance(new XYZ(15, 20, 0), familySymbol, StructuralType.NonStructural);
FamilyInstance instance2 = doc.Create.NewFamilyInstance(new XYZ(25, 30, 0), familySymbol, StructuralType.NonStructural);
// faster to create multiple instances without calling Regenerate after each one
LocationPoint point = instance.Location as LocationPoint;
// this data is incorrect because the new geometry has not yet been regenerated
doc.Regenerate();
point = instance.Location as LocationPoint;
// now it is correct
Exceptions
Exception | Condition |
---|---|
RegenerationFailedException | Thrown when the operation fails.If regeneration fails, there is posted error of severity DocumentCorruption that will be delivered to the end user at the end of transaction explaining what specifically has happened.If regeneration has failed, document is corrupted and even reading from it is illegal.Code that called regeneration and got this exception should not catch and ignore it - instead, it should do nothing but internal cleanup and return control to the owner of currently active transaction/subtransaction, which must be aborted. |
InvalidOperationException | Modification of the document is forbidden. Typically, this is because there is no open transaction; consult documentation for Document.IsModified for other possible causes. |