I dont believe it is a Map Save Set lock. I have had this error occur without a discernable patern, but I have also replicated it in a controlled environment. For now, I'll focus on the controlled environment, although I would eventually like to figure out what is causing the seemingly random occurances. Basically, what I do is a use the following code to iterate through an object's Object Data records for a particular table..
Public Sub test()
Dim AcadApp, AcadMap, acadmapproject, ODTables1
Dim AcadObj
Dim ODT_pipeline As ODtable
Dim BadObj As Boolean
Dim RecordIterator, ODRec, counter, CurTable, CurRecord
Dim Uid As Long
Set AcadApp = ThisDrawing.Application
Set AcadMap = AcadApp.GetInterfaceObject("AutoCADMap.Application")
Set acadmapobject = AcadMap.Projects(ThisDrawing)
Set ODTables1 = acadmapobject.ODTables
For Each selset In ThisDrawing.SelectionSets
If selset.name = "Chkproj" Then Exit For Else Set selset = Nothing
Next
If selset Is Nothing Then Set selset = ThisDrawing.SelectionSets.Add("Chkproj")
selset.Clear
selset.Select acSelectionSetAll
Set ODT_pipeline = ODTables1.item("Pipe")
For Each AcadObj In selset
If AcadObj.layer = "PIPE" Then
Set RecordIterator = ODT_pipeline.GetODRecords
RecordIterator.init AcadObj, False, False
If RecordIterator.IsDone Then BadObj = True 'flag object as bad
Do Until RecordIterator.IsDone
Set ODrecord = RecordIterator.Record
For counter = 0 To ODrecord.Count - 1
Set CurTable = ODT_pipeline.ODFieldDefs.item(counter)
Set CurRecord = ODrecord.item(counter)
If LCase(CurTable.name) = "idfeature" Then Uid = Val(CurRecord.Value)
Next
RecordIterator.Next
Loop
'Set RecordIterator = Nothing 'release the RecordIterator lock on objects
If BadObj = True Or Uid = 0 Then AcadObj.Color = acRed
End If
Next
End Sub
Now here is the thing.. if I stop the VBA code while its iterating through the set, or if I comment out the Set Rec.. = nothing line of code, then there is a lock placed on the object, and when I try to go and edit that object, say change its color or layer from VBA, I get the object open for read error. But yet, I can still go into AutoCAD and change the color of the object "by hand" as it were. My question is there any way that I can remove this lock so if i get an 'object was open for read' error, I can handle the error. I have attached the DWG file that I used to replicate the problem with the code above. Thank you for all your help.
Anthony Fiti
Las Vegas Valley Water District