Author Topic: Named Object Dictonary  (Read 1333 times)

0 Members and 1 Guest are viewing this topic.

poncelet

  • Guest
Named Object Dictonary
« on: March 09, 2012, 09:56:25 AM »
Hello,
Can we create a new dictionary under Named Object Dictonary (NOD) and put there our xrecords?

poncelet

  • Guest
Re: Named Object Dictonary
« Reply #1 on: March 09, 2012, 11:11:30 AM »
Found it:
Code - vb.net: [Select]
  1.         Dim ed As Editor = Application.DocumentManager.MdiActiveDocument.Editor
  2.         Dim dLock As DocumentLock = Application.DocumentManager.MdiActiveDocument.LockDocument
  3.  
  4.         Using trans As Transaction = ed.Document.Database.TransactionManager.StartTransaction
  5.             Try
  6.                 Dim nod As DBDictionary = trans.GetObject(ed.Document.Database.NamedObjectsDictionaryId, OpenMode.ForRead)
  7.                 If Not nod.Contains("i love to hate .net") Then
  8.                     nod.UpgradeOpen()
  9.                     Dim Dict As New DBDictionary
  10.                     nod.SetAt("i love to hate .net", Dict)
  11.                     trans.AddNewlyCreatedDBObject(Dict, True)
  12.                 End If
  13.             Catch ex As System.Exception
  14.                 ed.WriteMessage(vbCr & "Dictionary creation failed")
  15.             End Try
  16.             trans.Commit()
  17.             dLock.Dispose()
  18.         End Using
  19.  

If you use VBA try this:
Code - vb.net: [Select]
  1.         ThisDrawing.Dictionaries.Add("i love to hate .net")