Creating an array of arrays as XrecordData

Discussion in 'AutoCAD' started by Dale Levesque, Jun 2, 2004.

  1. What I'm trying to do is to create an array of arrays as XRecordData using
    the following but it results in an error at 'xrec.SetXRecordData xType,
    xData'.

    At the error: xType = an array of size zero containing 1001
    xData = an array of size zero containing an array of 3
    variants.


    Any suggestions?


    Dale

    GetXrecord lo_Drawing, DICTIONARY_NAME, XRECORD_BRICK, XRecordDataType,
    fv_BrickData

    If Not HasElements(fv_BrickData) Then
    fv_BrickDataType = 1001

    ReDim fv_Data(0 To 2)
    ' Block Suffix
    fv_Data(0) = "1"
    fv_Data(1) = mvarWidth
    fv_Data(2) = mvarThickness

    fv_BrickData = fv_Data
    End If

    WriteXrecord lo_Drawing, DICTIONARY_NAME, XRECORD_BRICK, fv_BrickDataType,
    fv_BrickData

    Public Function HasElements(ByVal ArrayToCheck As Variant) As Boolean
    On Error Resume Next
    HasElements = (LBound(ArrayToCheck) <= UBound(ArrayToCheck))
    End Function

    Public Sub WriteXrecord(ao_Drawing As AcadDocument, dName As String, keyName
    As String, ParamArray data())

    Dim dic As AcadDictionary, xrec As AcadXRecord
    Dim xType() As Integer, xData(), I As Integer, J As Integer
    Dim min As Integer, max As Integer

    On Error Resume Next
    Set dic = ao_Drawing.Dictionaries(dName)
    If Err Then
    Err.Clear
    Set dic = ao_Drawing.Dictionaries.Add(dName)
    End If
    On Error GoTo 0

    Set xrec = dic.AddXRecord(keyName)

    min = LBound(data): max = UBound(data)
    J = 0

    For I = min To max Step 2
    ReDim Preserve xType(0 To J)
    ReDim Preserve xData(0 To J)
    xType(J) = data(I): xData(J) = data(I + 1)
    J = J + 1
    Next

    xrec.SetXRecordData xType, xData

    End Sub
     
    Dale Levesque, Jun 2, 2004
    #1
  2. Any idea where to get a listing of the integers to use for various data
    types?
     
    Dale Levesque, Jun 2, 2004
    #2
  3. Should this work????

    xrec.SetXRecordData xType, xData

    When xType is an array from 0 to 2 containing 1, 38 and 38.
    xData is an array from 0 to 2 containing "1", 4 and 1.625

    I get a subscript out of range error.

    Dale
     
    Dale Levesque, Jun 2, 2004
    #3
  4. Art's list looks odd at 38-39. Those should still be 3D points still.

    --
    R. Robert Bell


    "Mark Propst" <notmark-at-atreng-dot-com> wrote in message
    A few notes on xdata codes

    From Art Cooney

    Here's the data types that Xrecords use for the
    various group code ranges:

    0 - 9 Text
    10,20,30 - 17,27,37 3d point
    38 - 59 Real
     
    R. Robert Bell, Jun 2, 2004
    #4
  5. Dale,

    Use group codes 40 & 41, not 38 & 39:

    Public Sub WriteXRec()
    Dim myDict As AcadDictionary
    Set myDict = ThisDrawing.Dictionaries.Add("Sample")
    Dim myXRec As AcadXRecord
    Set myXRec = myDict.AddXRecord("Test")
    Dim dxfCode(0 To 2) As Integer
    Dim dxfData(0 To 2)
    dxfCode(0) = 1: dxfData(0) = "1"
    dxfCode(1) = 40: dxfData(1) = 4#
    dxfCode(2) = 41: dxfData(2) = 1.625
    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) & vbCrLf & dxfData(2)
    End Sub


    --
    R. Robert Bell


    "Dale Levesque" <dale at dynamicwindows.com> wrote in message
    Should this work????

    xrec.SetXRecordData xType, xData

    When xType is an array from 0 to 2 containing 1, 38 and 38.
    xData is an array from 0 to 2 containing "1", 4 and 1.625

    I get a subscript out of range error.

    Dale
     
    R. Robert Bell, Jun 2, 2004
    #5
  6. Art's list would indicate that 38/39 is available to hold a real, while it
    is not.
     
    R. Robert Bell, Jun 2, 2004
    #6
  7. ActiveX won't let the assignment occur under 38 (I did not test 39).

    --
    R. Robert Bell


    "Mark Propst" <notmark-at-atreng-dot-com> wrote in message
    also from art

    "Actually, group codes 38 & 39 are ok to use. In Xrecords, group codes 38 -
    59 can hold a double that can mean anything you want (no special
    intrepretation/conversion is done by AutoCAD)."
     
    R. Robert Bell, Jun 2, 2004
    #7
  8. Thanks for the help though Mark. Much appreciated.

    Best regards,

    Dale

     
    Dale Levesque, Jun 2, 2004
    #8
  9. Dale Levesque

    Mark Propst Guest

    from help:

    "NOTE Do not add a 1001 group into your extended data because AutoCAD
    assumes it is the beginning of a new application extended data
    group"
     
    Mark Propst, Jun 3, 2004
    #9
  10. Dale Levesque

    Mark Propst Guest

    A few notes on xdata codes

    From Art Cooney

    Here's the data types that Xrecords use for the
    various group code ranges:

    0 - 9 Text
    10,20,30 - 17,27,37 3d point
    38 - 59 Real
    60 - 79 Int16
    90 - 99 Int32
    100 Text
    101 Text
    102 Text
    105 Text
    110,120,130 - 112,122,132 3d point
    140 - 149 Real
    170 - 179 Int16
    210,220,230 - 219,229,239 3d point
    270 - 279 Int16
    280 - 289 Int8
    290 - 299 Int8
    300 - 309 Text
    310 - 319 BChunk
    320 - 329 Handle
    330 - 339 SoftPointerId
    340 - 349 HardPointerId
    350 - 359
    SoftOwnershipId
    360 - 369
    HardOwnershipId
    370 - 379 Int16
    380 - 389 Int16
    390 - 399 HardPointerId
    400 - 409 Int16
    410 - 419 Text
    999 - 1003 Text
    1004 BChunk
    1005 Text
    1010,1020,1030 - 1013,1023,1033 3d point
    1040 - 1042 Real
    1070 Int16
    1071 Int32

    from R. Robert Bell:

    XRecord data will be stored/retrieved using the standard DXF group codes, so
    you need to have that list handy (look in the DXF Reference). Note that you
    should *not* use DXF group codes above 369.
     
    Mark Propst, Jun 3, 2004
    #10
  11. Dale Levesque

    Mark Propst Guest

    The list is in the help under dxf codes.
    However there are a few mistakes there(what's new?)
    I posted the corrected list (thanks to Art Cooney ) in my other reply
     
    Mark Propst, Jun 3, 2004
    #11
  12. Dale Levesque

    Mark Propst Guest

     
    Mark Propst, Jun 3, 2004
    #12
  13. Dale Levesque

    Mark Propst Guest

    also from art

    "Actually, group codes 38 & 39 are ok to use. In Xrecords, group codes 38 -
    59 can hold a double that can mean anything you want (no special
    intrepretation/conversion is done by AutoCAD)."
     
    Mark Propst, Jun 3, 2004
    #13
  14. Dale Levesque

    Mark Propst Guest

    I'll revise my notes accordingly,
    Thanks
     
    Mark Propst, Jun 3, 2004
    #14
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.