- 积分
- 163
- 明经币
- 个
- 注册时间
- 2002-7-12
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
楼主 |
发表于 2002-7-21 22:34:00
|
显示全部楼层
还是有问题!
“http://www.mjtd.com/mcdown/list.asp?id=85 ;”下载不了。我在别处下载了。
在vba ide中用文件-导入-选vlax.cls
程序为:
Sub try()
Dim pickObj As AcadEntity '保存被选择图元的对象变量
Dim pickPnt As Variant '选择图元时的拾取点变量
Dim length As Double
ThisDrawing.Utility.GetEntity pickObj, pickPnt, "选择图元对象:"
length = GetCurveLength(pickObj)
MsgBox length
End Sub
Public Function GetCurveLength(curve As AcadEntity) As Double
Dim obj As VLAX, retVal
Set obj = New VLAX
obj.EvalLispExpression "(setq curve (handent " & Chr(34) & curve.Handle & Chr(34) & "))"
obj.EvalLispExpression "(setq curvelength (vlax-curve-getDistAtParam curve " & _
"(vlax-curve-getEndParam curve)))"
retVal = obj.GetLispSymbol("curvelength")
obj.NullifySymbol "curve", "curvelength"
Set obj = Nothing
GetCurveLength = CDbl(retVal)
End Function
运行后在图形中选择了一个pline,报错“实时错误-2147221005 (800401f3)”选择调试后停在类库:
Private Sub Class_Initialize()
Set VL = ThisDrawing.Application.GetInterfaceObject("VL.Application.1")
Set VLF = VL.ActiveDocument.Functions
End Sub
的第一行。
到底是怎么回事呢,我觉得没那错啊。请受累看看 |
|