選擇需要化身成為XYZ座標的注解,再執行以下代碼即可:(希望不會引來質疑。)
Sub main()
Set swApp = Application.SldWorks
Set Part = swApp.ActiveDoc
Set SelMgr = Part.SelectionManager
c = SelMgr.GetSelectedObjectCount
For i = 1 To c
ObjectType = SelMgr.GetSelectedObjectType(i)
If ObjectType = 15 Then
Set Note = SelMgr.GetSelectedObject2(i)
XYZ = Note.GetAttachPos
UnitsLinearDecimalPlaces = Part.GetUserPreferenceIntegerValue(swUnitsLinearDecimalPlaces)
X = Round(XYZ(0) * 1000, UnitsLinearDecimalPlaces)
Y = Round(XYZ(1) * 1000, UnitsLinearDecimalPlaces)
Z = Round(XYZ(2) * 1000, UnitsLinearDecimalPlaces)
Note.SetText ("X: " & X & Chr(13) & "Y: " & Y & Chr(13) & "Z: " & Z)
End If
Next