foxlinshan 发表于 2004-10-29 10:30:00

[求助]能够获得点坐标,为什么不能添加点呢?

我在模块1里面定义了


pulic P1(2)as double


然后写了一个求点的函数



Public Function calc_point1(ByVal whirl_cen As Variant, ByVal PtoP_angle As Double, _<BR>ByVal whirl_a As Double, ByVal whirl_r As Double) As Variant


'whirl_cen 为圆弧圆心坐标,PtoP_angle 为一个方位角,whirl_a 为回旋线放大系数,


'whirl_r为回旋线上一点对应半径<BR>Dim temp_pt(1), t,Arc_xy(1) As Double


Arc_xy(0) = 10


Arc_xy(1)=20<BR>t = whirl_a ^ 2 / whirl_r ^ 2 / 2


temp_pt(0) = whirl_cen(0) + (Arc_xy(1) + whirl_r * Cos(t)) * Cos(PtoP_angle)<BR>temp_pt(1) = whirl_cen(1) + (Arc_xy(1) + whirl_r * Cos(t)) * Sin(PtoP_angle)


P1(0) = temp_pt(0) - (Arc_xy(0) - whirl_r * Sin(t)) * Sin(PtoP_angle)<BR>P1(1) = temp_pt(1) + (Arc_xy(0) - whirl_r * Sin(t)) * Cos(PtoP_angle)<BR>P1(2) = 0


'添加debug.print       


ThisDrawing.ModelSpace.addpoint P1


calc_point1 = P1


End Function



在运行到ThisDrawing.ModelSpace.addpoint P1时出现 运行时错误 ‘5’,无效的过程调用或参数


而我在添加的debug.print处得出点坐标为564.610060386037 ,178.306128990985        ,        0


为什么有了点坐标却不能添加一个点呢?请高手帮帮忙,谢谢!

雪山飞狐_lzh 发表于 2004-10-29 10:51:00

public p1(2) As Double<BR>

foxlinshan 发表于 2004-10-29 12:11:00

public p1(2) As Double?


括号是我在发帖的时候,没弄好的


括号应该没什么问题


是不是定义的类型不匹配阿?

雪山飞狐_lzh 发表于 2004-10-29 15:21:00

Dim p1(2) As Double


<BR>Public Function calc_point1(ByVal whirl_cen As Variant, ByVal PtoP_angle As Double, _<BR>ByVal whirl_a As Double, ByVal whirl_r As Double) As Variant


'whirl_cen 为圆弧圆心坐标,PtoP_angle 为一个方位角,whirl_a 为回旋线放大系数,


'whirl_r为回旋线上一点对应半径<BR>Dim temp_pt(1) As Double, t As Double, Arc_xy(1) As Double


Arc_xy(0) = 10<BR>Arc_xy(1) = 20


t = whirl_a ^ 2 / whirl_r ^ 2 / 2


temp_pt(0) = whirl_cen(0) + (Arc_xy(1) + whirl_r * Cos(t)) * Cos(PtoP_angle)<BR>temp_pt(1) = whirl_cen(1) + (Arc_xy(1) + whirl_r * Cos(t)) * Sin(PtoP_angle)


p1(0) = temp_pt(0) - (Arc_xy(0) - whirl_r * Sin(t)) * Sin(PtoP_angle)<BR>p1(1) = temp_pt(1) + (Arc_xy(0) - whirl_r * Sin(t)) * Cos(PtoP_angle)<BR>p1(2) = 0


'添加debug.print


ThisDrawing.ModelSpace.AddPoint p1


calc_point1 = p1


End Function


       


Sub tt()<BR>a = calc_point1(p1, 30, 1, 5)<BR>End Sub<BR>

crazylsp 发表于 2013-1-15 10:17:10

我也发现有时类型定义都没问题,就是加不进去。研究中...
页: [1]
查看完整版本: [求助]能够获得点坐标,为什么不能添加点呢?