Hi Guys,
I am transfering information from a Current Drawing that is open to a side Database.
But when I try to copy across the LineType I get a eLockViolation error.
Any help would be greatly appreciated.
Offenending Piece of code is:
DB.WblockCloneObjects(CloneOIDS, mLayers(FoundIndex).SetLLineTypeTableID, idMap, DuplicateRecordCloning.Replace, False)
DB = New Database(False, True) 'Open DWG to be copied to
DB.ReadDwgFile(ExistingFileName, FileOpenMode.OpenForReadAndWriteNoShare, False, "")
Using DB
Changed = False
Dim layer As LayerTableRecord
Using tr As Transaction = DB.TransactionManager.StartTransaction()
Dim lt As LayerTable = TryCast(tr.GetObject(DB.LayerTableId, OpenMode.ForWrite), LayerTable)
For Each layerId As ObjectId In lt
layer = TryCast(tr.GetObject(layerId, OpenMode.ForWrite), LayerTableRecord)
'List Of Classes that contain my Layers that need to be copied.
Dim FoundIndex As Integer = mLayers.FindIndex(Function(Lay As clsLayerDetails) Lay.LayerName = layer.Name)
If FoundIndex > -1 Then 'Has found a Layer to needs to be copied
mLayers(FoundIndex).LayerFound_Res = True
'Modify layer Status to suit
If mLayers(FoundIndex).eFreeze Then layer.IsFrozen = mLayers(FoundIndex).IsFrozen
If mLayers(FoundIndex).eOnOff Then layer.IsOff = mLayers(FoundIndex).IsOff
If mLayers(FoundIndex).ePlot Then layer.IsPlottable = mLayers(FoundIndex).IsPlotAble
If mLayers(FoundIndex).eLock Then layer.IsLocked = mLayers(FoundIndex).IsLocked
'Change Color
If mLayers(FoundIndex).eLColor Then layer.Color = mLayers(FoundIndex).SetLColor
'If line type needs to be changed
If mLayers(FoundIndex).eLLineType Then
Dim ltt As LinetypeTable = TryCast(tr.GetObject(DB.LinetypeTableId, OpenMode.ForWrite), LinetypeTable)
'Check to see if line type i missing in Destination Database (SetLLineType is ObjectID of linetype)
If ltt.Has(mLayers(FoundIndex).SetLLineType) = False Then
Dim CloneOIDS As New ObjectIdCollection
CloneOIDS.Add(mLayers(FoundIndex).SetLLineType)
Dim idMap As IdMapping = New IdMapping()
DB.WblockCloneObjects(CloneOIDS, mLayers(FoundIndex).SetLLineTypeTableID, idMap, DuplicateRecordCloning.Replace, False) 'FAIL HERE eLockViolation
End If
layer.LinetypeObjectId = mLayers(FoundIndex).SetLLineType
End If
Changed = True
End If
Next
tr.Commit()
End Using
If Changed Then
DB.RetainOriginalThumbnailBitmap = True
DB.SaveAs(SaveAsFileName, DB.OriginalFileVersion) ' DwgVersion.Current)
End If
End Using
DB = Nothing