Here's some code I found useful to copy Layer Standards, Property Set Definitions, or Display Properties that should be applicable to your needs (it works with anything that can be contained in a Dictionary object):
{code}
' copies the specified dictionary from the source document into the destination document
' overwrites any existing values it finds in the destination document
Protected Friend Shared Function CloneDictionary(ByVal dbAcad As Database, ByVal strSource As String, ByVal strDictionary As String, Optional ByVal strItem As String = Nothing, Optional ByVal blnIncludeDefaults As Boolean = False) As Boolean
Dim blnReturn As Boolean
Dim dbSource As Database = New Database(False, True)
Dim edCmdLine As Editor = AcApp.Application.DocumentManager.MdiActiveDocument.Editor
If Not File.Exists(strSource) Then
edCmdLine.WriteMessage(vbLf & "Cannot find Dictionary """ & strDictionary & """ at " & strSource)
Return False
End If
' check if the source drawing is the same as the destination drawing
If String.Compare(strSource, dbAcad.Filename, True) = 0 Then
Return False
End If
Try
' read the source drawing in as a "side" database
dbSource.ReadDwgFile(strSource, FileShare.Read, True, "")
Dim oicSource As ObjectIdCollection = New ObjectIdCollection()
Dim rxcItem As RXClass = Nothing
Using trSource As Transaction = dbSource.TransactionManager.StartTransaction()
Dim dicNOD As DBDictionary = DirectCast(trSource.GetObject(dbSource.NamedObjectsDictionaryId, OpenMode.ForRead, False, False), DBDictionary)
Dim dicSource As DBDictionary = DirectCast(trSource.GetObject(dicNOD.GetAt(strDictionary), OpenMode.ForRead, False, False), DBDictionary)
Dim deItem As DBDictionaryEntry
For Each deItem In dicSource
' if no dictionary entry is specified, load them all
If String.IsNullOrEmpty(strItem) Then
oicSource.Add(deItem.Value)
Else ' if a dictionary entry is specified, only load the specified entry
If deItem.Key = strItem Then
oicSource.Add(deItem.Value)
End If
End If
Next
' if any items have been added to the collection, get the RXClass and clone the items
If oicSource.Count > 0 Then
Dim objItem As DBObject = trSource.GetObject(oicSource.Item(0), OpenMode.ForRead)
' get a valid RXClass
rxcItem = objItem.GetRXClass()
Dim clhAcad As CloningHelper = New CloningHelper()
clhAcad.MergeType = DictionaryRecordMergeBehavior.Overwrite
clhAcad.UseTransactions = False
clhAcad.OverwriteDependentAutoCADObjects = True
clhAcad.IncludeDefaultDisplaySystem = blnIncludeDefaults
' make sure the Id's are from individual items (and not the Id of the dictionary itself)
' all entries should be of the same RXClass type, which is typically true for an AEC dictionary
clhAcad.Clone(dbSource, dbAcad, oicSource, rxcItem, True)
blnReturn = True
Else
blnReturn = False
End If
trSource.Commit()
End Using
Catch ex As Exception
blnReturn = False
Finally
If Not dbSource Is Nothing AndAlso Not dbSource.IsDisposed Then
dbSource.Dispose()
End If
End Try
Return blnReturn
End Function
{code}
A sample implementation would be:
{code}
' imports specified layer key standard from specified file into current database
Protected Friend Shared Function LoadLayerStandard(ByVal dbAcad As Database) As Boolean
Dim blnReturn As Boolean
Dim strLayerKeyStandard As String = "AIA (256 Color)"
Dim strLayerKeyStandardFile As String = "X:\Support\ACD-A 2011\Layers\AecLayerStd.dwg"
blnReturn = CloneDictionary(dbAcad, strLayerKeyStandardFile, "AEC_LAYERKEY_STYLES")
Using trAcad As Transaction = dbAcad.TransactionManager.StartTransaction()
Dim dicLayerKey As DictionaryLayerKeyStyle = New DictionaryLayerKeyStyle(dbAcad)
Dim dsvAcad As DrawingSetupVariables
dsvAcad = DirectCast(trAcad.GetObject(DrawingSetupVariables.GetInstance(dbAcad, True), OpenMode.ForWrite), DrawingSetupVariables)
dsvAcad.AlwaysUpdateLayerKeyStyle = True
dsvAcad.LayerFile = strLayerKeyStandardFile
dsvAcad.LayerStandard = strLayerKeyStandard
dsvAcad.SaveAsDefault()
trAcad.Commit()
End Using
Return blnReturn
End Function
{code}
I found, in the case of the LayerKeyStandard, that you need to programatically set a Layer Key Override then reset it in order to copy all the override values.