通过运行,发现在以下代码运行时不稳定,报错
Private Sub Class_Initialize()
If Left(ThisDrawing.Application.Version, 2) = "15" Then
Set VL = ThisDrawing.Application.GetInterfaceObject("VL.Application.1")
Else
Set VL = ThisDrawing.Application.GetInterfaceObject("VL.Application.16")
End If
Set VLF = VL.ActiveDocument.Functions
End Sub
在参考其他源码,发现做如下变动,运行就比较稳定
Private Sub Class_Initialize()
ThisDrawing.SendCommand "(vl-load-com)" & vbCr '首先要加载VL接口,因为后面的函数是基于它的。本句为新添加语句,其他不变
If Left(ThisDrawing.Application.Version, 2) = "15" Then
Set VL = ThisDrawing.Application.GetInterfaceObject("VL.Application.1")
ElseIf Left(ThisDrawing.Application.Version, 2) = "16" Then
Set VL = ThisDrawing.Application.GetInterfaceObject("VL.Application.16")
End If
Set VLF = VL.ActiveDocument.Functions
End Sub
运行环境:XP3,CAD2006,VB6
有没有大神解释下 Curve类模块中 GetClosestPointToProjection 的Normal参数在VBA中如何指定啊?
多谢!
Public Function GetClosestPointToProjection(Point As Variant, Normal As Variant, Optional Extend As Boolean = False) As Variant
Dim retval As Variant, pt(0 To 2) As Double
Dim i As Long
With objVLAX
.SetLispSymbol "handle", mvarEntity.Handle
.SetLispSymbol "givenPt", Point
.SetLispSymbol "normal", Normal
If Extend Then .EvalLispExpression "(setq ext T)"
.EvalLispExpression "(setq lst (vlax-curve-getClosestPointToProjection (handent handle) givenPt normal ext))"
retval = .GetLispList("lst")
.NullifySymbol "handle", "lst", "normal", "ext", "givenPt"
End With