CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

AddVertex Method (ActiveX)

2023-1-4 12:03| 发布者: admin| 查看: 495| 评论: 0|来自: AutoCAD

摘要: 将顶点添加到轻量级折线或截面。

将顶点添加到轻量级折线或截面。

支持的平台:仅窗口

签名

工 务 局:

object.AddVertex Index, Point
对象

类型:LW线部分

此方法适用的对象。

指数

访问:仅输入

类型:

要添加顶点的顶点数组中的索引。索引必须是正整数。数组的第一个元素是索引 0。

访问:仅输入

类型:变体(双精度的三元素数组)

用于创建新顶点的 3D OCS 坐标。

返回值(RetVal)

无返回值。

言论

LWPolyline:顶点指定新线段的端点。要将弧段添加到轻量级折线,请先创建线段,然后将“凸起”添加到要成为弧的单个段。若要向段添加凸起值,请使用该方法。SetBulge

截面:顶点指定剖面线上的点。

可以使用该方法将坐标与OCS相互转换。TranslateCoordinates

例子

工 务 局:

Sub Example_AddVertex()
    ' This example creates a lightweight polyline in model space.
    ' It then adds a vertex to the polyline.

    Dim plineObj As AcadLWPolyline
    Dim points(0 To 9) As Double
    
    
    ' Define the 2D polyline points
    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
        
    ' Create a lightweight Polyline object in model space
    Set plineObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(points)
    ZoomAll
    MsgBox "Add a vertex to the end of the polyline.", , "AddVertex Example"
    
    ' Define the new vertex
    Dim newVertex(0 To 1) As Double
    newVertex(0) = 4: newVertex(1) = 1
    
    ' Add the vertex to the polyline
    plineObj.AddVertex 5, newVertex
    plineObj.Update
    MsgBox "Vertex added.", , "AddVertex Example"
    
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_AddVertex()
    ;; This example creates a lightweight polyline in model space.
    ;; It then adds a vertex to the polyline.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))

    ;; Define the 2D polyline points
    (setq points (vlax-make-safearray vlax-vbDouble '(0 . 9)))
    (vlax-safearray-fill points '(1 1
                                  1 2
                                  2 2
                                  3 2
                                  4 4
                                 )
    )
        
    ;; Create a lightweight Polyline object in model space
    (setq modelSpace (vla-get-ModelSpace doc))
    (setq plineObj (vla-AddLightWeightPolyline modelSpace points))
    (vla-ZoomAll acadObj)
    (alert "Add a vertex to the end of the polyline.")
    
    ;; Define the new vertex
    (setq newVertex (vlax-make-safearray vlax-vbDouble '(0 . 1)))
    (vlax-safearray-fill newVertex '(4 1))
    
    ;; Add the vertex to the polyline
    (vla-AddVertex plineObj 5 newVertex)
    (vla-Update plineObj)
    (alert "Vertex added.")
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-5-12 11:08

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部