CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

追加顶点方法 (ActiveX)

2023-1-4 11:47| 发布者: admin| 查看: 633| 评论: 0|来自: AutoCAD

摘要: 将顶点追加到 3DPolyline、折线或多边形网格对象的末尾。

将顶点追加到 3DPolyline、折线或多边形网格对象的末尾。

支持的平台:仅窗口

签名

工 务 局:

object.AppendVertex Point
对象

类型:3D线,多边形网格折线

此方法适用的对象。

访问:仅输入

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

指定要追加的顶点的坐标。

多边形网格:指定附加顶点行的 3D WCS 坐标数组。

3DPolyline:指定要追加的顶点的 3D WCS 坐标数组。

折线:3D 坐标数组。XY坐标以 OCS 形式给出,Z坐标被忽略。

返回值(RetVal)

无返回值。

言论

多边形网格:将顶点附加到对象的末端时,将附加一行顶点。例如,对于 4 x 3,您可以定义 12 个顶点。附加顶点将使矩阵为 5 x 3,因此需要三个额外的坐标。如果 4 x 3 矩阵的最后一个顶点如下:PolygonMeshPolygonMesh

  • 顶点(3,0): 6,6,6
  • 顶点(3,1): 7,7,7
  • 顶点(3,2): 8,8,8

您将附加:

  • 顶点(4,0): 10,10,10
  • 顶点(4,1): 10,5,0
  • 顶点(4,2): 10,20,30

对象的OCS坐标可以使用该方法与其他坐标系相互转换。PolylineTranslateCoordinates

例子

工 务 局:

Sub Example_AppendVertex()
    ' This example creates a polyline in model space.
    ' It then appends a vertex to the polyline.
    
    Dim plineObj As AcadPolyline
    Dim points(0 To 14) As Double
    
    
    ' Define the 2D polyline points
    points(0) = 1: points(1) = 1: points(2) = 0
    points(3) = 1: points(4) = 2: points(5) = 0
    points(6) = 2: points(7) = 2: points(8) = 0
    points(9) = 3: points(10) = 2: points(11) = 0
    points(12) = 4: points(13) = 4: points(14) = 0
        
    ' Create a lightweight Polyline object in model space
    Set plineObj = ThisDrawing.ModelSpace.AddPolyline(points)
    ZoomAll
    MsgBox "Append the vertex 4, 1, 0.", , "AppendVertex Example"
    
    Dim newVertex(0 To 2) As Double
    newVertex(0) = 4: newVertex(1) = 1: newVertex(2) = 0
    plineObj.AppendVertex newVertex
    ZoomAll
    MsgBox "The vertex 4, 1, 0 as been appended.", , "AppendVertex Example"

End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_AppendVertex()
    ;; This example creates a polyline in model space.
    ;; It then appends a vertex to the polyline.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
    
    ;; Define the 2D polyline points
    (setq center (vlax-make-safearray vlax-vbDouble '(0 . 14)))
    (vlax-safearray-fill center '(1 1 0
                                  1 2 0
                                  2 2 0
                                  3 2 0
                                  4 4 0
                                 )
    )
        
    ;; Create a lightweight Polyline object in model space
    (setq modelSpace (vla-get-ModelSpace doc))  
    (setq plineObj (vla-AddPolyline modelSpace points))
    (vla-ZoomAll acadObj)
    (alert "Append the vertex 4, 1, 0.")
    
    (setq newVertex (vlax-3d-point 4 1 0))
    (vla-AppendVertex plineObj newVertex)
    (vla-ZoomAll acadObj)
    (alert "The vertex 4, 1, 0 as been appended.")
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-5-19 14:35

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部