CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

中心属性 (ActiveX)

2023-1-3 20:55| 发布者: admin| 查看: 496| 评论: 0|来自: AutoCAD

摘要: 指定圆弧、圆、椭圆、视图或视口的中心。

指定圆弧、圆、椭圆、视图或视口的中心。

支持的平台:仅窗口

签名

工 务 局:

object.Center
对象

类型:圆弧暗径大,椭圆,光伏,视图视口

此属性适用的对象。

属性值

只读:

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

表示对象中心的 3D 坐标。默认中心为 (0,0,0)。

视口、视图:视口和视图对象的中心是 2D 坐标。

言论



例子

工 务 局:

Sub Example_Center()
    
    Dim circObj As AcadCircle
    Dim currCenterPt(0 To 2) As Double
    Dim newCenterPt(0 To 2) As Double
    Dim radius As Double
    
    ' Define the initial center point and radius for the circle
    currCenterPt(0) = 20: currCenterPt(1) = 30: currCenterPt(2) = 0
    radius = 3
    
    ' Create the circle in model space
    Set circObj = ThisDrawing.ModelSpace.AddCircle(currCenterPt, radius)
    ZoomAll
    MsgBox "The center point of the circle is " & currCenterPt(0) & ", " & currCenterPt(1) & ", " & currCenterPt(2), vbInformation, "Center Example"

    ' Change the center point of the circle
    newCenterPt(0) = 25: newCenterPt(1) = 25: newCenterPt(2) = 0
    circObj.center = newCenterPt
    circObj.Update
    
    ' Query the results of the new center position
    ' Notice the output from the center property is a variant
    Dim centerPoint As Variant
    centerPoint = circObj.center
    MsgBox "The center point of the circle is " & centerPoint(0) & ", " & centerPoint(1) & ", " & centerPoint(2), vbInformation, "Center Example"
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_Center()
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
  
    ;; Define the initial center point and radius for the circle
    (setq currCenterPt (vlax-3d-point 20 30 0)
          radius 3)
    
    ;; Create the circle in model space
    (setq modelSpace (vla-get-ModelSpace doc))
    (setq circObj (vla-AddCircle modelSpace currCenterPt radius))
    (vla-ZoomAll acadObj)
    (alert (strcat "The center point of the circle is"
		   "\n" (rtos (nth 0 (vlax-safearray->list (vlax-variant-value currCenterPt)))) ", "
		   (rtos (nth 1 (vlax-safearray->list (vlax-variant-value currCenterPt)))) ", "
		   (rtos (nth 2 (vlax-safearray->list (vlax-variant-value currCenterPt))))
           )
    )

    ;; Change the center point of the circle
    (setq newCenterPt (vlax-3d-point 25 25 0))
    (vla-put-Center circObj newCenterPt)
    (vla-Update circObj)
    
    ;; Query the results of the new center position
    ;; Notice the output from the center property is a variant
    (setq centerPoint (vlax-variant-value (vla-get-Center circObj)))
    (alert (strcat "The center point of the circle is"
		   "\n" (rtos (nth 0 (vlax-safearray->list centerPoint))) ", "
		   (rtos (nth 1 (vlax-safearray->list centerPoint))) ", "
		   (rtos (nth 2 (vlax-safearray->list centerPoint)))
           )
    )
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-5-19 12:22

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部