明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1287|回复: 3

[求助]奇怪

[复制链接]
发表于 2003-4-18 22:26 | 显示全部楼层 |阅读模式
有如下怪问题:
  下面的程序是选取封闭区域的一点,有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
 楼主| 发表于 2003-4-19 21:03 | 显示全部楼层

請教斑竹

上面的问题我考虑了很长时间。却无结果,按常理在vba ide中调试成功,用宏
调用绝对没有问题,是否有其他的原因呢?
配置-win2000+acad2000
发表于 2003-4-19 22:25 | 显示全部楼层

我试过没有问题,我这里是98+2002

发表于 2003-5-12 11:29 | 显示全部楼层

在vba ide中调试成功

在vba ide中调试成功,这样你肯定是处于中断模式,这时SendCommand命令是直接执行的,但如果不是处于中断模式,AutoCad就会先执行ThisDrawing.SetVariable "NOMUTT", 0
    If ThisDrawing.ModelSpace.count > PrevTotal Then
        Set Boundary = ThisDrawing.ModelSpace.Item(ThisDrawing.ModelSpace.count - 1)
    End If

(AtuoCad优先执行VBA的代码,然后才执行SendCommand的内容)
这样就不可能正确。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-5-18 19:30 , Processed in 0.187765 second(s), 23 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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