正如托尼. t .会说的,拥有一个可以被调用的lisp函数比试图用VL接口来做所有的事情更有意义。这是一个小函数,它可以满足你的需要,但是我不确定TwistAngle实际上做了什么......我可以用这个函数改变它,视图对话框显示它被改变了,但是恢复的实际视图和它开始时是一样的。
无论如何,你可以这样从VBA打电话给我:
''First 2 functions from Tony T's example sent to me
Public vlApp As Object
' Initialize and/or return vl application object
' Note that we don't try to cache any other Vl
' objects, because they are all document-specific
Public Function GetVlApp() As Object
If (vlApp Is Nothing) Then
Set vlApp = AcadApplication.GetInterfaceObject("Vl.Application.16")
End If
Set GetVlApp = vlApp
End Function
' Call this to get a LISP function defined in the Active document
' (do not cache the result because it is document-specific)
Public Function VlFunc(Name As String) As Object
Set VlFunc = GetVlApp.ActiveDocument.Functions.Item(Name)
End Function
''This calls the setviewangle lisp function
Sub testViewAngle()
Dim oView As AcadView
Dim dRot As Double
Set oView = ThisDrawing.Views.Item("test")
dRot = 1.57
VlFunc("setviewangle").Funcall oView.Handle, dRot
End Sub
和lisp:
(defun setviewangle (hndl ang / elist)
(setq elist (entget (handent hndl)))
(entmod (subst (cons 50 ang)(assoc 50 elist) elist))
)
HTH,
杰夫