你的程序的问题出在了下面两处:
1,Dim offsetobj As AcadLWPolyline offsetobj = plineObj.Offset(0.25)
对象Offset后返回的是一个对象数组,而你的offsetobj只定义成一种对象类型,那么在运行时回报错。所以改成
Dim offsetobj As Variant offsetobj = plineObj.Offset(0.25)
2,下面的这一段
Dim line As AcadLine Dim pnt1(2) As Double Dim pnt2(2) As Double
pnt1(0) = offsetobj.Coordinates(0) pnt1(1) = offsetobj.Coordinates(1) pnt1(2) = 0
Coordinates属性不支持Coordinates(0)这种获取数值的方法,需要一个中间变量来过渡一下。所以改成如下
Dim line As AcadLine Dim pnt1 As Variant Dim pnt2(2) As Double
pnt1 = offsetobj(0).Coordinates ReDim Preserve pnt1(2) pnt1(2) = 0
ReDim Preserve pnt1(2)是为了去除你不想要的一些数值
最后,我运行完发现程序最后生成的线的位置不太对头,你再仔细调试一下。反正有思路就不难了!
|