指定对象中单个顶点的坐标。 支持的平台:仅窗口 签名工 务 局: object.Coordinate(index) 属性值只读:不 类型:变体(三元素或双精度数组的双元素) 指定顶点的X、Y 和Z坐标数组。 轻量级折线对象:变体有两个元素,表示 OCS 中的X和Y坐标。 折线对象:变体有三个元素,表示 OCS 中的X和Y坐标。Z坐标存在于变体中,但被忽略。 所有其他对象:变体有三个元素,代表 WCS 中的X和Y坐标;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))) ) |
|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2025-1-8 19:48
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.