CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

AutoCAD 2021 开发者帮助

关于在 3D 中旋转 (VBA/ActiveX)

2024-5-31 19:45| 发布者: admin| 查看: 9| 评论: 0|原作者: admin|来自: AutoCAD

关于在 3D 中旋转 (VBA/ActiveX)

使用该方法,您可以围绕指定点以 2D 形式旋转对象。Rotate

旋转方向由 WCS 确定。该方法以 3D 形式围绕指定的轴旋转对象。该方法采用三个值作为输入:定义旋转轴的两点的 WCS 坐标和以弧度为单位的旋转角度。Rotate3DRotate3D



若要旋转 3D 对象,请使用 or 方法。RotateRotate3D

创建一个 3D 盒子并绕轴旋转它

本示例创建一个 3D 框。然后,它定义要旋转的轴,最后将盒子绕轴旋转 30 度。

Sub Ch8_Rotate_3DBox()
    Dim boxObj As Acad3DSolid
    Dim length As Double
    Dim width As Double
    Dim height As Double
    Dim center(0 To 2) As Double

    ' Define the box
    center(0) = 5: center(1) = 5: center(2) = 0
    length = 5
    width = 7
    height = 10

    ' Create the box object in model space
    Set boxObj = ThisDrawing.ModelSpace. _
 AddBox(center, length, width, height)

    ' Define the rotation axis with two points
    Dim rotatePt1(0 To 2) As Double
    Dim rotatePt2(0 To 2) As Double
    Dim rotateAngle As Double
    rotatePt1(0) = -3: rotatePt1(1) = 4: rotatePt1(2) = 0
    rotatePt2(0) = -3: rotatePt2(1) = -4: rotatePt2(2) = 0
    rotateAngle = 30
    rotateAngle = rotateAngle * 3.141592 / 180#
    ' Rotate the box
    boxObj.Rotate3D rotatePt1, rotatePt2, rotateAngle
    ZoomAll
End Sub

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

GMT+8, 2024-6-27 16:21

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部