transaction
Revit transactions facility.
Attributes
mlogger = get_logger(__name__)
module-attribute
DEFAULT_TRANSACTION_NAME = 'pyRevit Transaction'
module-attribute
Classes
Transaction(name=None, doc=None, clear_after_rollback=False, show_error_dialog=False, swallow_errors=False, log_errors=True, nested=False)
Adds a context manager around Revit Transaction object.
Runs Transaction.Start()
and Transaction.Commit()
before and after the context.
Automatically rolls back if exception is raised.
```python with Transaction('Move Wall'): wall.DoSomething()
with Transaction('Move Wall') as action:
wall.DoSomething()
assert action.status == ActionStatus.Started # True
assert action.status == ActionStatus.Committed # True
```
Source code in pyrevitlib/pyrevit/revit/db/transaction.py
Attributes
name
property
writable
status
property
Functions
has_started()
DryTransaction(name=None, doc=None, clear_after_rollback=False, show_error_dialog=False, swallow_errors=False, log_errors=True, nested=False)
Bases: Transaction
Wrapper to a transaction that doesn't commit anything (dry-run).
Source code in pyrevitlib/pyrevit/revit/db/transaction.py
Attributes
name
property
writable
status
property
Functions
has_started()
TransactionGroup(name=None, doc=None, assimilate=True, log_errors=True)
Transactions group with context manager.
Source code in pyrevitlib/pyrevit/revit/db/transaction.py
Attributes
assimilate = assimilate
instance-attribute
name
property
writable
status
property
Functions
has_started()
Functions
carryout(name, doc=None)
Transaction Decorator.
Decorate any function with @doc.carryout('Txn name')
and the funciton will run within an Transaction context.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
name |
str
|
Name of the Transaction |
required |
doc |
Document
|
Revit document |
None
|
@doc.carryout('Do Something')
def set_some_parameter(wall, value):
wall.parameters['Comments'].value = value
set_some_parameter(wall, value)