Modifying is forbidden because the document has no open transaction. The document has no open transaction. In Revit Document.
Asked
Active
Viewed 2,127 times
3 Answers
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()

Daren Thomas
- 67,947
- 40
- 154
- 200
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();

Augusto Goncalves
- 8,493
- 2
- 17
- 44
-
Remember to always put transactions in a using block, as demonstrated here: https://boostyourbim.wordpress.com/2012/12/04/use-a-using-block-with-transactions/ & http://thebuildingcoder.typepad.com/blog/2012/04/scope-and-dispose-transactions.html – Colin Stark Jul 15 '15 at 18:28
-1
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