CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

偏移方法 (ActiveX)

2023-1-4 05:08| 发布者: admin| 查看: 592| 评论: 0|来自: AutoCAD

摘要: 在距现有对象的指定偏移距离处创建新对象。

在距现有对象的指定偏移距离处创建新对象。

支持的平台:仅窗口

签名

工 务 局:

RetVal = object.Offset(Distance)
对象

类型:椭圆直线LWPolyline折线样条,XLine

此方法适用的对象。

距离

访问:仅输入

类型:

偏移对象的距离。偏移量可以是正数或负数,但不能等于零。如果偏移为负,则将其解释为偏移以形成“较小”曲线(即,对于弧,它将偏移到比起始曲线半径“距离小”的半径)。如果“较小”没有意义,则它将沿较小的XYZWCS 坐标方向偏移。

返回值(RetVal)

类型:变体(对象数组)

由偏移量生成的新创建的对象的数组。

言论

对于许多曲线,此操作的结果将是一条新曲线(可能与原始曲线的类型不同)。例如,偏移椭圆将产生样条曲线,因为结果不符合椭圆的方程。在某些情况下,偏移结果可能需要为多条曲线。



原始对象和偏移量为红色的对象。

例子

工 务 局:

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

Visual 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.")
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

QQ|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 )

GMT+8, 2024-5-12 03:14

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部