Free VBA code snippets for AutoCAD
Please feel free to be inspired, cut&paste or if you have any feedback or questions go here. If you want some customization, VBA conversion to .NET or anything else that you can come up with that we might help you with you're welcome to contact us.
Sample to write and read Xrecord values in a Dictionary:
Public Sub WriteXRec() Dim oDict As AcadDictionary Dim oXRec As AcadXRecord Dim dxfCode(0 To 1) As Integer Dim dxfData(0 To 1) Set oDict = ThisDrawing.Dictionaries.Add("SampleTest") Set oXRec = oDict.AddXRecord("Record1") dxfCode(0) = 1: dxfData(0) = "First Value" dxfCode(1) = 2: dxfData(1) = "Second Value" oXRec.SetXRecordData dxfCode, dxfData End Sub Public Sub ReadXRec() Dim oDict As AcadDictionary Dim oXRec As AcadXRecord Dim dxfCode, dxfData Set oDict = ThisDrawing.Dictionaries.Item("SampleTest") Set oXRec = oDict.Item("Record1") oXRec.GetXRecordData dxfCode, dxfData Debug.Print dxfData(0) Debug.Print dxfData(1) End Sub