Vla-get-xvector

提供:GizmoLabs - だいたい CAD LISP なサイト
構文
(vla-get-xvector vla-object vec)


機能
所定の UCS の X 方向を取得する。


引数
  • vla-object … UCS の VLAオブジェクト


戻り値
所定の UCS の X 方向を指定するベクトル。


  • 注意 :アクティブな UCS で X ベクトルの値を変更した場合は、アクティブな UCS を再設定しなければ変更結果を表示できない。アクティブな UCS を再設定するには、ActiveUCS プロパティを使用する。


サンプル
(vl-load-com)
(defun c:Example_XVector()
    ;; UCSのXY方向を取得して変更し、元に戻すサンプル

    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))

    ;; アクティブビューポートを取得
    (setq viewportObj (vla-get-ActiveViewport doc))
    
    ;; UCS を設定して表示
    (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)
    
    ;; X Y 方向を表示
    (alert (strcat "現在の XY 方向: "
                   "\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)))

    ;; 変更
    (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)

    ;; 戻す
    (vla-put-ActiveUCS doc ucsObj)

    (alert (strcat "新しいの XY 方向: "
                   "\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)))
)

関連事項