ch_wang 发表于 2010-5-11 00:15:00

object.offset(distance)怎么了?

<p>Public Sub TdnC()</p><p>Dim myLn1 As AcadLine<br/>Dim myLn1CP As AcadLine<br/>Dim myLn2 As AcadLine<br/>Dim myLn2CP As AcadLine<br/>Dim mySPt(1 To 3) As Double<br/>Dim myEPt(1 To 3) As Double<br/>Dim CR As Double<br/>Dim myCirc As AcadCircle<br/>Dim myCPt(1 To 3) As Double<br/>Dim x As AcadCircle</p><p>mySPt(1) = 0<br/>mySPt(2) = 0<br/>mySPt(3) = 0<br/>myEPt(1) = 100<br/>myEPt(2) = 100<br/>myEPt(3) = 0<br/>myCPt(1) = 0<br/>myCPt(2) = 0<br/>myCPt(3) = 0</p><p>CR = 30</p><p>Set myCirc = ThisDrawing.ModelSpace.AddCircle(myCPt, CR)<br/>myCirc.Update<br/>Set x = myCirc.Offset(-15)</p><p>Set myLn1 = ThisDrawing.ModelSpace.AddLine(mySPt, myEPt)<br/>Set myLn1CP = myLn1.Offset(CR)</p><p>mySPt(1) = 100<br/>mySPt(2) = 100<br/>mySPt(3) = 0<br/>myEPt(1) = 400<br/>myEPt(2) = 100<br/>myEPt(3) = 0</p><p>Set myLn2 = ThisDrawing.ModelSpace.AddLine(mySPt, myEPt)<br/>Set myLn2CP = myLn2.Offset(CR)</p><p>ThisDrawing.Application.ZoomExtents</p><p>End Sub</p><p>给位大哥帮下小弟!这个问题应该是非常的简单,现在就是不知道错在哪里?一运行就会显示,要求对象,错误‘424’</p><p>小弟一人孤军奋战,头大之极!在我的电脑上就是运行不过去!不知道哪里的毛病!上面就是全部代码!需要别人帮助指点下~可怜我~帮助下!</p><p></p>

ch_wang 发表于 2010-5-11 10:46:00

<p>我早上起来试了下</p><p>单独使用Obiect.offset(distance)可以,就是不能把他赋给别的对象!请问下是不是这样啊??</p><p>小弟请求大家指点下,我刚学VBA,不是很明白,我看别人都可以把它赋给别的对象的啊!!!这是怎么回事啊?</p>

ag503685496 发表于 2010-5-11 20:00:00

<p>Obiect.offset(distance)的返回值不是对象,而是对象数组。所以Set myLn1CP = myLn1.Offset(CR)是错误的,而应该这样:</p><p>dim myLn1CP as various </p><p>myLn1CP=myLn1.Offset(CR)</p><p>既然是数组,如果对象只有一个,可以象这样引用:</p><p>myLn1CP(0).delete,等等</p>

ch_wang 发表于 2010-5-12 00:27:00

<p>感谢您的回复!非常感谢!</p><p>明白了!</p>
页: [1]
查看完整版本: object.offset(distance)怎么了?