- UID
- 3388
- 积分
- 3322
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-3-28
- 最后登录
- 1970-1-1
|
发表于 2018-5-7 23:31:39
|
显示全部楼层
你的VBA代码是帮助里面的? 你用的CAD版本是什么,下面是我在2019的VBA里面运行的帮助的代码,结果如下
变换了
---------------------------
TranslateCoordinates Example
---------------------------
The point has the following coordinates:
WCS: 1090.86014478392, 1980.06009680671, 2
UCS: 1088.86014478392, 1978.06009680671, 0
---------------------------
确定
---------------------------
 - Sub Example_TranslateCoordinates()
- ' This example creates a UCS with an origin at 2, 2, 2.
- ' Next, a point is entered by the user. The WCS and UCS
- ' coordinates of that point are output in a Msgbox.
- AppActivate ThisDrawing.Application.Caption
- ' Create a UCS named "New_UCS" in current drawing
- Dim ucsObj As AcadUCS
- Dim origin(0 To 2) As Double
- Dim xAxisPnt(0 To 2) As Double
- Dim yAxisPnt(0 To 2) As Double
- ' Define the UCS
- origin(0) = 2#: origin(1) = 2#: origin(2) = 2#
- xAxisPnt(0) = 5#: xAxisPnt(1) = 2#: xAxisPnt(2) = 2#
- yAxisPnt(0) = 2#: yAxisPnt(1) = 6#: yAxisPnt(2) = 2#
- ' Add the UCS to the UserCoordinatesSystems collection
- Set ucsObj = ThisDrawing.UserCoordinateSystems.Add(origin, xAxisPnt, yAxisPnt, "New_UCS")
- ThisDrawing.ActiveUCS = ucsObj
- ' Get the active viewport and make sure the UCS icon is on
- Dim viewportObj As AcadViewport
- Set viewportObj = ThisDrawing.ActiveViewport
- viewportObj.UCSIconOn = True
- viewportObj.UCSIconAtOrigin = True
- ThisDrawing.ActiveViewport = viewportObj
- ' Have the user enter a point
- Dim pointWCS As Variant
- pointWCS = ThisDrawing.Utility.GetPoint(, "Enter a point to translate:")
- ' Translate the point into UCS coordinates
- Dim pointUCS As Variant
- pointUCS = ThisDrawing.Utility.TranslateCoordinates(pointWCS, acWorld, acUCS, False)
- ' Display the coordinates of the point
- MsgBox "The point has the following coordinates:" & vbCrLf & _
- "WCS: " & pointWCS(0) & ", " & pointWCS(1) & ", " & pointWCS(2) & vbCrLf & _
- "UCS: " & pointUCS(0) & ", " & pointUCS(1) & ", " & pointUCS(2), , "TranslateCoordinates Example"
- End Sub
你对比下,和你的代码。
|
|