The custom attribute Autodesk.Revit.Attributes.RegenerationAttribute should be applied to your implementation class of the IExternalCommand interface and IExternalApplication interface to control the regeneration behavior for the external command and external application. There is no default for this option. You must apply it to legacy application classes to allow your application to function in Revit 2011.
This mode controls whether or not the API framework automatically regenerates after every model modification. There are two supported values:
- RegenerationOption.Automatic – The API framework will regenerate after every model level change (equivalent behavior with Revit 2010 and earlier). Regeneration and update can be suspended using SuspendUpdating for some operations, but in general the performance of multiple modifications within the same file will be slower than RegenerationOption.Manual. This mode is provided for behavioral equivalence with Revit 2010 and earlier; it is obsolete and will be removed in a future release.
- RegenerationOption.Manual – The API framework will not regenerate after every model level change. Instead, you may use the regeneration APIs to force update of the document after a group of changes. SuspendUpdating blocks are unnecessary and should not be used. Performance of multiple modifications of the Revit document should be faster than RegenerationOption.Automatic. Because this mode suspends all updates to the document, your application should not read data from the document after it has been modified until the document has been regenerated, or it runs the risk of accessing stale data. This mode will be only option in a future release.
For example, to set an external command to use manual regeneration mode:
[Regeneration(RegenerationOption.Manual)]
[Transaction(TransactionMode.Automatic)]
public class Command : IExternalCommand
{
public Autodesk.Revit.IExternalCommand.Result Execute(Autodesk.Revit.ExternalCommandData commandData,
ref string message,
Autodesk.Revit.ElementSet elements)
{
// Command implementation, which modifies the document and calls regeneration APIs when
// needed.
}
}
To set an external application to use automatic mode
[Regeneration(RegenerationOption.Automatic)]
public class Application : IExternalApplication
{
public Autodesk.Revit.UI.Result OnStartup(ControlledApplication application)
{
// OnStartup implementation
}
public Autodesk.Revit.UI.Result OnShutdown(ControlledApplication application)
{
// OnShutdown implementation
}
}
The regeneration mode used for code executed during events and updater callbacks will be the same mode applied to the ExternalApplication or ExternalCommand during which the event or updater was registered.
Comments
Leave a comment