这是我的代码
- 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
第一个似乎有效。我尝试了两个图形,一个有信息,没有错误消息提示,一个没有信息,得到了错误消息。我的问题似乎是第二个代码。我试图看看是否可以在不指定大小的情况下获取xrecord数据,并将其打印到消息框中(目前命令行也可以)
这是用于添加xrecord和dictionary的lisp代码(以防万一)。
- (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")
- )
本帖以下内容被隐藏保护;需要你回复后,才能看到! 游客,如果您要查看本帖隐藏内容请 回复 |