Cp327 1 Applied Dynamics Using Dynamic Model Update in The Revit API
Cp327 1 Applied Dynamics Using Dynamic Model Update in The Revit API
4
Frameworks for dynamic change
Transaction.Start()
model changes
Transaction
Transaction.Commit()
Dynamic Update – loop Starts
committing
Updater1.Execute()
Updater2.Execute()
Dynamic Update – loop Ends
Failure processing
Application.DocumentChanged
Application.Idling
Dynamic model update
Adding logic to regeneration
Dynamic Model Update
9
IUpdater interface
The interface
public interface class IUpdater
All methods except Execute() invoked {
only once at the time of registration, UpdaterId GetUpdaterId();
to get information about the updater:
void Execute(UpdaterData data);
Id
Name ChangePriority
GetChangePriority();
Additional info (used in user messages)
10
Registering updaters
Change
Scope
type
Trigger
Examples:
Two updaters change different parameters of wall – OK
Two updaters change height parameter – forbidden
Two updaters change the curve driver of a wall - forbidden
Even if one moves it in X, one moves it in Y
Missing updaters
Revit
Remembers updaters
Checks for remembered updaters
on document open
This is for protection of data
integrity of the document
21
Misbehaving updaters
22
Updater examples
23
Updater examples
24
Document Changed Event
What just happened?
The DocumentChanged event
28
Failure Processing
Posting and reacting to problems
Defining and posting failures
Three options
FailuresPreprocessor
Specific transaction
Suppress warnings or handle errors possibly raised by your transaction
FailureProcessing
Global event
See and react to warnings and errors before user does
FailureProcessor
Final handler for failures
Normally, Revit’s UI acts as the FailuresProcessor for the session
Implementing this interface will allow your application to handle all errors instead
(UI will not be used)
Idling Event
Let me make changes gradually…
Idling event