马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
对于一个声明为AcadEntity的对象,当它的属性返回值是Variant(变体)类型时,如果这个值是数组的话,则不能直接引用它当中的某一个值。如
- [FONT=courier new]
- Dim startPoint(0 To 2) As Double
- Dim endPoint(0 To 2) As Double
- startPoint(0) = 1#: startPoint(1) = 1#: startPoint(2) = 0#
- endPoint(0) = 5#: endPoint(1) = 5#: endPoint(2) = 0#
- Dim lineObj As AcadEntity
- Set lineObj = ThisDrawing.ModelSpace.AddLine(startPoint, endPoint)
- MsgBox "Start point = " & lineObj.startPoint(0) & ", " & lineObj.startPoint(1)
- [/FONT]
运行程序后,将产生错误。
解决方法:1、声明lineObj对象为AcadLine对象。
- [FONT=courier new]
- Dim startPoint(0 To 2) As Double
- Dim endPoint(0 To 2) As Double
- startPoint(0) = 1#: startPoint(1) = 1#: startPoint(2) = 0#
- endPoint(0) = 5#: endPoint(1) = 5#: endPoint(2) = 0#
- Dim lineObj As AcadLine
- Set lineObj = ThisDrawing.ModelSpace.AddLine(startPoint, endPoint)
- MsgBox "Start point = " & lineObj.startPoint(0) & ", " & lineObj.startPoint(1)
- [/FONT]
2、创建一临时变量,如:
- [FONT=courier new]
- Dim startPoint(0 To 2) As Double
- Dim endPoint(0 To 2) As Double
- startPoint(0) = 1#: startPoint(1) = 1#: startPoint(2) = 0#
- endPoint(0) = 5#: endPoint(1) = 5#: endPoint(2) = 0#
- Dim lineObj As AcadLine
- Set lineObj = ThisDrawing.ModelSpace.AddLine(startPoint, endPoint)
- Dim tempPoint As Variant
- tempPoint = lineObj.startPoint
- MsgBox "Start point = " & tempPoint(0) & ", " & tempPoint(1)
- [/FONT]
|