Here is my code
Public Function GetXRecLisp() As AcadXRecord
Dim DictCol As AcadDictionaries
Dim MyDict As AcadDictionary
Dim XRec As AcadXRecord
Set DictCol = ThisDrawing.Dictionaries
On Error GoTo MyError
Set MyDict = DictCol.Item("LisptoVBA")
Set XRec = MyDict.Item("LisptoVBA")
Set GetXRecLisp = XRec
Exit Function
MyError:
MsgBox "Error " & Err.Number & " ( " & Err.Description & " )"
End Function
Public Sub ShowXrecData(ByRef XRec As AcadXRecord)
Dim DataType As Integer
Dim Data As Variant
Dim Cnt As Integer
Set XRec = GetXRecLisp
XRec.GetXRecordData DataType, Data
For Cnt = 0 To UBound(Data)
MsgBox Data(Cnt)
Next
End Sub
It seems like the first one works. I tried it with two drawings, one with information, no error message prompt, one with no information, and got the error message. My problem seems to be with the second code. I'm trying to see if I can get the xrecord data without specifying a size, and just print it to a message box (command line would be fine also, for now).
Thanks in advance for any help.
Here is the lisp code used to add the xrecord, and dictionary (just incase).
(defun MySetXRec (Obj CodeList DataList / )
; Sets XRecordData. Dxf numbers between 1-369, except 5, 100, 105.
; See help for types and numbers to use.
(vla-SetXRecordData Obj
(vlax-make-variant
(vlax-safearray-fill
(vlax-make-safearray
vlax-vbInteger
(cons 0 (1- (length CodeList)))
)
CodeList
)
)
(vlax-make-variant
(vlax-safearray-fill
(vlax-make-safearray
vlax-vbVariant
(cons 0 (1- (length Datalist)))
)
DataList
)
)
)
)
(MySetXrec
(vla-AddXRecord
(vla-Add
(vla-get-Dictionaries
(vla-get-ActiveDocument
(vlax-get-Acad-Object)
)
)
"LisptoVBA"
)
"LisptoVBA"
)
'(1 2)
'("Testing" "Again")
)