Revit: Modifying is forbidden because the document has no open transaction

梦想的初衷 提交于 2019-12-25 08:48:10

问题


Modifying is forbidden because the document has no open transaction. The document has no open transaction. In Revit Document.


回答1:


You have 2 options:

  1. change the TransactionMode to Automatic at the class attribute

    [Transaction(TransactionMode.Automatic)]

  2. open a transaction within your command

    Transaction tr = new Transaction(commandData.Application.ActiveUIDocument.Document); tr.Start("Command name here");

    // your code

    tr.Commit();




回答2:


Since you tagged this as revitpythonshell:

try:
    transaction = Transaction(doc, 'a name for your transaction)
    transaction.Start()
    do_stuff_that_needs_to_modify_document()
    transaction.Commit()
except:
    transaction.Rollback()
    throw_hands_up_in_the_air_and_cry_in_frustration()



回答3:


close streamreader function

Dim TextLine As String = ""
    Dim fs As FileStream = New FileStream("baglanti.ini", FileMode.Open)
    Dim sr As StreamReader = New StreamReader(fs)
    baglanti_kodu = sr.ReadLine()
    fs.Close()
    sr.Close()  <---- they


来源:https://stackoverflow.com/questions/31428726/revit-modifying-is-forbidden-because-the-document-has-no-open-transaction

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!