Coordinates 属性 (ActiveX)
指定对象中每个顶点的坐标。 支持的平台:仅限 Windows 签名VBA: object.Coordinates
属性值只读:不 类型:变体(双打数组) 点的数组。 3DFace 对象:变体是 WCS 中由三个或四个 3D 点组成的数组。 3DPolyline 对象:变体是 WCS 中的 3D 点数组。 Leader 对象:变体是 WCS 中的 3D 点数组。 LightweightPolyline 对象:变体是 OCS 中的 2D 点数组。 Mline 对象:变体是 WCS 中的 3D 点数组。 点对象:变体是 WCS 中 3D 点的数组。 PolyfaceMesh 对象:变体是 WCS 中的 3D 点数组。 PolygonMesh 对象:变体是 WCS 中的 3D 点数组。 折线对象:变体是 3D 点数组:X 和 Y 坐标位于 OCS 中;Z 坐标将被忽略。 实体对象:变体是 WCS 中由三个或四个 3D 点组成的数组。 跟踪对象:变体是 WCS 中由四个 3D 点组成的数组。 所有其他对象:变体是 WCS 中的 3D 点数组。 言论此属性将更新指定对象的坐标。使用标准数组处理技术处理此属性中包含的坐标。 PolyfaceMesh、PolygonMesh 和 Trace:不能使用此属性更改对象中的坐标数。您只能更改现有坐标的位置。 3DPolyline、折线和多边形网格:对于简单折线(非样条线或曲线拟合),此属性指定简单折点。对于样条线或曲线拟合折线,此属性指定控制点折点。 设置折线的坐标时,如果提供的坐标少于对象当前拥有的坐标,则折线将被截断。应用于截断顶点的任何拟合点也将被截断。如果提供的坐标多于对象当前拥有的坐标,则额外的折点将追加到折线。 可以使用该方法将 和 对象的 OCS 坐标转换为其他坐标系或从其他坐标系转换。PolylineLightweightPolylineTranslateCoordinates 例子VBA: Sub Example_Coordinates() ' This example creates a polyline. It then uses the Coordinates ' property to return all the coordinates in the polyline. It then ' resets one of the vertices using the Coordinates property. Dim plineObj As AcadPolyline ' Create Polyline Dim points(5) As Double points(0) = 3: points(1) = 7: points(2) = 0 points(3) = 9: points(4) = 2: points(5) = 0 Set plineObj = ThisDrawing.ModelSpace.AddPolyline(points) ThisDrawing.Regen True ' Return all the coordinates of the polyline Dim retCoord As Variant retCoord = plineObj.Coordinates ' Display current coordinates for the second vertex MsgBox "The current coordinates of the second vertex are: " & points(3) & ", " & points(4) & ", " & points(5), vbInformation, "Coordinates Example" ' Modify the coordinate of the second vertex to (5,5,0). Note that in ' case of a lightweight Polyline, indices will be different because the points are 2D only. points(3) = 5 points(4) = 5 points(5) = 0 plineObj.Coordinates = points ' Update display ThisDrawing.Regen True MsgBox "The new coordinates have been set to " & points(3) & ", " & points(4) & ", " & points(5), vbInformation, "Coordinates Example" End Sub 可视化 LISP: (vl-load-com) (defun c:Example_Coordinates() ;; This example creates a polyline. It then uses the Coordinates ;; property to return all the coordinates in the polyline. It then ;; resets one of the vertices using the Coordinates property. (setq acadObj (vlax-get-acad-object)) (setq doc (vla-get-ActiveDocument acadObj)) ;; Create Polyline (setq points (vlax-make-safearray vlax-vbDouble '(0 . 5))) (vlax-safearray-fill points '(3 7 0 9 2 0 ) ) (setq modelSpace (vla-get-ModelSpace doc)) (setq plineObj (vla-AddPolyline modelSpace points)) (vla-ZoomAll acadObj) ;; Return all the coordinates of the polyline (setq retCoord (vla-get-Coordinates plineObj)) ;; Display current coordinates for the second vertex (alert (strcat "The current coordinates of the second vertex are: " (rtos (vlax-safearray-get-element points 3) 2) ", " (rtos (vlax-safearray-get-element points 4) 2) ", " (rtos (vlax-safearray-get-element points 5) 2))) ;; Modify the coordinate of the second vertex to (5,5,0). Note that in ;; case of a lightweight Polyline, indices will be different because the points are 2D only. (vlax-safearray-put-element points 3 5) (vlax-safearray-put-element points 4 5) (vlax-safearray-put-element points 5 0) (vla-put-Coordinates plineObj points) ;; Update display (vla-Regen doc :vlax-true) (alert (strcat "The new coordinates have been set to: " (rtos (vlax-safearray-get-element points 3) 2) ", " (rtos (vlax-safearray-get-element points 4) 2) ", " (rtos (vlax-safearray-get-element points 5) 2))) ) |
|Archiver|CAD开发者社区 ( 苏ICP备2022047690号-1 苏公网安备32011402011833)
GMT+8, 2024-12-15 12:39
Powered by Discuz! X3.4
Copyright © 2001-2021, Tencent Cloud.