cryyyy 发表于 2005-5-27 17:21:00

在vb和CAD二次开发时,画圆弧出现了这样的错误




如图,发生了这样的错误


提示是要求对象,不明白


程序都在图上了,谁给看看...


或者如下:


Dim arcObj As AcadArc<BR>Dim centerPoint(0 To 2) As Double<BR>Dim radius As Double<BR>Dim startAngleInDegree As Double<BR>Dim endAngleInDegree As Double<BR>' Define the circle<BR>centerPoint(0) = 0#: centerPoint(1) = 0#: centerPoint(2) = 0#<BR>radius = 5#<BR>startAngleInDegree = 10#<BR>endAngleInDegree = 230#<BR>' Convert the angles in degrees to angles in radians<BR>Dim startAngleInRadian As Double<BR>Dim endAngleInRadian As Double<BR>startAngleInRadian = startAngleInDegree * 3.141592 / 180#<BR>endAngleInRadian = endAngleInDegree * 3.141592 / 180#<BR>' Create the arc object in model space<BR>Set arcObj = ThisDrawing.ModelSpace.AddArc(centerPoint, radius, startAngleInRadian, endAngleInRadian)<BR>ZoomAll<BR>

wyj7485 发表于 2005-5-27 18:08:00

程序没错啊,我刚试了,可以画圆弧.

armylee 发表于 2005-5-27 20:51:00

我也帮你试过了,没有错,可以画圆弧。

mccad 发表于 2005-5-27 21:29:00

还没有错?<BR>请注意楼主需要的是在VB环境下,而不是VBA环境下。<BR>所以ThisDrawing没有定义。

cryyyy 发表于 2005-5-27 22:35:00

mccad发表于2005-5-27 21:29:00static/image/common/back.gif还没有错?请注意楼主需要的是在VB环境下,而不是VBA环境下。所以ThisDrawing没有定义。


怎么定义?


直接 dim thisdrawing as double ???<BR>

cryyyy 发表于 2005-5-27 22:45:00

cryyyy发表于2005-5-27 22:35:00static/image/common/back.gif以下是引用mccad在2005-5-27 21:29:50的发言:还没有错?请注意楼主需要的是在VB环境下,而不是VBA环境下。所以Thi...

<BR></DIV>



我直接对 thisdrawing 定义的话(别见笑,初学者),又发生了这样的错误说       无效限定符


这又是怎么回事?

armylee 发表于 2005-5-28 01:20:00

dim        thisdrawing as acaddocument       


set thisdrawing =acadApp.Activedocument

cryyyy 发表于 2005-5-28 15:48:00

armylee发表于2005-5-28 1:20:00static/image/common/back.gifdim        thisdrawing as acaddocument       



set thisdrawing =acadApp.Activedocument


哈哈,厉害


高手


搞定了


非常感谢<BR>

xqyhome 发表于 2005-5-28 16:04:00

椭圆弧怎么画,帮我

用VB代码画 椭圆弧 ,帮我

cryyyy 发表于 2005-5-28 18:20:00

armylee发表于2005-5-28 1:20:00static/image/common/back.gifdim        thisdrawing as acaddocument       



set thisdrawing =acadApp.Activedocument


<BR>Dim arcObj As AcadArc                                                                                                                                                               '''''''''''''''''''''''''''''''''''''''''弧<BR>Dim centerPoint(0 To 2) As Double<BR>Dim radius As Double<BR>Dim startAngleInDegree As Double               'Sqr(nj ^ 2 - (b / 2) ^ 2) + ybjl<BR>Dim endAngleInDegree As Double


Dim thisdrawing As AcadDocument


Set thisdrawing = acadapp.ActiveDocument


<BR>'Dim ppp As Double<BR>ppp = (b / 2) / Sqr(nj ^ 2 - (b / 2) ^ 2)<BR>qqq = Atn(ppp)


<BR>' Define the circle<BR>centerPoint(0) = ybjl#: centerPoint(1) = zxxsp#: centerPoint(2) = 0#<BR>radius = nj#<BR>startAngleInDegree = ppp<BR>endAngleInDegree = -qqq<BR>' Convert the angles in degrees to angles in radians<BR>Dim startAngleInRadian As Double<BR>Dim endAngleInRadian As Double<BR>startAngleInRadian = startAngleInDegree * 3.141592 / 180#<BR>endAngleInRadian = endAngleInDegree * 3.141592 / 180#<BR>' Create the arc object in model space<BR>Set arcObj = thisdrawing.ModelSpace.AddArc(centerPoint, radius, startAngleInRadian, endAngleInRadian)<BR>ZoomAll


完整程序如上,其中我要定义这俩个角才可以画出弧,假如我直接给角附值,那可以轻松画出弧.但是假如我给他附一个变量,怎么就画不出来啊...???


startAngleInDegree = ppp<BR>endAngleInDegree = -qqq


ppp可以,但是经过反正切Atn(ppp)得到qqq之后,就画不出来了,是不是不能用反正切函数啊???


ppp = (b / 2) / Sqr(nj ^ 2 - (b / 2) ^ 2)<BR>qqq = Atn(ppp)
页: [1] 2
查看完整版本: 在vb和CAD二次开发时,画圆弧出现了这样的错误