[求助]奇怪
有如下怪问题:下面的程序是选取封闭区域的一点,有boundary()函数找出其边界
而后对得到的多义线进行编辑。(boundary()函数在明经取得)
怪问题出现:在IDE编辑器中运行正常,可在点取宏菜单中的运行宏时
提示出错?不知何故,请斑竹指点,
Public Sub test()
Dim point As Variant
point = ThisDrawing.Utility.GetPoint(, "select a point:")
Dim mypline As AcadLWPolyline
Dim coordpoint As Variant
Set mypline = Boundary(point)
mypline.layer = "qbz"
coordpoint = mypline.Coordinates
End Sub
Public Function Boundary(ByVal point As Variant) As AcadLWPolyline
On Error Resume Next
Dim PrevTotal As Long
PrevTotal = ThisDrawing.ModelSpace.count
ThisDrawing.SetVariable "NOMUTT", 1
ThisDrawing.SendCommand "_-boundary" & vbCr & point(0) & "," & point(1) & vbCr & vbCr
ThisDrawing.SetVariable "NOMUTT", 0
If ThisDrawing.ModelSpace.count > PrevTotal Then
Set Boundary = ThisDrawing.ModelSpace.Item(ThisDrawing.ModelSpace.count - 1)
End If
End Function
請教斑竹
上面的问题我考虑了很长时间。却无结果,按常理在vba ide中调试成功,用宏调用绝对没有问题,是否有其他的原因呢?
配置-win2000+acad2000
我试过没有问题,我这里是98+2002
在vba ide中调试成功
在vba ide中调试成功,这样你肯定是处于中断模式,这时SendCommand命令是直接执行的,但如果不是处于中断模式,AutoCad就会先执行ThisDrawing.SetVariable "NOMUTT", 0If ThisDrawing.ModelSpace.count > PrevTotal Then
Set Boundary = ThisDrawing.ModelSpace.Item(ThisDrawing.ModelSpace.count - 1)
End If
(AtuoCad优先执行VBA的代码,然后才执行SendCommand的内容)
这样就不可能正确。
页:
[1]