nhy12345678 发表于 2008-6-17 13:58:00

如何得到偏移后的对象?

<p>set sst=sst1.offset 100</p><p>提示出现错误!!!请高手指点</p>

robbin840311 发表于 2008-6-18 10:15:00

<p>LZ,我估计你定义的sst类型不是Variant。</p><p>而RetVal = object.Offset(Distance) </p><p class="element"><strong>RetVal是一个Variant类型</strong></p><p class="element-desc">Variant (array of objects)<br/>An array of the newly created objects resulting from the offset.</p><p class="element-desc"></p><p><strong>’代码如下:</strong></p><p>Sub Example_Offset()<br/>&nbsp;&nbsp;&nbsp; ' This example creates a lightweight polyline<br/>&nbsp;&nbsp;&nbsp; ' and then offsets the polyline.<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; ' Create the polyline<br/>&nbsp;&nbsp;&nbsp; Dim plineObj As AcadLWPolyline<br/>&nbsp;&nbsp;&nbsp; Dim points(0 To 11) As Double<br/>&nbsp;&nbsp;&nbsp; points(0) = 1: points(1) = 1<br/>&nbsp;&nbsp;&nbsp; points(2) = 1: points(3) = 2<br/>&nbsp;&nbsp;&nbsp; points(4) = 2: points(5) = 2<br/>&nbsp;&nbsp;&nbsp; points(6) = 3: points(7) = 2<br/>&nbsp;&nbsp;&nbsp; points(8) = 4: points(9) = 4<br/>&nbsp;&nbsp;&nbsp; points(10) = 4: points(11) = 1<br/>&nbsp;&nbsp;&nbsp; Set plineObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(points)<br/>&nbsp;&nbsp;&nbsp; plineObj.Closed = True</p><p>&nbsp;&nbsp;&nbsp; ' Offset the polyline<br/>&nbsp;&nbsp;&nbsp; Dim offsetObj As Variant<br/>&nbsp;&nbsp;&nbsp; offsetObj = plineObj.Offset(0.25)&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; Dim pLwpOffset As AcadLWPolyline<br/>&nbsp;&nbsp;&nbsp; Set pLwpOffset = offsetObj(0)&nbsp;&nbsp;&nbsp; '得到偏移后的多段线<br/>&nbsp;&nbsp;&nbsp; <br/>&nbsp;&nbsp;&nbsp; '定义绿色<br/>&nbsp;&nbsp; Dim CorGreen As AcadAcCmColor<br/>&nbsp;&nbsp; Set CorGreen = AcadApplication.GetInterfaceObject("AutoCAD.AcCmColor.16")<br/>&nbsp;&nbsp; Call CorGreen.SetRGB(0, 255, 0)&nbsp;&nbsp; '绿色<br/>&nbsp;&nbsp; pLwpOffset.TrueColor = CorGreen<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br/>End Sub</p>

nhy12345678 发表于 2008-7-4 23:48:00

非常感谢!原来偏移后的对象可能不了1个,所以是Variant<br/>&nbsp;明白了。

rongyifei 发表于 2008-7-5 16:49:00

学习了!
页: [1]
查看完整版本: 如何得到偏移后的对象?