Message 1 of 20
Xrecords (going from VBA to .NET)

Not applicable
07-09-2008
09:34 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello,
I have been spinning my wheels for near on 8 months now trying to figure
out how to create (and then read) Xrecords in .NET. Thus far i haven't
found any posts/lessons that have been of any help.
Below are the 2 VBA functions I use to create/read/delete my Xrecords in
AutoCAD. I hope someone can get me going in the right direction (this
little problem stands in my way of moving my applications to .NET).
Thank you to whoever decides to help me 😆
--------------------------------------
--------------------------------------
Create:::
Public Function vb_sxr()
Dim TrackingDictionary As AcadDictionary, TrackingXRecord As
AcadXRecord
Dim XRecordDataType As Variant, XRecordData As Variant
Dim DataType As Integer, Data As String, msg As String
Const TYPE_STRING = 1
Const TAG_DICTIONARY_NAME = "TRK Page"
Const TAG_XRECORD_NAME = "Layout"
On Error GoTo Create
Set TrackingDictionary = ThisDrawing.Dictionaries(TAG_DICTIONARY_NAME)
Set TrackingXRecord = TrackingDictionary.GetObject(TAG_XRECORD_NAME)
On Error GoTo 0
TrackingXRecord.GetXRecordData XRecordDataType, XRecordData
If VarType(XRecordDataType) And vbArray = vbArray Then
Else
ReDim XRecordDataType(0) As Integer
ReDim XRecordData(0) As Variant
End If
XRecordDataType(0) = TYPE_STRING: XRecordData(0) =
ThisDrawing.GetVariable("USERS1")
TrackingXRecord.SetXRecordData XRecordDataType, XRecordData
Exit Function
Create:
If TrackingDictionary Is Nothing Then
Set TrackingDictionary =
ThisDrawing.Dictionaries.Add(TAG_DICTIONARY_NAME)
Set TrackingXRecord =
TrackingDictionary.AddXRecord(TAG_XRECORD_NAME)
End If
Resume
End Function
--------------------------------------
--------------------------------------
Read:::
Public Function vb_gxr()
Dim TrackingDictionary As AcadDictionary, TrackingXRecord As
AcadXRecord
Dim XRecordDataType As Variant, XRecordData As Variant
' Dim iCount As Long
Dim DataType As Integer, Data As String, msg As String
Const TYPE_STRING = 1
Const TAG_DICTIONARY_NAME = "TRK Page"
Const TAG_XRECORD_NAME = "Layout"
On Error GoTo NONE
Set TrackingDictionary = ThisDrawing.Dictionaries(TAG_DICTIONARY_NAME)
Set TrackingXRecord = TrackingDictionary.GetObject(TAG_XRECORD_NAME)
On Error GoTo 0
TrackingXRecord.GetXRecordData XRecordDataType, XRecordData
DimSet = XRecordData(0)
Exit Function
NONE:
DimSet = ""
End Function
--------------------------------------
--------------------------------------
Delete:::
Public Function vb_rxr()
Dim TrackingDictionary As AcadDictionary, TrackingXRecord As
AcadXRecord
Dim XRecordDataType As Variant, XRecordData As Variant
Dim DataType As Integer, Data As String, msg As String
Const TYPE_STRING = 1
Const TAG_DICTIONARY_NAME = "TRK Page"
Const TAG_XRECORD_NAME = "Layout"
On Error GoTo NONE
Set TrackingDictionary = ThisDrawing.Dictionaries(TAG_DICTIONARY_NAME)
Set TrackingXRecord = TrackingDictionary.GetObject(TAG_XRECORD_NAME)
On Error GoTo 0
TrackingXRecord.GetXRecordData XRecordDataType, XRecordData
If VarType(XRecordDataType) And vbArray = vbArray Then
Else
ReDim XRecordDataType(0) As Integer
ReDim XRecordData(0) As Variant
End If
XRecordDataType(0) = TYPE_STRING: XRecordData(0) =
ThisDrawing.GetVariable("USERS1")
TrackingXRecord.SetXRecordData XRecordDataType, XRecordData
TrackingDictionary.Delete
RemTRKFT
Exit Function
NONE:
End Function
I have been spinning my wheels for near on 8 months now trying to figure
out how to create (and then read) Xrecords in .NET. Thus far i haven't
found any posts/lessons that have been of any help.
Below are the 2 VBA functions I use to create/read/delete my Xrecords in
AutoCAD. I hope someone can get me going in the right direction (this
little problem stands in my way of moving my applications to .NET).
Thank you to whoever decides to help me 😆
--------------------------------------
--------------------------------------
Create:::
Public Function vb_sxr()
Dim TrackingDictionary As AcadDictionary, TrackingXRecord As
AcadXRecord
Dim XRecordDataType As Variant, XRecordData As Variant
Dim DataType As Integer, Data As String, msg As String
Const TYPE_STRING = 1
Const TAG_DICTIONARY_NAME = "TRK Page"
Const TAG_XRECORD_NAME = "Layout"
On Error GoTo Create
Set TrackingDictionary = ThisDrawing.Dictionaries(TAG_DICTIONARY_NAME)
Set TrackingXRecord = TrackingDictionary.GetObject(TAG_XRECORD_NAME)
On Error GoTo 0
TrackingXRecord.GetXRecordData XRecordDataType, XRecordData
If VarType(XRecordDataType) And vbArray = vbArray Then
Else
ReDim XRecordDataType(0) As Integer
ReDim XRecordData(0) As Variant
End If
XRecordDataType(0) = TYPE_STRING: XRecordData(0) =
ThisDrawing.GetVariable("USERS1")
TrackingXRecord.SetXRecordData XRecordDataType, XRecordData
Exit Function
Create:
If TrackingDictionary Is Nothing Then
Set TrackingDictionary =
ThisDrawing.Dictionaries.Add(TAG_DICTIONARY_NAME)
Set TrackingXRecord =
TrackingDictionary.AddXRecord(TAG_XRECORD_NAME)
End If
Resume
End Function
--------------------------------------
--------------------------------------
Read:::
Public Function vb_gxr()
Dim TrackingDictionary As AcadDictionary, TrackingXRecord As
AcadXRecord
Dim XRecordDataType As Variant, XRecordData As Variant
' Dim iCount As Long
Dim DataType As Integer, Data As String, msg As String
Const TYPE_STRING = 1
Const TAG_DICTIONARY_NAME = "TRK Page"
Const TAG_XRECORD_NAME = "Layout"
On Error GoTo NONE
Set TrackingDictionary = ThisDrawing.Dictionaries(TAG_DICTIONARY_NAME)
Set TrackingXRecord = TrackingDictionary.GetObject(TAG_XRECORD_NAME)
On Error GoTo 0
TrackingXRecord.GetXRecordData XRecordDataType, XRecordData
DimSet = XRecordData(0)
Exit Function
NONE:
DimSet = ""
End Function
--------------------------------------
--------------------------------------
Delete:::
Public Function vb_rxr()
Dim TrackingDictionary As AcadDictionary, TrackingXRecord As
AcadXRecord
Dim XRecordDataType As Variant, XRecordData As Variant
Dim DataType As Integer, Data As String, msg As String
Const TYPE_STRING = 1
Const TAG_DICTIONARY_NAME = "TRK Page"
Const TAG_XRECORD_NAME = "Layout"
On Error GoTo NONE
Set TrackingDictionary = ThisDrawing.Dictionaries(TAG_DICTIONARY_NAME)
Set TrackingXRecord = TrackingDictionary.GetObject(TAG_XRECORD_NAME)
On Error GoTo 0
TrackingXRecord.GetXRecordData XRecordDataType, XRecordData
If VarType(XRecordDataType) And vbArray = vbArray Then
Else
ReDim XRecordDataType(0) As Integer
ReDim XRecordData(0) As Variant
End If
XRecordDataType(0) = TYPE_STRING: XRecordData(0) =
ThisDrawing.GetVariable("USERS1")
TrackingXRecord.SetXRecordData XRecordDataType, XRecordData
TrackingDictionary.Delete
RemTRKFT
Exit Function
NONE:
End Function