放射線を作成したら、これを照会することで、オブジェクトの作成に使用された点を特定することができます。
BasePoint プロパティは、放射線の最初の点を取得するために使用できます。放射線の作成に使用された 2 番目の点はオブジェクトに格納されていませんが、DirectionVector プロパティを使用して、放射線の方向ベクトルを取得することができます。
次のコード例は、2 つの点(5、0、0) と (1、1、0)を使用して Ray オブジェクトを作成します。そして、現在の基点と方向ベクトルを取得し、結果をメッセージ ボックスに表示します。その後で方向ベクトルを変更し、基点と新しい方向ベクトルを照会して表示します。
Sub Ch3_EditRay() Dim rayObj As AcadRay Dim basePoint(0 To 2) As Double Dim secondPoint(0 To 2) As Double ' Define the ray basePoint(0) = 3#: basePoint(1) = 3#: basePoint(2) = 0# secondPoint(0) = 4#: secondPoint(1) = 4#: secondPoint(2) = 0# ' Creates a Ray object in model space Set rayObj = ThisDrawing.ModelSpace.AddRay(basePoint, secondPoint) ThisDrawing.Application.ZoomAll ' Find the current status of the Ray MsgBox "The base point of the ray is: " & _ rayObj.basePoint(0) & ", " & _ rayObj.basePoint(1) & ", " & _ rayObj.basePoint(2) & vbCrLf & _ "The directional vector for the ray is: " & _ rayObj.DirectionVector(0) & ", " & _ rayObj.DirectionVector(1) & ", " & _ rayObj.DirectionVector(2), , "Edit Ray" ' Change the directional vector for the ray Dim newVector(0 To 2) As Double newVector(0) = -1 newVector(1) = 1 newVector(2) = 0 rayObj.DirectionVector = newVector ThisDrawing.Regen False MsgBox "The base point of the ray is: " & _ rayObj.basePoint(0) & ", " & _ rayObj.basePoint(1) & ", " & _ rayObj.basePoint(2) & vbCrLf & _ "The directional vector for the ray is: " & _ rayObj.DirectionVector(0) & ", " & _ rayObj.DirectionVector(1) & ", " & _ rayObj.DirectionVector(2), , "Edit Ray" End Sub