I need help using temporary Transactions in Revit via Python. I can't seem to extract data from the transaction after the Rollback.
This is for a pyRevit add-in that will insert a specific family. I've tried using pyRevit's DryTransactions, SubTransactions, and GroupTransactions but none of them seem to be working for me.
fam_symbol = None
t = Transaction(doc, 'loadfamily')
t.Start()
success, fam_symbol = doc.LoadFamilySymbol.Overloads.Functions[1](fam_doc_path, fam_symbol_name)
doc.Regenerate()
fam_symbol = fam_symbol.Name
t.RollBack()
I would expect fam_symbol to now contain the family symbol but it doesn't. If I test it from within the Transaction it works, but after the rollback the information is gone.
Maybe your assignment of fam_symbol
creates a pointer to the string variable fam_symbol.Name
that disappears after the transaction has been rolled back, instead of making a copy of its value. Read the explanation about assigning another variable to a string make a copy or increase the reference count : Python never ever makes a copy unless specifically instructed to using eg copy
or deepcopy
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.