CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

源属性 (ActiveX)

2023-1-3 09:30| 发布者: admin| 查看: 404| 评论: 0|来自: AutoCAD

摘要: 在 WCS 坐标中指定 UCS、块、图案填充或光栅图像的原点。

在 WCS 坐标中指定 UCS、块、图案填充或光栅图像的原点。

支持的平台:仅窗口

签名

工 务 局:

object.Origin
对象

类型:地理地图图像,图案填充模型空间图纸空间光栅图像UCS擦除

此属性适用的对象。

属性值

只读:

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

2D 点:表示相对于介质左下角的原点的XY值。

3D 点:指定对象原点的 3D WCS 坐标。

言论

图案填充:此属性是图案填充实体图案的原点坐标。

例子

工 务 局:

Sub Example_Origin()
    ' This example creates a UCS and returns its origin.

    Dim viewportObj As AcadViewport
    
    ' Set the viewportObj variable to the activeviewport
    Set viewportObj = ThisDrawing.ActiveViewport
    
    ' Create a new UCS with origin 2, 2, 0
    Dim ucsObj As AcadUCS
    Dim origin(0 To 2) As Double
    Dim xAxisPoint(0 To 2) As Double
    Dim yAxisPoint(0 To 2) As Double
    
    origin(0) = 2: origin(1) = 2: origin(2) = 0
    xAxisPoint(0) = 3: xAxisPoint(1) = 2: xAxisPoint(2) = 0
    yAxisPoint(0) = 2: yAxisPoint(1) = 3: yAxisPoint(2) = 0
    
    Set ucsObj = ThisDrawing.UserCoordinateSystems.Add(origin, xAxisPoint, yAxisPoint, "UCS1")
    ThisDrawing.ActiveUCS = ucsObj
    viewportObj.UCSIconOn = True
    viewportObj.UCSIconAtOrigin = True
    ThisDrawing.ActiveViewport = viewportObj
    
    ' Display the current origin for the new UCS
    MsgBox "The origin of the UCS is: " & ucsObj.origin(0) & ", " & ucsObj.origin(1) & ", " & ucsObj.origin(2), , "Origin Example"

    ' Change the origin of the UCS
    origin(0) = 4: origin(1) = 4: origin(2) = 0
    ucsObj.origin = origin
    
    ' Reset the active UCS and viewport to see the change
    ThisDrawing.ActiveUCS = ucsObj
    ThisDrawing.ActiveViewport = viewportObj
    
    MsgBox "The origin of the UCS is now: " & ucsObj.origin(0) & ", " & ucsObj.origin(1) & ", " & ucsObj.origin(2), , "Origin Example"
    
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_Origin()
    ;; This example creates a UCS and returns its origin.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
  
    ;; Set the viewportObj variable to the activeviewport
    (setq viewportObj (vla-get-ActiveViewport doc))
    
    ;; Create a new UCS with origin 2, 2, 0
    (setq origin (vlax-3d-point 2 2 0)
          xAxisPoint (vlax-3d-point 3 2 0)
          yAxisPoint (vlax-3d-point 2 3 0))
    
    (setq ucsObj (vla-Add (vla-get-UserCoordinateSystems doc) origin xAxisPoint yAxisPoint "UCS1"))
    (vla-put-ActiveUCS doc ucsObj)
    (vla-put-UCSIconOn viewportObj :vlax-true)
    (vla-put-UCSIconAtOrigin viewportObj :vlax-true)
    (vla-put-ActiveViewport doc viewportObj)
    
    ;; Display the current origin for the new UCS
    (alert (strcat "The origin of the UCS is: " (rtos (vlax-safearray-get-element (vlax-variant-value (vla-get-Origin ucsObj)) 0) 2) ", "
                                                (rtos (vlax-safearray-get-element (vlax-variant-value (vla-get-Origin ucsObj)) 1) 2) ", "
                                                (rtos (vlax-safearray-get-element (vlax-variant-value (vla-get-Origin ucsObj)) 2) 2)))

    ;; Change the origin of the UCS
    (setq origin (vlax-3d-point 4 4 0))
    (vla-put-Origin ucsObj origin)
    
    ;; Reset the active UCS and viewport to see the change
    (vla-put-ActiveUCS doc ucsObj)
    (vla-put-ActiveViewport doc viewportObj)
    
    (alert (strcat "The origin of the UCS is now: " (rtos (vlax-safearray-get-element (vlax-variant-value (vla-get-Origin ucsObj)) 0) 2) ", "
                                                    (rtos (vlax-safearray-get-element (vlax-variant-value (vla-get-Origin ucsObj)) 1) 2) ", "
                                                    (rtos (vlax-safearray-get-element (vlax-variant-value (vla-get-Origin ucsObj)) 2) 2)))
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-5-12 11:55

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部