how to use StartTransactionForDocumentOpen()?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
hi,
Can someone tell me how to use this ?
TransactionManager.StartTransactionForDocumentOpen( DisplayName As String ) As Transaction
https://help.autodesk.com/view/INVNTOR/2023/ENU/?guid=GUID-54D83CD1-1AF4-4817-B156-14E8718FF0D3
the discription is not clear, and try it, give strange results.
Case 1 the .StartTransactionForDocumentOpen : this is to add a new transaction for the document that is open/active.
Case 2the .StartTransactionForDocumentOpen : this is to create a transaction, where you want to add or open a new document.
testresults :
1, open inventor, add an new part doc, create and run vba rule :
Public Sub trans()
MsgBox (ThisApplication.TransactionManager.CurrentTransaction.DisplayName & "-" & ThisApplication.TransactionManager.CurrentTransaction.Id)
End Sub
CurrentTransaction, is never nothing, there is always an transaction called "Unidentified transaction"
But, you cann't end this :
now we change the vba code to :
Public Sub trans()
MsgBox (ThisApplication.TransactionManager.CurrentTransaction.DisplayName & "-" & ThisApplication.TransactionManager.CurrentTransaction.Id)
Dim customtrans As Transaction
Set customtrans = ThisApplication.TransactionManager.StartTransactionForDocumentOpen("xxx")
MsgBox (ThisApplication.TransactionManager.CurrentTransaction.DisplayName & "-" & ThisApplication.TransactionManager.CurrentTransaction.Id)
customtrans.End
End Sub
The code runs to the end with no err; but you can see the code start an new transaction, but not use the string for displayname.
there is no action add on the undo button,...
so i gues this is not the way to use it, but there is no error and an new transaction that you can 'end'
-you can not be sure that you can use 'end' methode for 'current transaction', because they not use the string to give the new transaction an name. the name stays : 'Unidentified transaction'
test result case 2
change code to :
Public Sub trans()
MsgBox (ThisApplication.TransactionManager.CurrentTransaction.DisplayName & "-" & ThisApplication.TransactionManager.CurrentTransaction.Id)
Dim oDrawDoc As DrawingDocument
Dim customtrans As Transaction
Set customtrans = ThisApplication.TransactionManager.StartTransactionForDocumentOpen("xxx")
MsgBox (ThisApplication.TransactionManager.CurrentTransaction.DisplayName & "-" & ThisApplication.TransactionManager.CurrentTransaction.Id)
Set oDrawDoc = ThisApplication.Documents.Add(DocumentTypeEnum.kDrawingDocumentObject, ThisApplication.FileOptions.TemplatesPath & "Metric\ISO.idw", True)
customtrans.End
End Sub
and run,
you can see there is an new transaction id, and the transaction 'end- methode' can be finished
but :
where is the name/discription from the transaction in the undo?
you cann't find it.
so i gues i can not use 'StartTransactionForDocumentOpen-methode' for add the transaction to the undo list
the only way : 'StartTransaction'
Thanks to add some feedback.