CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

坐标属性 (ActiveX)

2023-1-3 19:53| 发布者: admin| 查看: 342| 评论: 0|来自: AutoCAD

摘要: 指定对象中单个顶点的坐标。

指定对象中单个顶点的坐标。

支持的平台:仅窗口

签名

工 务 局:

object.Coordinate(index)
对象

类型:3DFace3D领导者LWPolyline,多边形网格,多边形网格折线,截面实体子DMesh跟踪

此属性适用的对象。

指数

类型:整数

要设置或查询的顶点的顶点数组中的索引。顶点数组从 0 开始。

属性值

只读:

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

指定顶点的XYZ坐标数组。

轻量级折线对象:变体有两个元素,表示 OCS 中的XY坐标。

折线对象:变体有三个元素,表示 OCS 中的XY坐标。Z坐标存在于变体中,但被忽略。

所有其他对象:变体有三个元素,代表 WCS 中的XY坐标;Z 坐标在活动 UCS 上将默认为 0。

言论

此属性将替换指定对象的任何现有顶点。使用标准数组处理技术来处理此属性中包含的值。

3DPolyline、Polyline、PolygonMesh:对于简单折线(非样条曲线或曲线拟合),此属性指定简单顶点。对于样条曲线或曲线拟合折线,此属性指定控制点顶点。

折线和对象的 OCS 坐标可以使用该方法与其他坐标系进行转换。LightweightPolylineTranslateCoordinates

例子

工 务 局:

Sub Example_Coordinate()
    ' This example creates a polyline in model space and
    ' queries and changes the coordinate in the first index position.
        
    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
    
    ' Find the coordinate in the first index position
    Dim coord As Variant
    coord = plineObj.Coordinate(0)
    MsgBox "The coordinate in the first index position of the polyline is: " & coord(0) & ", " _
        & coord(1) & ", " & coord(2)
    
    ' Change the coordinate
    coord(0) = coord(0) + 1
    plineObj.Coordinate(0) = coord
    plineObj.Update
    
    ' Query the new coordinate
    coord = plineObj.Coordinate(0)
    MsgBox "The coordinate in the first index position of the polyline is now: " & coord(0) & ", " _
        & coord(1) & ", " & coord(2)
    
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_Coordinate()
    ;; This example creates a polyline in model space and
    ;; queries and changes the coordinate in the first index position.
    (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 . 14)))
    (vlax-safearray-fill points '(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)
    
    ;; Find the coordinate in the first index position
    (setq coord (vlax-safearray->list (vlax-variant-value (vla-get-Coordinate plineObj 0))))
    (alert (strcat "The coordinate in the first index position of the polyline is: "
		   (rtos (nth 0 coord) 2) ", " (rtos (nth 1 coord) 2) ", " (rtos (nth 2 coord) 2)))
    
    ;; Change the coordinate
    (setq newCoord (vlax-make-safearray vlax-vbDouble '(0 . 2)))
    (vlax-safearray-fill newCoord (list (+ (nth 0 coord) 1)
				        (nth 1 coord)
				        (nth 2 coord)))

    (vla-put-Coordinate plineObj 0 newCoord)
    (vla-Update plineObj)
    
    ; Query the new coordinate
    (setq coord (vlax-safearray->list (vlax-variant-value (vla-get-Coordinate plineObj 0))))
    (alert (strcat "The coordinate in the first index position of the polyline is now: "
		   (rtos (nth 0 coord) 2) ", " (rtos (nth 1 coord) 2) ", " (rtos (nth 2 coord) 2)))
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-5-12 00:18

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部