Problem with Transaction in Inventor 2018 library's or cc's file
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm experiencing some problem working with Transaction in Inventor 2018 with library's or content center's file.
I attacched a simple addin to reproduce the problem.
I create a sample button that add a property in every document referenced by the main assembly.
The activity is wrapped by a transaction.
Assuming to work with an assembly with two parts: If one of the referenced docs is a library's or content center's component an exception was thrown (and that is sadly known) but this exception cause an unexpected corruption of my transaction that will throw an exception calling the End method on it.
It seems like this exception cause my transaction to be aborted, this would explain why if the first document is the cc file I find the property created properly and the action not named "Sample Transaction":
and I don't see anything if the first document is not the cc file:
If I'am not working with lib or cc file everything goes well:
Here some code's lines:
Trans = invAppl.TransactionManager.StartGlobalTransaction(oAsmDoc, "SampleTransaction") Try For Each oOcc As ComponentOccurrence In oAsmDoc.ComponentDefinition.Occurrences CreateProperty(oOcc.Definition.Document, "myProp", "myPropValue") Next Catch ex As Exception Trans.Abort() End Try Trans.End() Private Function CreateProperty(doc As Document, ByVal propName As String, ByVal propValue As Object) As Inventor.Property Dim prop As Inventor.Property = Nothing Dim pset As PropertySet Try ' Get user defined property set pset = doc.PropertySets.Item("{D5CDD505-2E9C-101B-9397-08002B2CF9AE}") prop = pset.Add(propValue, propName) Catch ex As Exception MsgBox(ex.ToString()) End Try Return prop End Function
Yes I could check if I have a lib or CC document but it's not as simple as it seems in this sample.