事实上,虽然这符合我的要求,但这将获得基于xrecord名称的Xrecorddata。我想这就是您真正想要的……检查test2子部分末尾的xcode和xdata的返回值……
- Function get_the_Xrec(strXRecName As String) As AcadXRecord
- Dim oEnt As AcadEntity
- Dim oDict As AcadDictionary
- Dim oXrec As AcadXRecord
- Dim oTmp2 As AcadObject
- For Each oEnt In ThisDrawing.ModelSpace
- If oEnt.HasExtensionDictionary = True Then
- Set oDict = oEnt.GetExtensionDictionary
- For Each oTmp2 In oDict
- If TypeOf oTmp2 Is AcadXRecord Then
- Set oXrec = oTmp2
- If oXrec.Name = strXRecName Then
- Set get_the_Xrec = oXrec
- Exit Function
- End If
- End If
- Next
- End If
- Next
- End Function
- Sub test2()
- Dim oXrec As AcadXRecord
- Set oXrec = get_the_Xrec("MV_PRODUCTS")
- If Not oXrec Is Nothing Then
- Debug.Print oXrec.Handle
- 'do whatever you want with it now that you have it
- Dim xdata As Variant
- Dim xcode As Variant
- oXrec.GetXRecordData xcode, xdata
- End If
- End Sub
|