问题
Modifying is forbidden because the document has no open transaction. The document has no open transaction. In Revit Document.
回答1:
You have 2 options:
change the TransactionMode to Automatic at the class attribute
[Transaction(TransactionMode.Automatic)]
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