Dictionaries and Xrecords

Discussion in 'AutoCAD' started by Matt W, Oct 8, 2004.

  1. Matt W

    Matt W Guest

    I'm new to this whole XRECORD concept so please bear with me...

    I've got a dictionary (MY_LAYERS) set up that Within that dictionary is an
    XRECORD (MY_LAYER_STATES) which contains the current layers within the
    drawing.
    I'm able to write everything to the dictionary and xrecord no problem!

    The problem I'm running into is this: How can I now read the contents of the
    xrecord?? The number of entries within the xrecord will vary from one
    drawing to another.

    Thanks in advance!
     
    Matt W, Oct 8, 2004
    #1
  2. Matt, Find the upper bounds of the record....

    For I = 0 to UBound(XrecordData)

    Nice game last night...Go Bronson...Bring
    on the Yanks....

    Paul
     
    Paul Richardson, Oct 9, 2004
    #2
  3. Matt, You could also add LBounds...

    For I = LBound(XrecordData) _
    to UBound(XrecordData)

    Paul
     
    Paul Richardson, Oct 9, 2004
    #3
  4. Matt W

    Matt W Guest

    Thanks, Paul but...

    I can't seem to get this thing straight. I *know* it's something simple,
    but I just can't put my finger on it.

    Here's the code I've got so far...

    Code:
    Option Explicit
    
    
    Public Sub CreateXrecord()
    Dim oXrec As AcadXRecord
    Dim oDict As AcadDictionary
    Dim oLayer As AcadLayer
    Dim vType() As Integer
    Dim vData() As Variant
    Dim i As Integer
    
    ReDim Preserve vData(0 To i)
    ReDim Preserve vType(0 To i)
    
    Set oDict = ThisDrawing.Dictionaries.Add("MY_LAYERS")
    For Each oLayer In ThisDrawing.Layers
    vType(i) = 1
    vData(i) = oLayer.Name
    Set oXrec = oDict.AddXRecord("MY_LAYER_STATES")
    oXrec.SetXRecordData vType, vData
    i = i + 1
    ReDim Preserve vData(0 To i)
    ReDim Preserve vType(0 To i)
    Next
    
    Set oXrec = Nothing
    End Sub
    
    Public Sub ReadXrecord()
    Dim oXrec As AcadXRecord
    Dim oDict As AcadDictionary
    Dim vType() As Integer
    Dim vData() As Variant
    Dim i As Integer
    
    Set oDict = ThisDrawing.Dictionaries("MY_LAYERS")
    
    ' This is where I'm lost.
    ' What's the syntax to read the contents of the dictionaries xrecords?
    For i = LBound(oXrec) To UBound(oXrec)
    
    Next
    
    Set oXrec = Nothing
    Set oDict = Nothing
    End Sub
    
    It's shaping up to be a good world series!
    Now if I could only find a place that sells the "Yankee Hater" hats I'll be
    all set.

    --
    I support two teams: the Red Sox and whoever beats the Yankees.


    | Matt, You could also add LBounds...
    |
    | For I = LBound(XrecordData) _
    | to UBound(XrecordData)
    |
    | Paul
    |
    | | > Matt, Find the upper bounds of the record....
    | >
    | > For I = 0 to UBound(XrecordData)
    | >
    | > Nice game last night...Go Bronson...Bring
    | > on the Yanks....
    | >
    | > Paul
    | >
    | >
    | > | > > I'm new to this whole XRECORD concept so please bear with me...
    | > >
    | > > I've got a dictionary (MY_LAYERS) set up that Within that dictionary
    is
    | an
    | > > XRECORD (MY_LAYER_STATES) which contains the current layers within the
    | > > drawing.
    | > > I'm able to write everything to the dictionary and xrecord no problem!
    | > >
    | > > The problem I'm running into is this: How can I now read the contents
    of
    | > the
    | > > xrecord?? The number of entries within the xrecord will vary from one
    | > > drawing to another.
    | > >
    | > > Thanks in advance!
    | > >
    | > >
    | > > --
    | > > I support two teams: the Red Sox and whoever beats the Yankees.
    | > >
    | > >
    | > >
    | >
    | >
    |
    |
     
    Matt W, Oct 11, 2004
    #4
  5. Matt dump the Record to a Var array and then you can read..Can't wait for
    tomorrow night...gl Paul

    Public Sub ReadXrecord()
    Dim oXrec As AcadXRecord
    Dim oDict As AcadDictionary
    Dim XrecType As Variant
    Dim XrecData As Variant
    Dim i As Integer

    Set oDict = ThisDrawing.Dictionaries("MY_LAYERS")
    Set oXrec = oDict.GetObject("MY_LAYER_STATES")
    oXrec.GetXRecordData XrecType, XrecData

    For i = LBound(XrecData) To UBound(XrecData)
    Debug.Print XrecData(i)
    Next

    Set oXrec = Nothing
    Set oDict = Nothing
    End Sub
     
    Paul Richardson, Oct 11, 2004
    #5
  6. Matt W

    Matt W Guest

    Thanks, Paul.
    I figured it out earlier this morning, but I've been to busy trying to get some as-built drawings completed!

    Thanks for the reply.

    I'm thinkin' the Sox in 5! I think they want it more than the Spankees (especially after last year).

    Go Red Sox!!
     
    Matt W, Oct 11, 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.