Offset 方法 (ActiveX) 
在与现有对象的指定偏移距离处创建新对象。 支持的平台:仅限 Windows 签名VBA: RetVal = object.Offset(Distance) 返回值 (RetVal)类型:变体(对象数组) 由偏移量生成的新创建对象的数组。 言论对于许多曲线,此操作的结果将是一条新曲线(可能与原始曲线的类型不同)。例如,偏移椭圆将导致样条曲线,因为结果不符合椭圆方程。在某些情况下,偏移结果可能需要是几条曲线。 ![]() 原始对象和偏移量为红色的对象。 例子VBA: 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
    ZoomAll
            
    MsgBox "Offset the polyline by 0.25.", , "Offset Example"
    
    ' Offset the polyline
    Dim offsetObj As Variant
    offsetObj = plineObj.offset(0.25)
    
    ZoomAll
    MsgBox "Offset completed.", , "Offset Example"
    
End Sub
可视化 LISP: (vl-load-com)
(defun c:Example_Offset()
    ;; This example creates a lightweight polyline
    ;; and then offsets the polyline.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
  
    ;; Create the polyline
    (setq points (vlax-make-safearray vlax-vbDouble '(0 . 11)))
    (vlax-safearray-fill points '(1 1
                                  1 2
                                  2 2
                                  3 2
                                  4 4
                                  4 1
                                 )
    )
    (setq modelSpace (vla-get-ModelSpace doc))
    (setq plineObj (vla-AddLightWeightPolyline modelSpace points))
    (vla-put-Closed plineObj :vlax-true)
    (vla-ZoomAll acadObj)
            
    (alert "Offset the polyline by 0.25.")
    
    ;; Offset the polyline
    (setq offsetObj (vla-Offset plineObj 0.25))
    
    (vla-ZoomAll acadObj)
    (alert "Offset completed.")
)
 | 
|Archiver|CAD开发者社区
( 苏ICP备2022047690号-1   苏公网安备32011402011833)
GMT+8, 2025-11-5 00:06
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.