【问题标题】:Revit: Attempt to modify the model outside of transactionRevit:尝试在事务之外修改模型
【发布时间】:2021-11-02 05:04:10
【问题描述】:

当我创建默认钢筋类型时,我遇到了这个错误:“尝试在事务之外修改模型。”你能帮我解释一下吗?

【问题讨论】:

    标签: c# revit-api


    【解决方案1】:

    如果您尝试修改 Revit 模型数据库,则必须将代码包装到事务中:

    using (Transaction t = new Transaction(doc, "My transaction")) 
    { 
       t.Start() 
       // Your code 
       t.Commit() 
    }
    

    使用 try-catch 会更好。 如果您使用非模态表单,则必须在此基础上创建 ExternalEvent。 如果是这样,我只能推荐this excellent video。 祝你好运,

    弗朗索瓦

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-10-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多