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

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


如图,发生了这样的错误
提示是要求对象,不明白
程序都在图上了,谁给看看...
或者如下:
Dim arcObj As AcadArc
Dim centerPoint(0 To 2) As Double
Dim radius As Double
Dim startAngleInDegree As Double
Dim endAngleInDegree As Double
' Define the circle
centerPoint(0) = 0#: centerPoint(1) = 0#: centerPoint(2) = 0#
radius = 5#
startAngleInDegree = 10#
endAngleInDegree = 230#
' Convert the angles in degrees to angles in radians
Dim startAngleInRadian As Double
Dim endAngleInRadian As Double
startAngleInRadian = startAngleInDegree * 3.141592 / 180#
endAngleInRadian = endAngleInDegree * 3.141592 / 180#
' Create the arc object in model space
Set arcObj = ThisDrawing.ModelSpace.AddArc(centerPoint, radius, startAngleInRadian, endAngleInRadian)
ZoomAll

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

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

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

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

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

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

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

怎么定义?
直接 dim thisdrawing as double ???

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

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

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

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

dim      thisdrawing as acaddocument      
set thisdrawing =acadApp.Activedocument

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

哈哈,厉害
高手
搞定了
非常感谢

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

用VB代码画 椭圆弧 ,帮我

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


Dim arcObj As AcadArc                                                                                                                                                               '''''''''''''''''''''''''''''''''''''''''弧
Dim centerPoint(0 To 2) As Double
Dim radius As Double
Dim startAngleInDegree As Double               'Sqr(nj ^ 2 - (b / 2) ^ 2) + ybjl
Dim endAngleInDegree As Double
Dim thisdrawing As AcadDocument
Set thisdrawing = acadapp.ActiveDocument
'Dim ppp As Double
ppp = (b / 2) / Sqr(nj ^ 2 - (b / 2) ^ 2)
qqq = Atn(ppp)
' Define the circle
centerPoint(0) = ybjl#: centerPoint(1) = zxxsp#: centerPoint(2) = 0#
radius = nj#
startAngleInDegree = ppp
endAngleInDegree = -qqq
' Convert the angles in degrees to angles in radians
Dim startAngleInRadian As Double
Dim endAngleInRadian As Double
startAngleInRadian = startAngleInDegree * 3.141592 / 180#
endAngleInRadian = endAngleInDegree * 3.141592 / 180#
' Create the arc object in model space
Set arcObj = thisdrawing.ModelSpace.AddArc(centerPoint, radius, startAngleInRadian, endAngleInRadian)
ZoomAll
完整程序如上,其中我要定义这俩个角才可以画出弧,假如我直接给角附值,那可以轻松画出弧.但是假如我给他附一个变量,怎么就画不出来啊...???
startAngleInDegree = ppp
endAngleInDegree = -qqq
ppp可以,但是经过反正切Atn(ppp)得到qqq之后,就画不出来了,是不是不能用反正切函数啊???
ppp = (b / 2) / Sqr(nj ^ 2 - (b / 2) ^ 2)
qqq = Atn(ppp)
页: [1]
查看完整版本: 在vb和CAD二次开发时,画圆弧出现了这样的错误