【发布时间】:2015-07-18 20:53:13
【问题描述】:
我想使用 C# 从 Revit 文档中删除遮罩区域。 错误:修改被禁止,因为文档没有打开的交易。 异常:ModificationOutsideTransactionException
【问题讨论】:
我想使用 C# 从 Revit 文档中删除遮罩区域。 错误:修改被禁止,因为文档没有打开的交易。 异常:ModificationOutsideTransactionException
【问题讨论】:
你有两个选择:
在类属性中将 TransactionMode 更改为 Automatic
[Transaction(TransactionMode.Automatic)]
在你的命令中打开一个事务
Transaction tr = new Transaction(commandData.Application.ActiveUIDocument.Document);
tr.Start("Command name here");
// your code
tr.Commit();
还发布了here。
【讨论】: