Document does not appear to save
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Im using ObjectDBX to correct text in a document. The idea is that I open the document and iterate through the text and block text updating it along the way before saving.
When I open the document again nothing appears to have changed.
Private Function t() Dim aDBX As AxDbDocument Dim FileName As String FileName = "C:\doc\Desktop\ect\93.dwg" Set aDBX = AcadApplication.GetInterfaceObject("ObjectDBX.AxDbDocument." & Left$(ThisDrawing.GetVariable("AcadVer"), 2)) Call aDBX.Open(FileName) Call UpdateAttributePosistionNamedDocument(aDBX) Call aDBX.SaveAs(FileName) End Function
There are no errors opening or saving and the code just sails through.
But, because I cannot see what is occurring real-time, there is little point setting breakpoints and stepping through....
I cannot confirm at which step the problem is occurring.
Public Function UpdateAttributePosistionNamedDocument(oDocument As AxDbDocument) Dim objEntity As AcadEntity Dim objBlockRef As AcadBlockReference Dim objAttriRef As AcadAttributeReference Dim AttriList() As AcadAttributeReference Dim objAttributes As AcadAttributeReference Dim objTextEntity As AcadText Dim dBlocks As New Dictionary Dim i As Integer dBlocks.CompareMode = TextCompare For Each objEntity In oDocument.ModelSpace If (TypeOf objEntity Is AcadBlockReference) Then Set objBlockRef = objEntity If (Not dBlocks.Exists(objBlockRef.Name)) Then If objBlockRef.HasAttributes Then AttriList = objBlockRef.GetAttributes For i = LBound(AttriList) To UBound(AttriList) Set objAttributes = AttriList(i) objAttributes.Update objBlockRef.Update Next End If End If End If If (TypeOf objEntity Is AcadText) Then Set objTextEntity = objEntity objTextEntity.Update End If Next End Function
I am fairly sure the UpdateAttributePosistionNamedDocument function works as I have a variant of this:
Public Function UpdateAttributePosistion()
in which the line
For Each objEntity In oDocument.ModelSpace
is renamed to
For Each objEntity In ThisDrawing.ModelSpace
I open a drawing and run this function and the text and blocks update as expected, so the logic seems sound and appears to be a problem introducing the ObjectDBX aspect of the code.