CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

相关分类

方向属性 (ActiveX)

2023-1-3 18:27| 发布者: admin| 查看: 288| 评论: 0|来自: AutoCAD

摘要: 指定绘图的三维可视化的查看方向或表格的方向矢量。

指定绘图的三维可视化的查看方向或表格的方向矢量。

支持的平台:仅窗口

签名

工 务 局:

object.Direction
对象

类型:拉伸曲面PViewport工作台视图视口

此属性适用的对象。

属性值

只读:

类型:变体

表对象:矢量(X轴,以 WCS 坐标为单位)定义包含表的水平面。

所有其他对象:矢量是一个三元素的双精度数组,用于定义可以从中查看绘图的方向。

言论

此属性使查看者能够查看图形,就像从空间中的指定点回望原点 (0, 0, 0) 一样。此属性类似于 AutoCAD 中的 VPOINT 命令。

例子

工 务 局:

Sub Example_Direction()
    ' This example creates a circle in model space
    ' and changes the thickness of the circle. Once
    ' the thickness has been changed, the direction
    ' of the active viewport is changed so that the
    ' new thickness setting is visible.
   
    Dim circleObj As AcadCircle
    Dim centerPoint(0 To 2) As Double
    Dim radius As Double
    
    ' Define the circle
    centerPoint(0) = 0#: centerPoint(1) = 0#: centerPoint(2) = 0#
    radius = 5#
    
    ' Create the Circle object in model space
    Set circleObj = ThisDrawing.ModelSpace.AddCircle(centerPoint, radius)
        
    ' Change the thickness of the circle
    circleObj.Thickness = 3
    
    ' Change the direction of the viewport so that you can
    ' view the change made to the thickness. Once you change
    ' the direction, you must reset the active viewport.
    Dim NewDirection(0 To 2) As Double
    NewDirection(0) = -1: NewDirection(1) = -1: NewDirection(2) = 1
    ThisDrawing.ActiveViewport.direction = NewDirection
    ThisDrawing.ActiveViewport = ThisDrawing.ActiveViewport
    
End Sub


Sub example_tableDirection()
    Dim oMS As AcadModelSpace
    Set oMS = ThisDrawing.ModelSpace
    Dim oT As AcadTable
    Dim pt(2) As Double
    Set oT = oMS.AddTable(pt, 4, 5, 5, 20)
    ZoomExtents
    Dim vDirection As Variant
    vDirection = oT.Direction
    MsgBox "Table Direction vector is " & vbCrLf & vDirection(0) & "," & vDirection(1) & "," & vDirection(2)

    Dim vNewDirection(2) As Double
    vNewDirection(0) = 0
    vNewDirection(1) = 1
    vNewDirection(2) = 0
    oT.Direction = vNewDirection
    
    Dim vRetDirection As Variant
    vRetDirection = oT.Direction
    MsgBox "New Table Direction vector is " & vbCrLf & vRetDirection(0) & "," & vRetDirection(1) & "," & vRetDirection(2)
End Sub

Visual LISP:

(vl-load-com)
(defun c:Example_Direction()
    ;; This example creates a circle in model space
    ;; and changes the thickness of the circle. Once
    ;; the thickness has been changed, the direction
    ;; of the active viewport is changed so that the
    ;; new thickness setting is visible.
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
    
    ;; Define the circle
    (setq centerPoint (vlax-3d-point 0 0 0)
          radius 5)

    ;; Create the Circle object in model space
    (setq modelSpace (vla-get-ModelSpace doc))  
    (setq circleObj (vla-AddCircle modelSpace centerPoint radius))
        
    ;; Change the thickness of the circle
    (vla-put-Thickness circleObj 3)
    
    ;; Change the direction of the viewport so that you can
    ;; view the change made to the thickness. Once you change
    ;; the direction, you must reset the active viewport.
    (setq NewDirection (vlax-3d-point -1 -1 1))
    (setq activeViewport (vla-get-ActiveViewport doc))
    (vla-put-Direction activeViewport NewDirection)
    (vla-put-ActiveViewport doc activeViewport)
)

(defun c:Example_TableDirection()
    (setq acadObj (vlax-get-acad-object))
    (setq doc (vla-get-ActiveDocument acadObj))
    (setq modelSpace (vla-get-ModelSpace doc))
  
    (setq pt (vlax-3d-point 0 0 0)
          oT (vla-AddTable modelSpace pt 4 5 5 20))

    (vla-ZoomExtents acadObj)
    (setq vDirection (vlax-safearray->list (vlax-variant-value (vla-get-Direction oT))))
    (alert (strcat "Table Direction vector is "
	           "\n" (rtos (nth 0 vDirection) 2) "," (rtos (nth 1 vDirection) 2) "," (rtos (nth 2 vDirection) 2)))

    (setq vNewDirection (vlax-3d-point 0 1 0))
    (vla-put-Direction oT vNewDirection)
    
    (setq vRetDirection (vlax-safearray->list (vlax-variant-value (vla-get-Direction oT))))
    (alert (strcat "New Table Direction vector is "
	           "\n" (rtos (nth 0 vRetDirection) 2) "," (rtos (nth 1 vRetDirection) 2) "," (rtos (nth 2 vRetDirection) 2)))
)

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-5-12 03:47

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部