CAD开发者社区

 找回密码
 立即注册

QQ登录

只需一步,快速开始

ActiveX 开发指南

关于旋转对象 (VBA/ActiveX)

2023-1-5 00:57| 发布者: admin| 查看: 750| 评论: 0|来自: AutoCAD

摘要: 可以旋转所有图形对象和属性参照对象。

可以旋转所有图形对象和属性参照对象。

若要旋转对象,请使用为该对象提供的方法。此方法需要基点和旋转角度作为输入。基点是具有三个双精度的变体数组。这些双精度表示一个 3D WCS 坐标,用于指定定义旋转轴的点。旋转角度以弧度为单位指定。此角度确定对象相对于其当前位置围绕基点旋转的距离。Rotate



围绕基点旋转折线

本示例创建一条闭合的轻量级多段线,然后将该折线绕基点 (4, 4.25, 0) 旋转 45 度。

Sub Ch4_RotatePolyline()
  ' Create the polyline
  Dim plineObj As AcadLWPolyline
  Dim points(0 To 11) As Double
  points(0) = 1: points(1) = 2
  points(2) = 1: points(3) = 3
  points(4) = 2: points(5) = 3
  points(6) = 3: points(7) = 3
  points(8) = 4: points(9) = 4
  points(10) = 4: points(11) = 2
  Set plineObj = ThisDrawing.ModelSpace.AddLightWeightPolyline(points)
  plineObj.Closed = True
  ZoomAll

  ' Define the rotation of 45 degrees about a
  ' base point of (4, 4.25, 0)
  Dim basePoint(0 To 2) As Double
  Dim rotationAngle As Double
  basePoint(0) = 4: basePoint(1) = 4.25: basePoint(2) = 0
  rotationAngle = 0.7853981   ' 45 degrees

  ' Rotate the polyline
  plineObj.Rotate basePoint, rotationAngle
  plineObj.Update
End Sub

路过

雷人

握手

鲜花

鸡蛋

最新评论

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

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

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

返回顶部