明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 2642|回复: 0

运行时错误‘13’ -类型不匹配

[复制链接]
发表于 2008-10-25 01:24:00 | 显示全部楼层 |阅读模式

Public Sub creatcircle()
Dim centerpoint(0 To 2) As Double
setpoint3d centpoint, 0, 0, 0
Dim mspace As New clsModelSpace
mspace.AddCircle centerpoint, 50
Dim startpoint(0 To 2) As Double, endpoint(0 To 2) As Double
setpoint3d startpoint, 50, 0, 0
setpoint3d endpoint, 150, 0, 0
mspace.AddCircleBy2Point startpoint, endpoint

End Sub

Public Function setpoint3d(ByVal point As Variant, ByVal x As Double, ByVal y As Double, ByVal z As Double)
Debug.Assert (VarType(point) = vbArray + vbDouble)----------------------------错误地方!!!!!!!!!!!!!!
Debug.Assert (LBound(point) = 0 And UBound(point) = 2)
point(0) = x
point(1) = y
point(2) = z
End Function

Public Function GetDistanceBetween2Point(ByVal startpoint As Variant, ByVal endpoint As Variant) As Double
Dim a As Double, b As Double, c As Double
x = startpoint(0) - endpoint(0)
y = startpoint(1) - endpoint(1)
z = startpoint(2) - endpoint(2)
GetDistanceBetween2Point = Sqr(x ^ 2 + y ^ 2 + z ^ 2)
End Function

Public Function GetMiddlePointBetween2Point(ByVal startpoint As Variant, ByVal endpoint As Variant) As Double
Dim midpoint(0 To 2) As Double
midpoint(0) = (startpoint(0) - endpoint(0)) / 2
midpoint(1) = (startpoint(1) - endpoint(1)) / 2
midpoint(2) = (startpoint(2) - endpoint(2)) / 2
GetMiddlePointBetween2Point = midpoint
End Function

Public Function AddCircle(ByVal centerpoint As Variant, ByVal radius As Double) As AcadCircle
Debug.Assert (radius > 0.0000001)
Debug.Assert (VarType(centerpoint) = vbArray + vbDouble)
Set AddCircle = ThisDrawing.ModelSpace.AddCircle(centerpoint, radius)
End Function

Public Function AddCircleBy2Point(ByVal startpoint As Variant, ByVal endpoint As Variant) As AcadCircle
Debug.Assert (VarType(startpoint) = vbArray + vbDouble)
Debug.Assert (VarType(endpoint) = vbArray + vbDouble)
'计算圆心和半径
Dim centerpoint As Variant, radius As Double
centerpoint = math.GetMiddlePointBetween2Point(startpoint, endpoint)
radius = math.GetDistanceBetween2Point(startpoint, endpoint) / 2
Set AddCircleBy2Point = AddCircle(centerpoint, radius)
End Function

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-26 06:46 , Processed in 0.156504 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表