Saving and Retriving AcadDictionaries

Discussion in 'AutoCAD' started by David Urban, Apr 15, 2004.

  1. David Urban

    David Urban Guest

    I have a project that I am working on that I save my data into an
    acadDictionary. I need this information in another drawing. I am
    looking suggestions/code examples for the best way to save and retrieve
    this data.

    TIA

    David Urban
     
    David Urban, Apr 15, 2004
    #1
  2. AcadDictionaries are stored in a drawing. If you need to
    access data across drawings, then it would make sense to
    store it externally, perhaps in an XML file or some other
    form, no?

    Otherwise, you can use ObjectDBX to access data in another
    drawing without opening it in the AutoCAD editor.
     
    Tony Tanzillo, Apr 15, 2004
    #2
  3. David Urban

    Tim Badger Guest

    David, this should get you started. I believe this was origianally posted
    by Jeff

    Public Sub WriteXRecOLD()
    Dim mydict As AcadDictionary
    Set mydict = ThisDrawing.Dictionaries.Add("Sample")

    Dim myXRec As AcadXRecord
    Set myXRec = mydict.AddXRecord("Test")

    Dim dxfCode(0 To 1) As Integer
    Dim dxfData(0 To 1)
    dxfCode(0) = 1: dxfData(0) = "Hello?"
    dxfCode(1) = 2: dxfData(1) = "Is anybody out there?"
    myXRec.SetXRecordData dxfCode, dxfData
    End Sub

    Public Sub ReadXRec()
    Dim mydict As AcadDictionary
    Set mydict = ThisDrawing.Dictionaries.Item("Sample")

    Dim myXRec As AcadXRecord
    Set myXRec = mydict.Item("Test")

    Dim dxfCode, dxfData
    myXRec.GetXRecordData dxfCode, dxfData

    MsgBox dxfData(0) & vbCrLf & dxfData(1)
    End Sub
     
    Tim Badger, Apr 16, 2004
    #3
  4. David Urban

    David Urban Guest

    Thanks for the code example. I may not have been fully clear in my
    question. I use these examples in my code but I need to move the
    dictionary to another drawing and need to save the dictionary data to a
    file and then retrieve that data in the new drawing. I use the
    dictionary just to save the data in the drawing and when my routine runs
    it loads a local array with my data. I can replace the dictionary with
    a subroutine that reads and writes the data to an INI or XML file. I
    found some examples for INI but haven't looked hard for an XML file. I
    was wondering before I start which is better to use. My array that my
    data is in is a UDT.

    Thanks

    David Urban
     
    David Urban, Apr 16, 2004
    #4
  5. David Urban

    Mark Propst Guest

    I think you were clear with your question
    Tony posted the solutions possible
    The xml sounds like the way to go, though, like you, I have not yet found a
    simple tutorial on how to create and read xml files.
    from the little i understand about xml that would be the perfect repository
    for a udt
    I've done a fair amount of googleing trying to find how to incorporate xml
    into lisp or vb but havent' found it yet....more time.....
    good luck and keep us posted on what you come up with.

    without getting into the new territory of an xml the quickest way may be
    what tony said about using objectdbx to just copy the dictionary object from
    one dwg to another
     
    Mark Propst, Apr 16, 2004
    #5
  6. David Urban

    Tim Badger Guest

    You probably stated it correctly... I didn't read it correctly :) After
    reading it again, Tony's suggestion to write it out to a file then aquire
    the data from the file for other drawing(s) seems like the way to go.
     
    Tim Badger, Apr 16, 2004
    #6
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.