CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

XVector Property (ActiveX)

2023-1-3 00:47| 发布者: admin| 查看: 156| 评论: 0|来自: AutoCAD

摘要: 指定给定 UCS 的 X 方向。

指定给定 UCS 的 X 方向。

支持的平台:仅窗口

签名

工 务 局:

object.XVector
对象

类型:UCS

此属性适用的对象。

属性值

只读:

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

指定给定 UCS 的X方向的向量。

言论

如果更改活动 UCS 上的 X 矢量值,则必须重置活动 UCS 才能看到更改。若要重置活动的 UCS,请使用该属性。ActiveUCS

注意:此属性的值存储在 UCSXDIR 系统变量中。

例子

工 务 局:

Sub Example_XVector()
    ' This finds the current setting of XVector for a given UCS.
    ' It then changes the XVector and resets the UCS.

    Dim viewportObj As AcadViewport
    
    ' Set the viewportObj variable to the activeviewport
    Set viewportObj = ThisDrawing.ActiveViewport
    
    ' Define a new UCS and turn on the UCS icon at the origin.
    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 setting of the XVector
    MsgBox "The current XVector is: " _
           & ucsObj.XVector(0) & ", " & ucsObj.XVector(1) & ", " & ucsObj.XVector(2) & vbCrLf _
           & "The current YVector is: " _
           & ucsObj.YVector(0) & ", " & ucsObj.YVector(1) & ", " & ucsObj.YVector(2), , "XVector Example"

    ' Change the setting of XVector
    Dim newVector(0 To 2) As Double
    newVector(0) = 1: newVector(1) = 1: newVector(2) = 0
    ucsObj.XVector = newVector
    
    ' Reset the active UCS to see the change
    ThisDrawing.ActiveUCS = ucsObj
    
    MsgBox "The new XVector is: " _
           & ucsObj.XVector(0) & ", " & ucsObj.XVector(1) & ", " & ucsObj.XVector(2) & vbCrLf _
           & "The YVector is: " _
           & ucsObj.YVector(0) & ", " & ucsObj.YVector(1) & ", " & ucsObj.YVector(2), , "XVector Example"
    
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_XVector()
    ;; This finds the current setting of XVector for a given UCS.
    ;; It then changes the XVector and resets the UCS.
    (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))
    
    ;; Define a new UCS and turn on the UCS icon at the origin.
    (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 "TEST"))
    (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 setting of the XVector
    (alert (strcat "The current XVector is: "
                   "\n" (rtos (vlax-safearray-get-element (vlax-variant-value (vla-get-XVector ucsObj)) 0) 2) ", "
                        (rtos (vlax-safearray-get-element (vlax-variant-value (vla-get-XVector ucsObj)) 1) 2) ", "
                        (rtos (vlax-safearray-get-element (vlax-variant-value (vla-get-XVector ucsObj)) 2) 2)
                   "\nThe current YVector is: "
                   "\n" (rtos (vlax-safearray-get-element (vlax-variant-value (vla-get-YVector ucsObj)) 0) 2) ", "
                        (rtos (vlax-safearray-get-element (vlax-variant-value (vla-get-YVector ucsObj)) 1) 2) ", "
                        (rtos (vlax-safearray-get-element (vlax-variant-value (vla-get-YVector ucsObj)) 2) 2)))

    ;; Change the setting of XVector
    (setq newVector (vlax-3d-point 0.7071 0.7071 0))
    (vla-put-XVector ucsObj newVector)

    (setq newVector (vlax-3d-point -0.7071 0.7071 0))
    (vla-put-YVector ucsObj newVector)

    ;; Reset the active UCS to see the change
    (vla-put-ActiveUCS doc ucsObj)

    (alert (strcat "The new XVector is: "
                   "\n" (rtos (vlax-safearray-get-element (vlax-variant-value (vla-get-XVector ucsObj)) 0) 2) ", "
                        (rtos (vlax-safearray-get-element (vlax-variant-value (vla-get-XVector ucsObj)) 1) 2) ", "
                        (rtos (vlax-safearray-get-element (vlax-variant-value (vla-get-XVector ucsObj)) 2) 2)
                   "\nThe new YVector is: "
                   "\n" (rtos (vlax-safearray-get-element (vlax-variant-value (vla-get-YVector ucsObj)) 0) 2) ", "
                        (rtos (vlax-safearray-get-element (vlax-variant-value (vla-get-YVector ucsObj)) 1) 2) ", "
                        (rtos (vlax-safearray-get-element (vlax-variant-value (vla-get-YVector ucsObj)) 2) 2)))
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-5-11 14:32

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部