请问使用VLAX 怎么使用?VLAX类代码如下: Private VL As Object Private VLF As Object Private Sub Class_Initialize() If Left(ThisDrawing.Application.Version, 2) = "15" Then Set VL = GetInterfaceObject("VL.Application.1") ElseIf Left(ThisDrawing.Application.Version, 2) = "16" Then Set VL = GetInterfaceObject("VL.Application.16") ElseIf Left(ThisDrawing.Application.Version, 2) = "17" Then Set VL = GetInterfaceObject("VL.Application.16") End If Set VLF = VL.ActiveDocument.Functions End Sub Private Sub Class_Terminate() Set VLF = Nothing Set VL = Nothing End Sub Public Function EvalLispExpression(ByVal lispStatement As String) Dim sym As Object, RET As Object, RetVal Set sym = VLF.Item("read").Funcall(lispStatement) On Error Resume Next RetVal = VLF.Item("eval").Funcall(sym) If Err Then EvalLispExpression = "" Else EvalLispExpression = RetVal End If End Function Public Sub SetLispSymbol(ByVal symbolName As String, ByVal Value) Dim sym As Object, RET, symvalue symvalue = Value Set sym = VLF.Item("read").Funcall(symbolName) RET = VLF.Item("set").Funcall(sym, symvalue) EvalLispExpression "(defun translate-variant (data) (cond ((= (type data) 'list) (mapcar 'translate-variant data)) ((= (type data) 'variant) (translate-variant (vlax-variant-value data))) ((= (type data) 'safearray) (mapcar 'translate-variant (vlax-safearray->list data))) (t data)))" EvalLispExpression "(setq " & symbolName & "(translate-variant " & symbolName & "))" EvalLispExpression "(setq translate-variant nil)" End Sub Public Function GetLispSymbol(ByVal symbolName As String) Dim sym As Object, RET, symvalue symvalue = Value Set sym = VLF.Item("read").Funcall(symbolName) GetLispSymbol = VLF.Item("eval").Funcall(sym) End Function Public Function GetLispList(ByVal symbolName As String) As Variant Dim sym As Object, list As Object Dim Count, elements(), i As Long Set sym = VLF.Item("Read").Funcall(symbolName) Set list = VLF.Item("Eval").Funcall(sym) Count = VLF.Item("length").Funcall(list) ReDim elements(0 To Count - 1) As Variant For i = 0 To Count - 1 elements(i) = VLF.Item("nth").Funcall(i, list) Next GetLispList = elements End Function Public Sub NullifySymbol(ParamArray symbolName()) Dim i As Integer For i = LBound(symbolName) To UBound(symbolName) EvalLispExpression "(setq " & CStr(symbolName(i)) & " nil)" Next End Sub |