Query Rays
From AutoCAD ActiveX
Once created, you can query the first point of a ray using the BasePoint property. The second point used to create the ray is not stored with the object. Instead, use the DirectionVector property to obtain the directional vector for the ray.
Add, query, and edit a Ray object
The following example code creates a Ray object using the two points (5, 0, 0) and (1, 1, 0). It then queries the current base point and direction vector and displays the results in a message box. The direction vector is then changed and the base point and new direction vector are queried and displayed.
Sub Ch3_EditRay()
Dim rayObj As AcadRay
Dim basePoint(0 To 2) As Double
Dim secondPoint(0 To 2) As Double
' Define the raybasePoint(0) = 3#: basePoint(1) = 3#: basePoint(2) = 0#secondPoint(0) = 4#: secondPoint(1) = 4#: secondPoint(2) = 0#' Creates a Ray object in model spaceSet rayObj = ThisDrawing.ModelSpace.AddRay _(basePoint, secondPoint)ThisDrawing.Application.ZoomAll' Find the current status of the RayMsgBox "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 rayDim newVector(0 To 2) As DoublenewVector(0) = -1newVector(1) = 1newVector(2) = 0rayObj.DirectionVector = newVectorThisDrawing.Regen FalseMsgBox "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