AutoCAD 2004 英文版 VBA 的
AutoCAD 2004 英文版VBA命令OFFSET有个BUG,将其帮助文件里面Offset_Example例程中各个顶点坐标都加上10000,执行后,原有对象会偏移到坐标系统原点。发现这个问题,是因为笔者编了一段自用程序,其中用到Offset命令,在AutoCAD 2002里面调试成功,转到AutoCAD 2004后屡试不爽。哪位高手遇到此类情况?有何解决办法?是否用Service Pack 1可以解决?若是,能否帮忙发个Service Pack 1?Autodesk网站上Service Pack 1的连接已经不可用了! 确实有这个问题,而且是偏移后的对象没有问题,而原对象会被移动原点附近。在中文版也是这样。
可以这样解决,在偏移前原对象先复制一个,进行偏移,然后再删除复制的对象。 至于SP1,你可以到本站下载中心下载。 Sub Example_Offset()
' This example creates a lightweight polyline
' and then offsets the polyline.
' Create the polyline
Dim plineObj As AcadLWPolyline
Dim points(0 To 11) As Double
points(0) = 10001: points(1) = 10001
points(2) = 10001: points(3) = 10002
points(4) = 10002: points(5) = 10002
points(6) = 10003: points(7) = 10002
points(8) = 10004: points(9) = 10004
points(10) = 10004: points(11) = 10001
Set plineObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(points)
plineObj.Closed = True
Set plineObj = plineObj.Copy
ZoomExtents
ThisDrawing.Regen acActiveViewport
MsgBox "Offset the polyline by 0.25.", , "Offset Example"
' Offset the polyline
Dim offsetObj As Variant
offsetObj = plineObj.Offset(0.25)
plineObj.Delete
ThisDrawing.Regen acActiveViewport
ZoomExtents
MsgBox "Offset completed.", , "Offset Example"
End Sub
非常感谢mccad给出例程!
页:
[1]