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

如何得到偏移后的对象?

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

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

LZ,我估计你定义的sst类型不是Variant。
而RetVal = object.Offset(Distance)
RetVal是一个Variant类型
Variant (array of objects)
An array of the newly created objects resulting from the offset.
’代码如下:
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) = 1: points(1) = 1
    points(2) = 1: points(3) = 2
    points(4) = 2: points(5) = 2
    points(6) = 3: points(7) = 2
    points(8) = 4: points(9) = 4
    points(10) = 4: points(11) = 1
    Set plineObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(points)
    plineObj.Closed = True
    ' Offset the polyline
    Dim offsetObj As Variant
    offsetObj = plineObj.Offset(0.25)   
   
    Dim pLwpOffset As AcadLWPolyline
    Set pLwpOffset = offsetObj(0)    '得到偏移后的多段线
   
    '定义绿色
   Dim CorGreen As AcadAcCmColor
   Set CorGreen = AcadApplication.GetInterfaceObject("AutoCAD.AcCmColor.16")
   Call CorGreen.SetRGB(0, 255, 0)   '绿色
   pLwpOffset.TrueColor = CorGreen
      
End Sub

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

非常感谢!原来偏移后的对象可能不了1个,所以是Variant
明白了。

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

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